@Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; mMap.setIndoorEnabled(true); mMap.setMyLocationEnabled(false); mMap.setOnMarkerClickListener(this); mMap.setOnIndoorStateChangeListener(this); mMap.setOnMapClickListener(this); UiSettings mapUiSettings = mMap.getUiSettings(); mapUiSettings.setZoomControlsEnabled(false); mapUiSettings.setMapToolbarEnabled(false); // load all markers LoaderManager lm = getLoaderManager(); lm.initLoader(TOKEN_LOADER_MARKERS, null, mMarkerLoader).forceLoad(); // load the tile overlays lm.initLoader(TOKEN_LOADER_TILES, null, mTileLoader).forceLoad(); setupMap(true); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); messageHelper = MessageHelper.getInstance(getActivity()); initializeMessageList(); // This needs to be done before initializing the cursor loader below initializeSortSettings(); loaderJustInitialized = true; LoaderManager loaderManager = getLoaderManager(); int len = accountUuids.length; cursors = new Cursor[len]; cursorValid = new boolean[len]; for (int i = 0; i < len; i++) { loaderManager.initLoader(i, null, this); cursorValid[i] = false; } }
public RecipientPresenter(Context context, LoaderManager loaderManager, RecipientMvpView recipientMvpView, Account account, ComposePgpInlineDecider composePgpInlineDecider, ComposePgpEnableByDefaultDecider composePgpEnableByDefaultDecider, AutocryptStatusInteractor autocryptStatusInteractor, ReplyToParser replyToParser, RecipientsChangedListener recipientsChangedListener) { this.recipientMvpView = recipientMvpView; this.context = context; this.autocryptStatusInteractor = autocryptStatusInteractor; this.composePgpInlineDecider = composePgpInlineDecider; this.composePgpEnableByDefaultDecider = composePgpEnableByDefaultDecider; this.replyToParser = replyToParser; this.listener = recipientsChangedListener; recipientMvpView.setPresenter(this); recipientMvpView.setLoaderManager(loaderManager); onSwitchAccount(account); }
@Before public void setUp() throws Exception { Context context = ShadowApplication.getInstance().getApplicationContext(); Robolectric.getBackgroundThreadScheduler().pause(); recipientMvpView = mock(RecipientMvpView.class); account = mock(Account.class); composePgpInlineDecider = mock(ComposePgpInlineDecider.class); composePgpEnableByDefaultDecider = mock(ComposePgpEnableByDefaultDecider.class); autocryptStatusInteractor = mock(AutocryptStatusInteractor.class); replyToParser = mock(ReplyToParser.class); LoaderManager loaderManager = mock(LoaderManager.class); listener = mock(RecipientPresenter.RecipientsChangedListener.class); recipientPresenter = new RecipientPresenter( context, loaderManager, recipientMvpView, account, composePgpInlineDecider, composePgpEnableByDefaultDecider, autocryptStatusInteractor, replyToParser, listener); runBackgroundTask(); noRecipientsAutocryptResult = new RecipientAutocryptStatus(RecipientAutocryptStatusType.NO_RECIPIENTS, null); }
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); String themes = sharedPrefs.getString( getString(R.string.settings_themes_key), getString(R.string.settings_themes_default)); switch (themes) { case "dark": setTheme(R.style.AppTheme); break; case "light": setTheme(R.style.AppTheme_Light); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, null, this); MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); }
@Override public void onChange(boolean selfChange) { if (!isAdded()) { return; } //clear map reload all data clearMap(); setupMap(false); // reload data from loaders LoaderManager lm = getActivity().getLoaderManager(); Loader<Cursor> loader = lm.getLoader(TOKEN_LOADER_MARKERS); if (loader != null) { loader.forceLoad(); } loader = lm.getLoader(TOKEN_LOADER_TILES); if (loader != null) { loader.forceLoad(); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mLoaderIdlingResource = new LoaderIdlingResource(getClass().getName() + "/" + getId(), getLoaderManager()); // Load data queries if any. if (mInitialQueriesToLoad != null && mInitialQueriesToLoad.length > 0) { LoaderManager manager = getLoaderManager(); for (int i = 0; i < mInitialQueriesToLoad.length; i++) { manager.initLoader(mInitialQueriesToLoad[i].getId(), null, this); } } else { // No data query to load, update the view. mUpdatableView.displayData(mModel, null); } }
@Before public void setUp() throws Exception { mockStatic(Base64.class); PowerMockito.when(Base64.encodeToString(any(byte[].class), any(Integer.class))).thenAnswer(invocation -> { byte[] bytes = (byte[]) invocation.getArguments()[0]; return new String(bytes); }); mPreferences = new SharedPreferencesMapImpl(); mContext = RxUtils.rxContext(); when(mContext.getSharedPreferences(anyString(), anyInt())).thenReturn(mPreferences); LoaderManager lm = RxUtils.rxLoaderManager(); mView = mock(LogInView.class); doNothing().when(mView).openRepositoriesScreen(); doNothing().when(mView).showLoginError(); doNothing().when(mView).showPasswordError(); mPresenter = new LogInPresenter(mContext, lm, mView); }
@Before public void setUp() throws Exception { Context context = RxUtils.rxContext(); LoaderManager loaderManager = RxUtils.rxLoaderManager(); mView = mock(RepositoriesView.class); doNothing().when(mView).showLoading(); doNothing().when(mView).hideLoading(); doNothing().when(mView).showError(); doNothing().when(mView).showRepositories(anyList()); doNothing().when(mView).showCommits(any(Repository.class)); RepositoriesRepository repository = new TestRepositoryImpl( generateRepositories(15)); mPresenter = new RepositoriesPresenter(context, loaderManager, mView, repository); }
@Before public void setUp() throws Exception { mView = Mockito.mock(WalkthroughView.class); Mockito.doNothing().when(mView).showBenefit(anyInt()); Mockito.doNothing().when(mView).setActionButtonText(anyInt()); Mockito.doNothing().when(mView).showLoadingSplash(); Mockito.doNothing().when(mView).showError(); Mockito.doNothing().when(mView).finishWalkthrough(); Context context = MockUtils.mockContext(); LoaderManager lm = MockUtils.mockLoaderManager(); mPresenter = new WalkthroughPresenter(context, lm, mView); RepositoryProvider.setRemoteRepository(new TestRemoteRepository()); RepositoryProvider.setKeyValueStorage(new TestKeyValueStorage()); }
@Test public void testGet() throws Exception { //GIVEN Activity activity = Robolectric.buildActivity(Activity.class).create().get(); Application application = RuntimeEnvironment.application; Scope appScope = Toothpick.openScope(application); appScope.installModules(new SmoothieApplicationModule(application)); Scope activityScope = Toothpick.openScopes(application, activity); activityScope.installModules(new SmoothieActivityModule(activity)); //WHEN Activity injectedActivity = activityScope.getInstance(Activity.class); FragmentManager fragmentManager = activityScope.getInstance(FragmentManager.class); LoaderManager loaderManager = activityScope.getInstance(LoaderManager.class); LayoutInflater layoutInflater = activityScope.getInstance(LayoutInflater.class); //THEN assertThat(injectedActivity, is(activity)); assertThat(fragmentManager, notNullValue()); assertThat(loaderManager, notNullValue()); assertThat(layoutInflater, notNullValue()); }
@Test public void testStartLoaderThatIsAlreadyInitialized() { final Activity activity = Robolectric.buildActivity(TestActivity.class).create().start().resume().get(); final FragmentManager fragmentManager = activity.getFragmentManager(); final BaseFragment fragment = new TestFragment(); fragmentManager.beginTransaction().add(fragment, null).commit(); fragmentManager.executePendingTransactions(); final LoaderManager loaderManager = fragment.getLoaderManager(); final LoaderManager.LoaderCallbacks mockLoaderCallbacks = mock(LoaderManager.LoaderCallbacks.class); final Loader firstLoader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null); final Loader secondLoader = new CursorLoader(mApplication, Uri.EMPTY, null, null, null, null); when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(firstLoader); loaderManager.initLoader(1, null, mockLoaderCallbacks); when(mockLoaderCallbacks.onCreateLoader(1, null)).thenReturn(secondLoader); assertThat(fragment.startLoader(1, null, mockLoaderCallbacks), is(secondLoader)); assertThat(loaderManager.getLoader(1), is(secondLoader)); loaderManager.destroyLoader(1); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mMessageHelper = MessageHelper.getInstance(getActivity()); initializeMessageList(); // This needs to be done before initializing the cursor loader below initializeSortSettings(); mLoaderJustInitialized = true; LoaderManager loaderManager = getLoaderManager(); int len = mAccountUuids.length; mCursors = new Cursor[len]; mCursorValid = new boolean[len]; for (int i = 0; i < len; i++) { loaderManager.initLoader(i, null, this); mCursorValid[i] = false; } }
@Override public void onChange(boolean selfChange) { if (!isAdded()) { return; } //clear map reload all data clearMap(); setupMap(false); // reload data from loaders LoaderManager lm = getActivity().getLoaderManager(); mMarkersLoaded = false; mOverlaysLoaded = false; Loader<Cursor> loader = lm.getLoader(MarkerQuery._TOKEN); if (loader != null) { loader.forceLoad(); } loader = lm.getLoader(OverlayQuery._TOKEN); if (loader != null) { loader.forceLoad(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String chosenAccountName = AccountUtils.getActiveAccountName(getActivity()); mPlusClient = new PlusClient.Builder(getActivity(), this, this) .clearScopes() .setAccountName(chosenAccountName) .build(); final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments()); mSessionUri = intent.getData(); if (mSessionUri == null) { return; } mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri); mVariableHeightHeader = intent.getBooleanExtra(EXTRA_VARIABLE_HEIGHT_HEADER, false); LoaderManager manager = getLoaderManager(); manager.restartLoader(0, null, this); setHasOptionsMenu(true); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.structureslist_item, null, new String[]{StructuresValues.Structures.NAME, StructuresValues.Structures.AWAY}, new int[]{R.id.structure_name, R.id.structure_away}, 0); setListAdapter(mAdapter); LoaderManager.LoaderCallbacks<Cursor> mCallbacks = this; LoaderManager lm = getLoaderManager(); lm.initLoader(LOADER_ID, null, mCallbacks); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.historylist_item, null, new String[]{HistoryValues.History.ENTRY, HistoryValues.History.CREATED_DATE_STR}, new int[]{R.id.history_entry, R.id.history_date}, 0); setListAdapter(mAdapter); LoaderManager.LoaderCallbacks<Cursor> mCallbacks = this; LoaderManager lm = getLoaderManager(); lm.initLoader(LOADER_ID, null, mCallbacks); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "onCreate()"); setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog); setCancelable(false); LoaderManager.enableDebugLogging(true); // https://groups.google.com/forum/#!topic/android-developers/DbKL6PVyhLI //Loader<ServerInfo> loader = getLoaderManager().initLoader(0, getArguments(), this); Loader<ServerInfo> loader = getLoaderManager().getLoader(0); if ( loader != null && loader.isReset() ) { loader = getLoaderManager().restartLoader(0, getArguments(), this); } else { loader = getLoaderManager().initLoader(0, getArguments(), this); } if (savedInstanceState == null) // http://code.google.com/p/android/issues/detail?id=14944 loader.forceLoad(); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Activity activity = getActivity(); if (!activity.isFinishing()) { // Start loading data LoaderManager loaderManager = getLoaderManager(); loaderManager.restartLoader(PeopleIveMetQuery.TOKEN, null, this); loaderManager.restartLoader(PeopleIveMetSubQuery.TOKEN, null, this); // Set up the API client GoogleApiClient.Builder builder = new GoogleApiClient.Builder(activity, this, this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN); if (AccountUtils.hasActiveAccount(activity)) { builder.setAccountName(AccountUtils.getActiveAccountName(activity)); } mApiClient = builder.build(); } }
private void onFeedbackQueryComplete(Cursor cursor) { // Views have not been set up yet -- continue loading the rest of data if (mSubmitFeedbackView == null) { LoaderManager manager = getLoaderManager(); manager.restartLoader(SessionsQuery._TOKEN, null, this); manager.restartLoader(SpeakersQuery._TOKEN, null, this); manager.restartLoader(TAG_METADATA_TOKEN, null, this); } // Is there existing feedback for this session? mAlreadyGaveFeedback = cursor.getCount() > 0; if (mAlreadyGaveFeedback) { final MessageCardView giveFeedbackCardView = (MessageCardView) mRootView.findViewById( R.id.give_feedback_card); if (giveFeedbackCardView != null) { giveFeedbackCardView.setVisibility(View.GONE); } if (mSubmitFeedbackView != null) { mSubmitFeedbackView.setVisibility(View.GONE); } } LOGD(TAG, "User " + (mAlreadyGaveFeedback ? "already gave" : "has not given") + " feedback for session."); cursor.close(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { Direction.FIELD_TITLE }, new int[] { android.R.id.text1 }, 0); setListAdapter(mAdapter); Bundle bundle = getArguments(); LoaderManager loaderManager = getLoaderManager(); if (bundle != null && loaderManager != null) { mRouteTag = bundle.getString(SelectRouteFragment.ROUTE_TAG); loaderManager.initLoader(0, null, this); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { Stop.FIELD_TITLE }, new int[] { android.R.id.text1 }, 0); setListAdapter(mAdapter); Bundle bundle = getArguments(); LoaderManager loaderManager = getLoaderManager(); if (bundle != null && loaderManager != null) { mRouteTag = bundle.getString(SelectRouteFragment.ROUTE_TAG); mDirectionTag = bundle.getString(SelectDirectionFragment.DIRECTION_TAG); loaderManager.initLoader(0, null, this); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_earthquake); init(); //TODO: verify if there's internet connection if(thereIsInternet()){ progressBar.setVisibility(View.VISIBLE); } else if(!(thereIsInternet())){ progressBar.setVisibility(View.GONE); noInternetConection.setText("There is no internet connection"); } // Find a reference to the {@link ListView} in the layout LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(EARTHQUAKE_LOADER, null, this); //TODO: set up the correct url earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Earthquake earthquake = earthquakeAdapterm.getItem(i); intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(earthquake.getUrl())); startActivity(intent); } }); }