CategoryController(final Activity activity, LoaderManager loaderManager, View itemView) { super(itemView); this.activity = activity; this.loaderManager = loaderManager; appCardsAdapter = new AppPreviewAdapter(activity); viewAll = (Button) itemView.findViewById(R.id.button); viewAll.setOnClickListener(onViewAll); heading = (TextView) itemView.findViewById(R.id.name); image = (FeatureImage) itemView.findViewById(R.id.category_image); background = (FrameLayout) itemView.findViewById(R.id.category_background); RecyclerView appCards = (RecyclerView) itemView.findViewById(R.id.app_cards); appCards.setAdapter(appCardsAdapter); appCards.addItemDecoration(new ItemDecorator(activity)); displayImageOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) .imageScaleType(ImageScaleType.NONE) .displayer(new FadeInBitmapDisplayer(100, true, true, false)) .bitmapConfig(Bitmap.Config.RGB_565) .build(); }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Utils.logD(LOG_TAG, "onCreate"); mSharedPreferences = new PreferencesManagerImp(getActivity().getApplicationContext()); mLocation = mSharedPreferences.getLocation(); if (savedInstanceState != null) { mRotation = true; } LoaderProvider loaderProvider = new LoaderProvider(getContext()); LoaderManager loaderManager = getLoaderManager(); Geocoder geocoder = new Geocoder(getActivity()); // loaderManager.enableDebugLogging(true); mPresenter = new FindPresenter(mLocation, loaderManager, loaderProvider, geocoder); setHasOptionsMenu(true); mRecentSearchSuggestions = new SearchRecentSuggestions(getContext(), RecentSuggestionsProvider.AUTHORITY, RecentSuggestionsProvider.MODE); mCompositeSubscription = new CompositeSubscription(); mActivityCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinator); mSnackCoordinator = (CoordinatorLayout) getActivity().findViewById(R.id.coordinatorSnackContainer); }
private void loadListViewItems(int listPosition, boolean markSeen, boolean showProgress) { if (!isAdded()) { return; } int loaderId = 0; ConversationsLoaderCallbacks callbacks = new ConversationsLoaderCallbacks(getContext(), listView, listPosition, cursorAdapter, markSeen, showProgress); LoaderManager manager = getLoaderManager(); Loader<?> loader = manager.getLoader(loaderId); if (loader == null) { // init and run the items loader manager.initLoader(loaderId, null, callbacks); } else { // restart loader manager.restartLoader(loaderId, null, callbacks); } }
private void loadListViewItems(String itemsFilter, boolean deleteItems, int listPosition) { if (!isAdded()) { return; } int loaderId = 0; JournalItemsLoaderCallbacks callbacks = new JournalItemsLoaderCallbacks(getContext(), cursorAdapter, itemsFilter, deleteItems, listView, listPosition); LoaderManager manager = getLoaderManager(); if (manager.getLoader(loaderId) == null) { // init and run the items loader manager.initLoader(loaderId, null, callbacks); } else { // restart loader manager.restartLoader(loaderId, null, callbacks); } }
private void loadListViewItems(int threadId, int unreadCount, int listPosition) { if (!isAdded()) { return; } int loaderId = 0; ConversationLoaderCallbacks callbacks = new ConversationLoaderCallbacks(getContext(), threadId, unreadCount, listView, listPosition, cursorAdapter); LoaderManager manager = getLoaderManager(); if (manager.getLoader(loaderId) == null) { // init and run the items loader manager.initLoader(loaderId, null, callbacks); } else { // restart loader manager.restartLoader(loaderId, null, callbacks); } }
private void loadListViewItems(String itemsFilter, boolean deleteItems, int listPosition) { if (!isAdded()) { return; } int loaderId = 0; ContactsLoaderCallbacks callbacks = new ContactsLoaderCallbacks(getContext(), contactType, cursorAdapter, itemsFilter, deleteItems, listView, listPosition); LoaderManager manager = getLoaderManager(); if (manager.getLoader(loaderId) == null) { // init and run the items loader manager.initLoader(loaderId, null, callbacks); } else { // restart loader manager.restartLoader(loaderId, null, callbacks); } }
private void search(EditText editText) { mEditText = editText; // Initialize the Loader with id '1239' and callbacks. // If the loader doesn't already exist, one is created. Otherwise, // the already created Loader is reused. In either case, the // LoaderManager will manage the Loader across the Activity/Fragment // lifecycle, will receive any new loads once they have completed, // and will report this new data back via callbacks. LoaderManager lm = getSupportLoaderManager(); //close any loader that is already running lm.destroyLoader(LOADER_ID); //init new loader lm.initLoader(LOADER_ID, null, this); }
@Test public void testGet() throws Exception { //GIVEN FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.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 SmoothieSupportActivityModule(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, instanceOf(FragmentActivity.class)); assertThat((FragmentActivity) injectedActivity, sameInstance(activity)); assertThat(fragmentManager, notNullValue()); assertThat(loaderManager, notNullValue()); assertThat(layoutInflater, notNullValue()); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Activity activity = getActivity(); if (activity instanceof FloatingActionButtonProvider) { actionButton = ((FloatingActionButtonProvider) activity).getActionButton(); if (actionButton != null) { actionButton.setOnClickListener(actionButtonClickListener); } } // Ensure the actionButton is initialized before creating the options menu setHasOptionsMenu(true); LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(BOOKMARK_STATUS_LOADER_ID, null, bookmarkStatusLoaderCallbacks); loaderManager.initLoader(EVENT_DETAILS_LOADER_ID, null, eventDetailsLoaderCallbacks); }
private void startSearch(String terms, String tags, int page){ noResults.setVisibility(View.GONE); Bundle args = new Bundle(); args.putString(SearchActivity.TERMS, terms); args.putString(SearchActivity.TAGS, tags); args.putInt(SearchActivity.PAGE, page); LoaderManager lm = getLoaderManager(); Loader l = lm.getLoader(page); if (l == null){ lm.initLoader(page, args, this); } //Check if the terms and tags are different from what the loader has and restart if they're different else { RequestSearchAsyncLoader s = (RequestSearchAsyncLoader)l; if (!s.getTerms().equalsIgnoreCase(searchTerms) || !s.getTags().equalsIgnoreCase(tags)){ lm.restartLoader(page, args, this); } else { lm.initLoader(page, args, this); } } }
private void startSearch(String terms, int page){ noResults.setVisibility(View.GONE); Bundle args = new Bundle(); args.putString(SearchActivity.TERMS, terms); args.putInt(SearchActivity.PAGE, page); LoaderManager lm = getLoaderManager(); Loader l = lm.getLoader(page); if (l == null){ lm.initLoader(page, args, this); } //Check if the terms and tags are different from what the loader has and restart if they're different else { UserSearchAsyncLoader s = (UserSearchAsyncLoader)l; if (!s.getTerms().equalsIgnoreCase(searchTerms)){ lm.restartLoader(page, args, this); } else { lm.initLoader(page, args, this); } } }
private void startSearch(String terms, String tags, int page){ noResults.setVisibility(View.GONE); Bundle args = new Bundle(); args.putString(SearchActivity.TERMS, terms); args.putString(SearchActivity.TAGS, tags); args.putInt(SearchActivity.PAGE, page); LoaderManager lm = getLoaderManager(); Loader l = lm.getLoader(page); if (l == null){ lm.initLoader(page, args, this); } //Check if the terms and tags are different from what the loader has and restart if they're different else { TorrentSearchAsyncLoader s = (TorrentSearchAsyncLoader)l; if (!s.getTerms().equalsIgnoreCase(searchTerms) || !s.getTags().equalsIgnoreCase(tags)){ lm.restartLoader(page, args, this); } else { lm.initLoader(page, args, this); } } }
public LoaderManager getLoaderManager() { if (mPlugins.isEmpty()) { return getOriginal().super_getLoaderManager(); } final ListIterator<FragmentPlugin> iterator = mPlugins.listIterator(mPlugins.size()); final CallFun0<LoaderManager> superCall = new CallFun0<LoaderManager>( "getLoaderManager()") { @Override public LoaderManager call() { if (iterator.hasPrevious()) { return iterator.previous().getLoaderManager(this); } else { return getOriginal().super_getLoaderManager(); } } }; return superCall.call(); }
public android.app.LoaderManager getLoaderManager() { if (mPlugins.isEmpty()) { return getOriginal().super_getLoaderManager(); } final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size()); final CallFun0<android.app.LoaderManager> superCall = new CallFun0<android.app.LoaderManager>("getLoaderManager()") { @Override public android.app.LoaderManager call() { if (iterator.hasPrevious()) { return iterator.previous().getLoaderManager(this); } else { return getOriginal().super_getLoaderManager(); } } }; return superCall.call(); }
public LoaderManager getSupportLoaderManager() { if (mPlugins.isEmpty()) { return getOriginal().super_getSupportLoaderManager(); } final ListIterator<ActivityPlugin> iterator = mPlugins.listIterator(mPlugins.size()); final CallFun0<LoaderManager> superCall = new CallFun0<LoaderManager>( "getSupportLoaderManager()") { @Override public LoaderManager call() { if (iterator.hasPrevious()) { return iterator.previous().getSupportLoaderManager(this); } else { return getOriginal().super_getSupportLoaderManager(); } } }; return superCall.call(); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); TestApplication.applicationGraph.inject(this); reset(favoriteManager); reset(userServices); reset(keyDelegate); reset(actionViewResolver.getActionView(mock(MenuItem.class))); controller = Robolectric.buildActivity(TestFavoriteActivity.class); when(favoriteManager.getSize()).thenReturn(2); when(favoriteManager.getItem(eq(0))).thenReturn(new TestFavorite( "1", "http://example.com", "title", System.currentTimeMillis())); when(favoriteManager.getItem(eq(1))).thenReturn(new TestFavorite( "2", "http://example.com", "ask HN", System.currentTimeMillis())); activity = controller.create().postCreate(null).start().resume().visible().get(); // skip menu due to search view recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view); adapter = recyclerView.getAdapter(); shadowAdapter = customShadowOf(adapter); fragment = activity.getSupportFragmentManager().findFragmentById(android.R.id.list); verify(keyDelegate).attach(any(Activity.class)); verify(favoriteManager).attach(any(Context.class), any(LoaderManager.class), observerCaptor.capture(), any()); }
@Test public void testSearchView() { SearchView searchView = (SearchView) actionViewResolver.getActionView(mock(MenuItem.class)); verify(searchView, atLeastOnce()).setOnSearchClickListener(searchViewClickListener.capture()); verify(searchView, atLeastOnce()).setOnCloseListener(searchViewCloseListener.capture()); searchViewClickListener.getAllValues() .get(searchViewClickListener.getAllValues().size() - 1) .onClick(searchView); assertFalse(((FavoriteFragment) fragment).startActionMode(null)); SearchView.OnCloseListener closeListener = searchViewCloseListener.getAllValues() .get(searchViewCloseListener.getAllValues().size() - 1); closeListener.onClose(); assertEquals(2, adapter.getItemCount()); ((FavoriteFragment) fragment).filter("ask"); verify(favoriteManager, times(2)).attach(any(Context.class), any(LoaderManager.class), observerCaptor.capture(), any()); when(favoriteManager.getSize()).thenReturn(1); when(favoriteManager.getItem(eq(0))).thenReturn(new TestFavorite( "2", "http://example.com", "ask HN", System.currentTimeMillis())); observerCaptor.getValue().onChanged(); assertEquals(1, adapter.getItemCount()); reset(searchView); closeListener.onClose(); verify(searchView).setQuery(eq(FavoriteActivity.EMPTY_QUERY), eq(true)); }
@Test @UiThreadTest public void test09TestLoadResetCallback() throws Exception { CursorLoader loader = BasicCRUDLoader.newInstance(context, mockLoaderManager) .forUri(testUri) .callback(mockBasicCRUDLoaderCallback) .loaderId(LOADER_ID) .initLoader(); // Ensure the callback has not yet been called assertFalse(mockBasicCRUDLoaderCallback.isCalled()); @SuppressWarnings("unchecked") LoaderManager.LoaderCallbacks<Cursor> callbacks = (LoaderManager.LoaderCallbacks<Cursor>) mockLoaderManager.getLoaderCallbacks(); assertNotNull(callbacks); // Simulate a loader reset. The loader id should be set and cursor is null callbacks.onLoaderReset(loader); assertTrue(mockBasicCRUDLoaderCallback.isCalled()); assertEquals(LOADER_ID, mockBasicCRUDLoaderCallback.getLoaderId()); assertNull(mockBasicCRUDLoaderCallback.getCursor()); }
public void load(LoaderManager loaderManager, CursorLoader cursorloader, PaperEntryConverter paperEntryConverter) { mLoaderManager = loaderManager; mPaperEntryConverter = paperEntryConverter; mCursorLoader = cursorloader; // image cache loader RequestQueue queue = AppContext.getInstance().getRequestQueue(); mImageLoader = new ImageLoader(queue, BitmapCache.getInstance()); // 设置幻灯片绑定 mSliderAdapter = new SliderAdapter(); mViewPager.setAdapter(mSliderAdapter); mPageIndicator.setViewPager(mViewPager); mLoaderManager.initLoader(mCursorLoader.hashCode(), null, new LoaderCallback()); }
private void startLoaders(@Nullable final Assignment assignment) { if (assignment != null) { // build the args used for various loaders final Bundle args = new Bundle(3); args.putString(ARG_GUID, mGuid); args.putString(ARG_MINISTRY_ID, assignment.getMinistryId()); args.putString(ARG_MCC, assignment.getMcc().toString()); // start loaders final LoaderManager manager = this.getLoaderManager(); if (assignment.getMcc() == Mcc.GCM) { manager.initLoader(LOADER_CHURCHES, args, mLoaderCallbacksChurches); } if (assignment.getMcc() != Mcc.UNKNOWN) { manager.initLoader(LOADER_TRAININGS, args, mLoaderCallbacksTraining); } } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final LoaderManager manager = getLoaderManager(); // Initialize the search adapter mAdapter = new SearchAdapter(getActivity()); mList.setAdapter(mAdapter); // Create callbacks before the initial loader is started mLoaderCallbacks = new CursorLoaderCallbacks(); // Reconnect to the loader only if present manager.initLoader(LOADER_ID_SEARCH, null, mLoaderCallbacks); // If there is a search term, put it in the text field if (!TextUtils.isEmpty(mSearchTerm)) { mSearch.setText(mSearchTerm); mSearch.selectAll(); } // Always start with an empty filter filter(""); }
/** * Initialize already started loaders. */ void initStartedLoaders() { LoaderManager lm = operatorContext.loaderManager; SparseArray<LoaderCookies> listenersMap = this.listenersMap; int count = listenersMap.size(); for (int i = 0; i < count; i++) { int loaderId = listenersMap.keyAt(i); Loader<?> loader = lm.getLoader(loaderId); if (loader != null && loader.isStarted()) { LoaderCookies cookies = listenersMap.valueAt(i); boolean notInit = (cookies.options & LoaderCookies.ALREADY_INIT) == 0; if (notInit) { Utils.initLoader( operatorContext, loaderId, STUB_PROVIDER, (cookies.options & LoaderCookies.DESTROY_ON_FINISH) == LoaderCookies.DESTROY_ON_FINISH, this ); } } } }
@Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setRetainInstance(true); mRunManager = RunManager.get(getActivity()); Bundle args = getArguments(); if(args != null){ long runId = args.getLong(ARG_RUN_ID, -1); if(runId != -1){ Log.d(TAG, "Run id: " + runId); // mRun = mRunManager.getRun(runId); // get the run instance // mLastLocation = mRunManager.getLastLocationForRun(runId); // get the last location for a specify runId LoaderManager lm = getLoaderManager(); lm.initLoader(LOAD_RUN, args, new RunLoaderCallbacks()); lm.initLoader(LOAD_LOCATION, args, new LocationLoaderCallBacks()); } } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new AltCursorAdapter(getActivity(), new int[]{R.layout.news_item}, null, new String[]{DB.MyNews.FEED_ID, DB.News.TITLE, DB.News.PUBLISHED_DATE}, new int[]{R.id.news_feed, R.id.news_title, R.id.news_date}); mAdapter.setViewBinder(new BinderNews(getActivity())); setListAdapter(mAdapter); initUI(); // on screen orientation changes, the loaders will return the last result, // without doing the background work again LoaderManager lm = getLoaderManager(); lm.initLoader(LoaderIds.CURSOR_GET_STARRED, null, cursorCallbacks); }
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Cursor c = mAdapter.getCursor(); Intent iNewsInfo = new Intent(getActivity(), NewsInfoActivity.class); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_ID, c.getString(c.getColumnIndex(DB.MyNews.ID))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_FEED_ID, c.getString(c.getColumnIndex(DB.MyNews.FEED_ID))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_AUTHOR, c.getString(c.getColumnIndex(DB.News.AUTHOR))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_TITLE, c.getString(c.getColumnIndex(DB.News.TITLE))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_DATE, c.getLong(c.getColumnIndex(DB.News.PUBLISHED_DATE))); iNewsInfo .putExtra(NewsInfoActivity.EXTRA_CONTENT_VALUES, c.getString(c.getColumnIndex(DB.News.CONTENT_VALUES))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_URL, c.getString(c.getColumnIndex(DB.News.URL))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_IS_BOOKMARK, c.getInt(c.getColumnIndex(DB.MyNews.IS_BOOKMARK)) > 0); startActivity(iNewsInfo); if (c.getInt(c.getColumnIndex(DB.MyNews.IS_READ)) == 0) { LoaderManager lm = getLoaderManager(); Bundle b = new Bundle(); b.putString("newsId", c.getString(c.getColumnIndex(DB.MyNews.ID))); b.putString("feedId", c.getString(c.getColumnIndex(DB.MyNews.FEED_ID))); lm.restartLoader(LoaderIds.ASYNC_UPDATE_READ, b, loaderCallbacks); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new AltCursorAdapter(getActivity(), new int[]{R.layout.news_item}, null, new String[]{ DB.News.TITLE, DB.News.PUBLISHED_DATE}, new int[]{R.id.news_title, R.id.news_date}); mAdapter.setViewBinder(new BinderNews(getActivity())); setListAdapter(mAdapter); initUI(); // on screen orientation changes, the loaders will return the last result, // without doing the background work again LoaderManager lm = getLoaderManager(); lm.initLoader(LoaderIds.CURSOR_GET_FEED + getArguments().getInt("position"), null, cursorCallbacks); }
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Cursor c = mAdapter.getCursor(); Intent iNewsInfo = new Intent(getActivity(), NewsInfoActivity.class); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_ID, c.getString(c.getColumnIndex(DB.MyNews.ID))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_FEED_ID, getArguments().getString("feedId")); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_AUTHOR, c.getString(c.getColumnIndex(DB.News.AUTHOR))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_TITLE, c.getString(c.getColumnIndex(DB.News.TITLE))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_DATE, c.getLong(c.getColumnIndex(DB.News.PUBLISHED_DATE))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_CONTENT_VALUES, c.getString(c.getColumnIndex(DB.News.CONTENT_VALUES))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_URL, c.getString(c.getColumnIndex(DB.News.URL))); iNewsInfo.putExtra(NewsInfoActivity.EXTRA_IS_BOOKMARK, c.getInt(c.getColumnIndex(DB.MyNews.IS_BOOKMARK)) > 0); startActivity(iNewsInfo); if (c.getInt(c.getColumnIndex(DB.MyNews.IS_READ)) == 0) { LoaderManager lm = getLoaderManager(); Bundle b = new Bundle(); b.putString("newsId", c.getString(c.getColumnIndex(DB.MyNews.ID))); lm.restartLoader(LoaderIds.ASYNC_UPDATE_READ, b, loaderCallbacks); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.buttonAuth: mTwitter = new TwitterFactory().getInstance(); mTwitter.setOAuthConsumer(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_key_secret)); mTwitter.setOAuthAccessToken(null); LoaderManager.LoaderCallbacks<RequestToken> requestTokenCallbacks = new TwitterOAuthRequestTokenCallbacks( this, mTwitter); getSupportLoaderManager() .initLoader(0, null, requestTokenCallbacks); break; case R.id.buttonSendPin: EditText editTextPin = (EditText) findViewById(R.id.editTextPin); if (editTextPin.getText().length() > 0 && mTwitter != null) { LoaderManager.LoaderCallbacks<AccessToken> accessTokenCallbacks = new TwitterOAuthAccessTokenCallbacks( this, mTwitter, editTextPin.getText().toString()); getSupportLoaderManager().initLoader(1, null, accessTokenCallbacks); } break; default: break; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); // Check for a Item ID as an argument, and find the item Bundle args = getArguments(); if (args != null) { long itemId = args.getLong(ARG_ITEM_ID, -1); if (itemId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(R.id.item_detail_fragment, args, new ItemLoaderCallbacks()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); // Check for a Item ID as an argument, and find the item Bundle args = getArguments(); if (args != null) { long locationId = args.getLong(ARG_LOCATION_ID, -1); if (locationId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(R.id.location_detail_fragment, args, new LocationLoaderCallbacks()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); setHasOptionsMenu(true); // Check for a Item ID as an argument, and find the item Bundle args = getArguments(); if (args != null) { long armorId = args.getLong(ARG_ARMOR_ID, -1); if (armorId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(R.id.armor_detail_fragment, args, new ArmorLoaderCallbacks()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); // Check for a Item ID as an argument, and find the item Bundle args = getArguments(); if (args != null) { long decorationId = args.getLong(ARG_DECORATION_ID, -1); if (decorationId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(R.id.decoration_detail_fragment, args, new DecorationLoaderCallbacks()); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); // Check for a Weapon ID as an argument, and find the weapon Bundle args = getArguments(); if (args != null) { long weaponId = args.getLong(ARG_WEAPON_ID, -1); if (weaponId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(R.id.weapon_detail_fragment, args, new WeaponLoaderCallbacks()); } } }
@Override public void onActivityCreated(Bundle savedState) { super.onActivityCreated(savedState); setEmptyText(getString(R.string.list_empty)); setHasOptionsMenu(false); setListShown(false); // styling listView final ExpandableListView list = getListView(); final Drawable divider = getResources().getDrawable(R.drawable.empty_divider); list.setChildDivider(divider); list.setOnChildClickListener(this); LoaderManager lm = getLoaderManager(); if (lm != null) lm.initLoader(LOADER_ID, null, this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_asset_class_list); mAdapter = new AssetClassListAdapter(null); initRecyclerView(mAdapter); LoaderManager.LoaderCallbacks<Cursor> loaderCallbacks = initLoaderCallbacks(); // get target asset class id, to exclude from the offered list Bundle loaderArgs = null; Intent intent = getIntent(); if (intent != null) { loaderArgs = new Bundle(); int assetClassId = intent.getIntExtra(EXTRA_ASSET_CLASS_ID, Constants.NOT_SET); loaderArgs.putInt(EXTRA_ASSET_CLASS_ID, assetClassId); } // start loader Loader loader = getSupportLoaderManager().initLoader(LOADER_ASSET_CLASSES, loaderArgs, loaderCallbacks); }
@Override public void onActivityCreated(Bundle savedInstanceState) { Log.d(TAG, "onActivityCreated()"); super.onActivityCreated(savedInstanceState); Locale locale = new Locale(Preferences.getString(getActivity(), Constants.PREFERENCE_LOCALE, "EN")); df = new SimpleDateFormat( getString(R.string.display_date_format), locale); Locales.updateLocale(getActivity(), locale); months = getActivity().getResources().getStringArray(R.array.months_long_format); // signal the dispatcher to sync mUri = getActivity().getIntent().getData(); if (mUri == null) { mUri = Encounters.CONTENT_URI; } mAdapter = new EncounterCursorAdapter(getActivity(), null, 0); setListAdapter(mAdapter); LoaderManager.enableDebugLogging(true); getActivity().getSupportLoaderManager().initLoader(Uris.ENCOUNTER_DIR, null, this); }
@Override public void onActivityCreated(Bundle savedInstanceState) { Log.d(TAG, "onActivityCreated()"); super.onActivityCreated(savedInstanceState); // signal the dispatcher to sync mUri = getActivity().getIntent().getData(); if (mUri == null) { mUri = Patients.CONTENT_URI; } Log.d(TAG, "onActivityCreated(): sync?"); mAdapter = new PatientCursorAdapter(getActivity(), null, 0); setListAdapter(mAdapter); mAdapter.setOnScrollCompleteListener(this); // Do we sync with server delta = getActivity().getResources().getInteger(R.integer.sync_delta_subjects); //sync(getActivity(), Subjects.CONTENT_URI); LoaderManager.enableDebugLogging(true); getActivity().getSupportLoaderManager().initLoader(PATIENTS_LOADER, null, this); }