List of usage examples for android.support.v4.app LoaderManager restartLoader
public abstract <D> Loader<D> restartLoader(int id, Bundle args, LoaderManager.LoaderCallbacks<D> callback);
From source file:mobisocial.musubi.ui.fragments.FeedListFragment.java
void initLoaders(boolean restart) { LoaderManager lm = getLoaderManager(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);//from w ww. j ava 2s. c o m Bundle args = new Bundle(); args.putLong("start", cal.getTimeInMillis()); if (restart) { lm.restartLoader(0, args, this); } else { lm.initLoader(0, args, this); } cal.add(Calendar.DAY_OF_MONTH, -1); for (int i = 1; i < DAYS_TO_SHOW; i++) { long time = cal.getTimeInMillis(); args = new Bundle(); args.putLong("start", time); args.putLong("end", time + ONE_DAY); if (restart) { lm.restartLoader(i, args, this); } else { lm.initLoader(i, args, this); } cal.add(Calendar.DAY_OF_MONTH, -1); } args = new Bundle(); args.putLong("end", cal.getTimeInMillis() + ONE_DAY); if (restart) { lm.restartLoader(DAYS_TO_SHOW, args, this); } else { lm.initLoader(DAYS_TO_SHOW, args, this); } }
From source file:org.mariotaku.twidere.fragment.StatusFragment.java
private void getStatus(final boolean omit_intent_extra) { final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_STATUS);//w w w .ja v a 2 s .c o m final Bundle args = new Bundle(); args.putBoolean(INTENT_KEY_OMIT_INTENT_EXTRA, omit_intent_extra); if (!mStatusLoaderInitialized) { lm.initLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks); mStatusLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks); } }
From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); Log.v("MISSION_LIST_FRAGMENT", "onAttach()"); // Activities containing this fragment must implement its callbacks. if (!(activity instanceof Callbacks)) { throw new IllegalStateException("Activity must implement fragment's callbacks."); }//from w w w . j a v a2s . co m // If a previous instance of the database was attached, the loader must be restarted boolean needReload = false; if (db != null && db.dbversion().equals("unknown")) { needReload = true; } // Check for a database if (getSherlockActivity() instanceof PendingMissionListActivity) { Log.v(TAG, "Loader: Connecting to Activity database"); db = ((PendingMissionListActivity) getSherlockActivity()).spatialiteDatabase; // restart the loader if needed if (needReload) { LoaderManager lm = getSherlockActivity().getSupportLoaderManager(); if (lm.getLoader(CURRENT_LOADER_INDEX) != null) { lm.restartLoader(CURRENT_LOADER_INDEX, null, this); } } } else { Log.w(TAG, "Loader: Could not connect to Activity database"); } listSelectionCallbacks = (Callbacks) activity; }
From source file:de.vanita5.twittnuker.fragment.support.StatusFragment.java
private void showLocationInfo(final boolean force) { if (mLocationInfoDisplayed && !force) return;//from ww w.j a v a 2 s .com final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_LOCATION); if (!mLocationLoaderInitialized) { lm.initLoader(LOADER_ID_LOCATION, null, mLocationLoaderCallbacks); mLocationLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_LOCATION, null, mLocationLoaderCallbacks); } }
From source file:de.vanita5.twittnuker.fragment.support.StatusFragment.java
private void showFollowInfo(final boolean force) { if (mFollowInfoDisplayed && !force) return;//from w w w .j a v a 2 s.c o m final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_FOLLOW); if (!mFollowInfoLoaderInitialized) { lm.initLoader(LOADER_ID_FOLLOW, null, mFollowInfoLoaderCallbacks); mFollowInfoLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_FOLLOW, null, mFollowInfoLoaderCallbacks); } }
From source file:com.stockbrowser.BookmarksPageCallbacks.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (loader.getId() == LOADER_ACCOUNTS) { LoaderManager lm = getLoaderManager(); int id = LOADER_BOOKMARKS; while (cursor.moveToNext()) { String accountName = cursor.getString(0); String accountType = cursor.getString(1); Bundle args = new Bundle(); args.putString(ACCOUNT_NAME, accountName); args.putString(ACCOUNT_TYPE, accountType); BrowserBookmarksAdapter adapter = new BrowserBookmarksAdapter(getActivity()); mBookmarkAdapters.put(id, adapter); boolean expand = true; try { expand = mState.getBoolean( accountName != null ? accountName : BookmarkExpandableView.LOCAL_ACCOUNT_NAME); } catch (JSONException e) { } // no state for accountName mGrid.addAccount(accountName, adapter, expand); lm.restartLoader(id, args, this); id++;/* www. j a va 2s . co m*/ } // TODO: Figure out what a reload of these means // Currently, a reload is triggered whenever bookmarks change // This is less than ideal // It also causes UI flickering as a new adapter is created // instead of re-using an existing one when the account_name is the // same. // For now, this is a one-shot load getLoaderManager().destroyLoader(LOADER_ACCOUNTS); } else if (loader.getId() >= LOADER_BOOKMARKS) { BrowserBookmarksAdapter adapter = mBookmarkAdapters.get(loader.getId()); adapter.changeCursor(cursor); } }
From source file:de.vanita5.twittnuker.fragment.support.UserProfileFragment.java
private void getFriendship() { final ParcelableUser user = mUser; final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_FRIENDSHIP); final Bundle args = new Bundle(); args.putLong(EXTRA_ACCOUNT_ID, user.account_id); args.putLong(EXTRA_USER_ID, user.id); if (!mGetFriendShipLoaderInitialized) { lm.initLoader(LOADER_ID_FRIENDSHIP, args, mFriendshipLoaderCallbacks); mGetFriendShipLoaderInitialized = true; } else {/* w ww . ja v a 2s .c om*/ lm.restartLoader(LOADER_ID_FRIENDSHIP, args, mFriendshipLoaderCallbacks); } }
From source file:de.vanita5.twittnuker.fragment.support.StatusFragment.java
private void getStatus(final boolean omit_intent_extra) { final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_STATUS);//from ww w . j av a 2 s .co m final Bundle args = new Bundle(getArguments()); args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omit_intent_extra); if (!mStatusLoaderInitialized) { lm.initLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks); mStatusLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_STATUS, args, mStatusLoaderCallbacks); } }
From source file:org.mariotaku.twidere.fragment.UserProfileFragment.java
public void getUserInfo(final long account_id, final long user_id, final String screen_name, final boolean omit_intent_extra) { mAccountId = account_id;/* w w w . j a v a 2 s .co m*/ mUserId = user_id; mScreenName = screen_name; final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_USER); lm.destroyLoader(LOADER_ID_FRIENDSHIP); lm.destroyLoader(LOADER_ID_BANNER); if (!isMyAccount(getActivity(), mAccountId)) { mListContainer.setVisibility(View.GONE); mErrorRetryContainer.setVisibility(View.GONE); return; } final Bundle args = new Bundle(); args.putBoolean(INTENT_KEY_OMIT_INTENT_EXTRA, omit_intent_extra); if (!mGetUserInfoLoaderInitialized) { lm.initLoader(LOADER_ID_USER, args, mUserInfoLoaderCallbacks); mGetUserInfoLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_USER, args, mUserInfoLoaderCallbacks); } if (account_id == -1 || user_id == -1 && screen_name == null) { mListContainer.setVisibility(View.GONE); mErrorRetryContainer.setVisibility(View.GONE); return; } }
From source file:de.vanita5.twittnuker.fragment.support.UserProfileFragment.java
public void getUserInfo(final long accountId, final long userId, final String screenName, final boolean omitIntentExtra) { final LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ID_USER);//from w w w . jav a 2s . co m lm.destroyLoader(LOADER_ID_FRIENDSHIP); if (!isMyAccount(getActivity(), accountId)) { mMainContent.setVisibility(View.GONE); mErrorRetryContainer.setVisibility(View.GONE); return; } final Bundle args = new Bundle(); args.putLong(EXTRA_ACCOUNT_ID, accountId); args.putLong(EXTRA_USER_ID, userId); args.putString(EXTRA_SCREEN_NAME, screenName); args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, omitIntentExtra); if (!mGetUserInfoLoaderInitialized) { lm.initLoader(LOADER_ID_USER, args, mUserInfoLoaderCallbacks); mGetUserInfoLoaderInitialized = true; } else { lm.restartLoader(LOADER_ID_USER, args, mUserInfoLoaderCallbacks); } if (accountId == -1 || userId == -1 && screenName == null) { mMainContent.setVisibility(View.GONE); mErrorRetryContainer.setVisibility(View.GONE); return; } }