List of usage examples for android.support.v4.app FragmentActivity getSupportLoaderManager
public LoaderManager getSupportLoaderManager()
From source file:com.gh.bmd.jrt.android.v4.core.LoaderInvocation.java
/** * Destroys the loader with the specified ID and the specified inputs. * * @param context the context./*w ww. j av a 2 s .com*/ * @param loaderId the loader ID. * @param inputs the invocation inputs. */ @SuppressWarnings("unchecked") static void purgeLoader(@Nonnull final Object context, final int loaderId, @Nonnull final List<?> inputs) { final SparseArray<WeakReference<RoutineLoaderCallbacks<?>>> callbackArray = sCallbackMap.get(context); if (callbackArray == null) { return; } final LoaderManager loaderManager; if (context instanceof FragmentActivity) { final FragmentActivity activity = (FragmentActivity) context; loaderManager = activity.getSupportLoaderManager(); } else if (context instanceof Fragment) { final Fragment fragment = (Fragment) context; loaderManager = fragment.getLoaderManager(); } else { throw new IllegalArgumentException("invalid context type: " + context.getClass().getCanonicalName()); } int i = 0; while (i < callbackArray.size()) { final RoutineLoaderCallbacks<?> callbacks = callbackArray.valueAt(i).get(); if (callbacks == null) { callbackArray.remove(callbackArray.keyAt(i)); continue; } final RoutineLoader<Object, Object> loader = (RoutineLoader<Object, Object>) callbacks.mLoader; if ((loader.getInvocationCount() == 0) && (loaderId == callbackArray.keyAt(i)) && loader.areSameInputs(inputs)) { loaderManager.destroyLoader(loaderId); callbackArray.remove(loaderId); continue; } ++i; } if (callbackArray.size() == 0) { sCallbackMap.remove(context); } }
From source file:com.gh.bmd.jrt.android.v4.core.LoaderInvocation.java
/** * Destroys all loaders with the specified invocation class. * * @param context the context.//from w w w. j av a2 s.c om * @param loaderId the loader ID. * @param invocationClass the invocation class. * @param invocationArgs the invocation constructor arguments. */ static void purgeLoaders(@Nonnull final Object context, final int loaderId, @Nonnull final Class<?> invocationClass, @Nonnull final Object[] invocationArgs) { final SparseArray<WeakReference<RoutineLoaderCallbacks<?>>> callbackArray = sCallbackMap.get(context); if (callbackArray == null) { return; } final LoaderManager loaderManager; if (context instanceof FragmentActivity) { final FragmentActivity activity = (FragmentActivity) context; loaderManager = activity.getSupportLoaderManager(); } else if (context instanceof Fragment) { final Fragment fragment = (Fragment) context; loaderManager = fragment.getLoaderManager(); } else { throw new IllegalArgumentException("invalid context type: " + context.getClass().getCanonicalName()); } int i = 0; while (i < callbackArray.size()) { final RoutineLoaderCallbacks<?> callbacks = callbackArray.valueAt(i).get(); if (callbacks == null) { callbackArray.remove(callbackArray.keyAt(i)); continue; } final RoutineLoader<?, ?> loader = callbacks.mLoader; if ((loader.getInvocationType() == invocationClass) && Arrays.equals(loader.getInvocationArgs(), invocationArgs) && (loader.getInvocationCount() == 0)) { final int id = callbackArray.keyAt(i); if ((loaderId == ContextRoutineBuilder.AUTO) || (loaderId == id)) { loaderManager.destroyLoader(id); callbackArray.remove(id); continue; } } ++i; } if (callbackArray.size() == 0) { sCallbackMap.remove(context); } }
From source file:com.gh.bmd.jrt.android.v4.core.LoaderInvocation.java
/** * Destroys all loaders with the specified invocation class and the specified inputs. * * @param context the context.//from ww w .jav a 2 s . c om * @param loaderId the loader ID. * @param invocationClass the invocation class. * @param invocationArgs the invocation constructor arguments. * @param inputs the invocation inputs. */ @SuppressWarnings("unchecked") static void purgeLoader(@Nonnull final Object context, final int loaderId, @Nonnull final Class<?> invocationClass, @Nonnull final Object[] invocationArgs, @Nonnull final List<?> inputs) { final SparseArray<WeakReference<RoutineLoaderCallbacks<?>>> callbackArray = sCallbackMap.get(context); if (callbackArray == null) { return; } final LoaderManager loaderManager; if (context instanceof FragmentActivity) { final FragmentActivity activity = (FragmentActivity) context; loaderManager = activity.getSupportLoaderManager(); } else if (context instanceof Fragment) { final Fragment fragment = (Fragment) context; loaderManager = fragment.getLoaderManager(); } else { throw new IllegalArgumentException("invalid context type: " + context.getClass().getCanonicalName()); } int i = 0; while (i < callbackArray.size()) { final RoutineLoaderCallbacks<?> callbacks = callbackArray.valueAt(i).get(); if (callbacks == null) { callbackArray.remove(callbackArray.keyAt(i)); continue; } final RoutineLoader<Object, Object> loader = (RoutineLoader<Object, Object>) callbacks.mLoader; if ((loader.getInvocationType() == invocationClass) && Arrays.equals(loader.getInvocationArgs(), invocationArgs) && (loader.getInvocationCount() == 0)) { final int id = callbackArray.keyAt(i); if (((loaderId == ContextRoutineBuilder.AUTO) || (loaderId == id)) && loader.areSameInputs(inputs)) { loaderManager.destroyLoader(id); callbackArray.remove(id); continue; } } ++i; } if (callbackArray.size() == 0) { sCallbackMap.remove(context); } }
From source file:com.blandware.android.atleap.loader.LoaderManagerCreator.java
/** * Init Loader Manager for Activity/* w ww. j a v a2 s . c o m*/ * @param activity activity * @param callbacks callbacks * @param args arguments for loader construction * @param <T> */ public <T> LoaderManagerCreator(FragmentActivity activity, LoaderManager.LoaderCallbacks<T> callbacks, Bundle args) { this(activity.getApplicationContext(), activity.getSupportLoaderManager(), (int) HashUtil.longHash(((Object) activity).getClass(), activity.getIntent(), callbacks), callbacks, args); }
From source file:com.xbm.android.matisse.internal.model.AlbumCollection.java
public void onCreate(FragmentActivity activity, AlbumCallbacks callbacks) { mContext = new WeakReference<Context>(activity); mLoaderManager = activity.getSupportLoaderManager(); mCallbacks = callbacks;//from w w w .ja v a 2 s . c om }
From source file:com.laevatein.internal.model.DevicePhotoAlbumCollection.java
public void onCreate(FragmentActivity activity, DevicePhotoAlbumCallbacks callbacks) { mContext = new WeakReference<Context>(activity); mLoaderManager = activity.getSupportLoaderManager(); mCallbacks = callbacks;//from w w w.j a va2s .c o m }
From source file:com.xbm.android.matisse.internal.model.AlbumMediaCollection.java
public void onCreate(@NonNull FragmentActivity context, @NonNull AlbumMediaCallbacks callbacks) { mContext = new WeakReference<Context>(context); mLoaderManager = context.getSupportLoaderManager(); mCallbacks = callbacks;/* w ww.j a va 2s . c o m*/ }
From source file:com.laevatein.internal.model.AlbumPhotoCollection.java
public void onCreate(@NonNull FragmentActivity context, @NonNull AlbumPhotoCallbacks callbacks) { mContext = new WeakReference<Context>(context); mLoaderManager = context.getSupportLoaderManager(); mCallbacks = callbacks;// w ww . j a v a 2 s . c o m }
From source file:io.valuesfeng.picker.control.PictureCollection.java
public void onCreate(@NonNull FragmentActivity context, @NonNull GridView gridView, SelectedUriCollection mCollection, SelectionSpec selectionSpec) { mContext = new WeakReference<Context>(context); mLoaderManager = context.getSupportLoaderManager(); this.selectionSpec = selectionSpec; albumPhotoAdapter = new PictureAdapter(context, null, mCollection); mCollection.getEngine().scrolling(gridView); gridView.setAdapter(albumPhotoAdapter); }
From source file:com.github.jobs.ui.fragment.TemplatesListFragment.java
private void queryList() { try {// w w w. j a v a2 s . co m FragmentActivity activity = getActivity(); if (activity == null || !isAdded()) { return; } LoaderManager loaderManager = activity.getSupportLoaderManager(); Loader<Object> loader = loaderManager.getLoader(TEMPLATES_LOADER_ID); if (loader == null) { loaderManager.initLoader(TEMPLATES_LOADER_ID, null, this); } else { loaderManager.restartLoader(TEMPLATES_LOADER_ID, null, this); } } catch (IllegalStateException e) { // happens when activity is closed. We can't use isResumed since it will be false when the activity is // not being shown, thus it will cause problems if user loads another screen while this is still loading } }