android.app.LoaderManager Java Examples
The following examples show how to use
android.app.LoaderManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ManyQuery.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. */ @SuppressWarnings("unchecked") @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void getAsync(LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[]{resultClass}); } final int loaderId = sqlQuery.hashCode(); lm.initLoader(loaderId, null, getLoaderCallbacks(sqlQuery, resultClass, handler, respondsToUpdatedOf)); }
Example #2
Source File: Utils.java From android-skeleton-project with MIT License | 5 votes |
public static void initOrRestartLoader(LoaderManager loaderManager, int id, Bundle bundle, LoaderManager.LoaderCallbacks callbacks) { Loader loader = loaderManager.getLoader(id); if (loader == null) { loaderManager.initLoader(id, bundle, callbacks); } else { loaderManager.restartLoader(id, bundle, callbacks); } }
Example #3
Source File: BlockedMessagesFragment.java From NekoSMS with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mAdapter = new BlockedMessagesAdapter(this); LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, null, this); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setEmptyView(mEmptyView); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); registerForContextMenu(mRecyclerView); disableFab(); setTitle(R.string.blocked_messages); onNewArguments(getArguments()); BlockedSmsLoader.get().markAllSeen(getContext()); }
Example #4
Source File: FilterRulesFragment.java From NekoSMS with GNU General Public License v3.0 | 5 votes |
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Initialize filter list FilterRulesAdapter adapter = new FilterRulesAdapter(this); mAdapter = adapter; LoaderManager loaderManager = getLoaderManager(); loaderManager.initLoader(0, null, this); mRecyclerView.setAdapter(adapter); mRecyclerView.setEmptyView(mEmptyView); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); registerForContextMenu(mRecyclerView); // Display create FAB enableFab(R.drawable.ic_create_white_24dp, new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getContext(), FilterEditorActivity.class); intent.putExtra(FilterEditorActivity.EXTRA_ACTION, mAction.name()); startActivity(intent); } }); // Set strings according to which section we're displaying if (mAction == SmsFilterAction.BLOCK) { setTitle(R.string.blacklist_rules); mEmptyView.setText(R.string.blacklist_rules_empty_text); } else if (mAction == SmsFilterAction.ALLOW) { setTitle(R.string.whitelist_rules); mEmptyView.setText(R.string.whitelist_rules_empty_text); } // Handle import requests as necessary onNewArguments(getArguments()); }
Example #5
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; mItemList = rowContents; LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue(); mMapper = new VideoItemMapper(); ((CursorObjectAdapter) mItemList).setMapper(mMapper); }
Example #6
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; LOADER_ID = mRowUri.hashCode(); mMapper = new VideoItemMapper(); videos = new ArrayList<Video>(); }
Example #7
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; LOADER_ID = mRowUri.hashCode(); mMapper = new VideoItemMapper(); videos = new ArrayList<Video>(); }
Example #8
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; mItemList = rowContents; LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue(); mMapper = new VideoItemMapper(); ((CursorObjectAdapter) mItemList).setMapper(mMapper); }
Example #9
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; mItemList = rowContents; LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue(); mMapper = new VideoItemMapper(); ((CursorObjectAdapter) mItemList).setMapper(mMapper); }
Example #10
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; mItemList = rowContents; LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue(); mMapper = new VideoItemMapper(); ((CursorObjectAdapter) mItemList).setMapper(mMapper); }
Example #11
Source File: VideoDataManager.java From android-tv-leanback with Apache License 2.0 | 5 votes |
public VideoDataManager(Context mContext, LoaderManager mLoaderManager, Uri mRowUri, ObjectAdapter rowContents) { this.mLoaderManager = mLoaderManager; this.mRowUri = mRowUri; this.mContext = mContext; mItemList = rowContents; LOADER_ID = Double.valueOf(Math.random() * Integer.MAX_VALUE).intValue(); mMapper = new VideoItemMapper(); ((CursorObjectAdapter) mItemList).setMapper(mMapper); }
Example #12
Source File: PlaylistFragment.java From BeyondUPnP with Apache License 2.0 | 5 votes |
@Override public void onChange(boolean selfChange) { if (!isAdded()) { return; } //Reload data LoaderManager lm = getLoaderManager(); Loader<Cursor> loader = lm.getLoader(0); if (loader != null) { loader.forceLoad(); } }
Example #13
Source File: ContactsOpsImpl.java From mobilecloud-15 with Apache License 2.0 | 4 votes |
/** * Get the LoaderManager. */ public LoaderManager getLoaderManager() { return mContactsView.get().getLoaderManager(); }
Example #14
Source File: LoaderManagerAssert.java From assertj-android with Apache License 2.0 | 4 votes |
public LoaderManagerAssert(LoaderManager actual) { super(actual, LoaderManagerAssert.class); }
Example #15
Source File: ArcaModernDispatcher.java From arca-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ArcaModernDispatcher(final ArcaExecutor executor, final Context context, final LoaderManager manager) { super(executor, context, manager); }
Example #16
Source File: ModernRequestDispatcher.java From arca-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ModernRequestDispatcher(final RequestExecutor executor, final Context context, final LoaderManager manager) { super(executor); mContext = context; mLoaderManager = manager; }
Example #17
Source File: HomeFragment.java From FireFiles with Apache License 2.0 | 4 votes |
private void showRecents() { final RootInfo root = roots.getRecentsRoot(); recents.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openRoot(root); } }); mRecentsAdapter = new RecentsAdapter(getActivity(), null); mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() { @Override public void onItemClick(RecentsAdapter.ViewHolder item, int position) { openDocument(item.mDocumentInfo); } }); mRecentsRecycler.setAdapter(mRecentsAdapter); LinearSnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(mRecentsRecycler); final BaseActivity.State state = getDisplayState(this); mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() { @Override public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) { final RootsCache roots = DocumentsApplication.getRootsCache(getActivity()); return new RecentLoader(getActivity(), roots, state); } @Override public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) { if (!isAdded()) return; if(null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) { recents_container.setVisibility(View.GONE); } else { //recents_container.setVisibility(View.VISIBLE); mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT)); } } @Override public void onLoaderReset(Loader<DirectoryResult> loader) { mRecentsAdapter.swapCursor(null); } }; getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #18
Source File: ContactsActivity.java From mobilecloud-15 with Apache License 2.0 | 4 votes |
/** * Return the LoaderManager. */ @Override public LoaderManager getLoaderManager() { return super.getLoaderManager(); }
Example #19
Source File: ConnectionsFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = getActivity(); mAdapter = new ConnectionsAdapter(this); mCallbacks = new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri contentsUri = ExplorerProvider.buildConnection(); String selection = null; String[] selectionArgs = null; if(!Utils.hasWiFi(getActivity())){ selection = ExplorerProvider.ConnectionColumns.TYPE + "!=? " ; selectionArgs = new String[]{SERVER}; } return new CursorLoader(context, contentsUri, null, selection, selectionArgs, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor result) { if (!isAdded()) return; mAdapter.swapResult(result); mEmptyView.setVisibility(mAdapter.isEmpty() ? View.VISIBLE : View.GONE); if (isResumed()) { setListShown(true); } else { setListShownNoAnimation(true); } } @Override public void onLoaderReset(Loader<Cursor> loader) { mAdapter.swapResult(null); } }; setListAdapter(mAdapter); setListShown(false); // Kick off loader at least once getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #20
Source File: HomeFragment.java From FireFiles with Apache License 2.0 | 4 votes |
private void showRecents() { final RootInfo root = roots.getRecentsRoot(); recents.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openRoot(root); } }); mRecentsAdapter = new RecentsAdapter(getActivity(), null); mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() { @Override public void onItemClick(RecentsAdapter.ViewHolder item, int position) { openDocument(item.mDocumentInfo); } }); mRecentsRecycler.setAdapter(mRecentsAdapter); LinearSnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(mRecentsRecycler); final BaseActivity.State state = getDisplayState(this); mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() { @Override public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) { final RootsCache roots = DocumentsApplication.getRootsCache(getActivity()); return new RecentLoader(getActivity(), roots, state); } @Override public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) { if (!isAdded()) return; if(null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) { recents_container.setVisibility(View.GONE); } else { //recents_container.setVisibility(View.VISIBLE); mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT)); } } @Override public void onLoaderReset(Loader<DirectoryResult> loader) { mRecentsAdapter.swapCursor(null); } }; getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #21
Source File: ConnectionsFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = getActivity(); mAdapter = new ConnectionsAdapter(this); mCallbacks = new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri contentsUri = ExplorerProvider.buildConnection(); String selection = null; String[] selectionArgs = null; if(!Utils.hasWiFi(getActivity())){ selection = ExplorerProvider.ConnectionColumns.TYPE + "!=? " ; selectionArgs = new String[]{SERVER}; } return new CursorLoader(context, contentsUri, null, selection, selectionArgs, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor result) { if (!isAdded()) return; mAdapter.swapResult(result); mEmptyView.setVisibility(mAdapter.isEmpty() ? View.VISIBLE : View.GONE); if (isResumed()) { setListShown(true); } else { setListShownNoAnimation(true); } } @Override public void onLoaderReset(Loader<Cursor> loader) { mAdapter.swapResult(null); } }; setListAdapter(mAdapter); setListShown(false); // Kick off loader at least once getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #22
Source File: HomeFragment.java From FireFiles with Apache License 2.0 | 4 votes |
private void showRecents() { final RootInfo root = roots.getRecentsRoot(); recents.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { openRoot(root); } }); mRecentsAdapter = new RecentsAdapter(getActivity(), null); mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() { @Override public void onItemClick(RecentsAdapter.ViewHolder item, int position) { openDocument(item.mDocumentInfo); } }); mRecentsRecycler.setAdapter(mRecentsAdapter); LinearSnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(mRecentsRecycler); final BaseActivity.State state = getDisplayState(this); mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() { @Override public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) { final RootsCache roots = DocumentsApplication.getRootsCache(getActivity()); return new RecentLoader(getActivity(), roots, state); } @Override public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) { if (!isAdded()) return; if(null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) { recents_container.setVisibility(View.GONE); } else { //recents_container.setVisibility(View.VISIBLE); mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT)); } } @Override public void onLoaderReset(Loader<DirectoryResult> loader) { mRecentsAdapter.swapCursor(null); } }; getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #23
Source File: ConnectionsFragment.java From FireFiles with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = getActivity(); mAdapter = new ConnectionsAdapter(this); mCallbacks = new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri contentsUri = ExplorerProvider.buildConnection(); String selection = null; String[] selectionArgs = null; if(!Utils.hasWiFi(getActivity())){ selection = ExplorerProvider.ConnectionColumns.TYPE + "!=? " ; selectionArgs = new String[]{SERVER}; } return new CursorLoader(context, contentsUri, null, selection, selectionArgs, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor result) { if (!isAdded()) return; mAdapter.swapResult(result); mEmptyView.setVisibility(mAdapter.isEmpty() ? View.VISIBLE : View.GONE); if (isResumed()) { setListShown(true); } else { setListShownNoAnimation(true); } } @Override public void onLoaderReset(Loader<Cursor> loader) { mAdapter.swapResult(null); } }; setListAdapter(mAdapter); setListShown(false); // Kick off loader at least once getLoaderManager().restartLoader(mLoaderId, null, mCallbacks); }
Example #24
Source File: OneQuery.java From sprinkles with Apache License 2.0 | 3 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. * * @return the id of the loader. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int getAsync(LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[]{resultClass}); } final int loaderId = placeholderQuery.hashCode(); lm.restartLoader(loaderId, null, getLoaderCallbacks(rawQuery, resultClass, handler, respondsToUpdatedOf)); return loaderId; }
Example #25
Source File: OneQuery.java From sprinkles with Apache License 2.0 | 3 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. * * @return the id of the loader. */ public int getAsync(android.support.v4.app.LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[]{resultClass}); } final int loaderId = placeholderQuery.hashCode(); lm.restartLoader(loaderId, null, getSupportLoaderCallbacks(rawQuery, resultClass, handler, respondsToUpdatedOf)); return loaderId; }
Example #26
Source File: ManyQuery.java From sprinkles with Apache License 2.0 | 3 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. * * @return the id of the loader. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public int getAsync(LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[]{resultClass}); } final int loaderId = placeholderQuery.hashCode(); lm.restartLoader(loaderId, null, getLoaderCallbacks(rawQuery, resultClass, handler, respondsToUpdatedOf)); return loaderId; }
Example #27
Source File: ManyQuery.java From sprinkles with Apache License 2.0 | 3 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. * * @return the id of the loader. */ public int getAsync(android.support.v4.app.LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[]{resultClass}); } final int loaderId = placeholderQuery.hashCode(); lm.restartLoader(loaderId, null, getSupportLoaderCallbacks(rawQuery, resultClass, handler, respondsToUpdatedOf)); return loaderId; }
Example #28
Source File: OneQuery.java From flickr-uploader with GNU General Public License v2.0 | 3 votes |
/** * Execute the query asynchronously * * @param lm * The loader manager to use for loading the data * * @param handler * The ResultHandler to notify of the query result and any updates to that result. * * @param respondsToUpdatedOf * A list of models excluding the queried model that should also trigger a update to the result if they change. */ @SuppressWarnings("unchecked") @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void getAsync(LoaderManager lm, ResultHandler<T> handler, Class<? extends Model>... respondsToUpdatedOf) { if (Model.class.isAssignableFrom(resultClass)) { respondsToUpdatedOf = Utils.concatArrays(respondsToUpdatedOf, new Class[] { resultClass }); } final int loaderId = sqlQuery.hashCode(); lm.initLoader(loaderId, null, getLoaderCallbacks(sqlQuery, resultClass, handler, respondsToUpdatedOf)); }
Example #29
Source File: ContactsOps.java From mobilecloud-15 with Apache License 2.0 | 2 votes |
/** * Get the LoaderManager associated with the View. */ LoaderManager getLoaderManager();
Example #30
Source File: PadLandActivity.java From padland with Apache License 2.0 | 2 votes |
/** * Initializes a loader manager * The callbacks_container param is an object or class containing callback methods. * @param callbacks_container * @return */ protected void initLoader(LoaderManager.LoaderCallbacks callbacks_container){ getLoaderManager().initLoader(0, null, callbacks_container); }