List of usage examples for android.content CursorLoader CursorLoader
public CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder)
From source file:com.flym.dennikn.activity.HomeActivity.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { CursorLoader cursorLoader = new CursorLoader(this, FeedColumns.GROUPED_FEEDS_CONTENT_URI, new String[] { FeedColumns._ID, FeedColumns.URL, FeedColumns.NAME, FeedColumns.IS_GROUP, FeedColumns.ICON, FeedColumns.LAST_UPDATE, FeedColumns.ERROR, FEED_UNREAD_NUMBER }, PrefUtils.getBoolean(PrefUtils.SHOW_READ, true) ? "" : WHERE_UNREAD_ONLY, null, null); cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY); return cursorLoader; }
From source file:com.viktorrudometkin.burramys.activity.HomeActivity.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { CursorLoader cursorLoader = new CursorLoader(this, FeedColumns.GROUPED_FEEDS_CONTENT_URI, new String[] { FeedColumns._ID, FeedColumns.URL, FeedColumns.NAME, FeedColumns.IS_GROUP, FeedColumns.ICON, FeedColumns.LAST_UPDATE, FeedColumns.ERROR, FEED_UNREAD_NUMBER }, null, null, null);/*from w w w . ja va2 s .co m*/ cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY); return cursorLoader; }
From source file:com.jackie.movies.ui.MovieActivity.java
/** * @param id/*w w w . jav a 2 s .c om*/ * @param args * @return */ @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Log.d(TAG, "onCreateLoader() called with: id = [" + id + "], args = [" + args + "]"); Uri uri; String select; switch (id) { case MOVIE_FAVORITE_ID: uri = Movie.CONTENT_URI; select = Movie.FAVOUR + " = 1"; break; case MOVIE_LOADER_ID: String path = mIsPopular ? Movie.PATH_POPULAR : Movie.PATH_TOP_RATED; uri = Movie.CONTENT_URI.buildUpon().appendPath(path).appendPath(String.valueOf(currentPage)).build(); select = null; break; default: return null; } return new CursorLoader(this, uri, null, select, null, null); }
From source file:org.catnut.plugin.zhihu.ZhihuItemsFragment.java
private void initSearchLoader() { mSearchAdapter = new CursorAdapter(getActivity(), null, 0) { @Override//from w w w . j a v a2 s . c o m public View newView(Context context, Cursor cursor, ViewGroup parent) { return LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, null); } @Override public CharSequence convertToString(Cursor cursor) { return cursor.getString(1); } @Override public void bindView(View view, Context context, Cursor cursor) { TextView tv = (TextView) view; tv.setText(cursor.getString(1)); } }; mSearchLoader = new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String keywords = args.getString(Constants.KEYWORDS); return new CursorLoader(getActivity(), CatnutProvider.parse(Zhihu.MULTIPLE), PROJECTION, new StringBuilder(Zhihu.TITLE).append(" like ").append(CatnutUtils.like(keywords)) .append(" or ").append(Zhihu.DESCRIPTION).append(" like ") .append(CatnutUtils.like(keywords)).toString(), null, Zhihu.LAST_ALTER_DATE + " desc" ); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { mSearchAdapter.swapCursor(data); } @Override public void onLoaderReset(Loader<Cursor> loader) { mSearchAdapter.swapCursor(null); } }; mSearchView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Cursor c = (Cursor) mSearchAdapter.getItem(position); viewItem(c, id); } }); mSearchView.setAdapter(mSearchAdapter); }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayFragment_WebView.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case RECOMMENDED_VIDEOS_LOADER: // Fall through. case QUEUE_VIDEOS_LOADER: { String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?", // Selection clause is category. new String[] { category }, // Select based on the category. null // Default sort order );/*from w w w . j a v a 2 s .co m*/ } default: { // Loading a specific video. String videoId = args.getString(VideoContract.VideoEntry._ID); return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. VideoContract.VideoEntry._ID + " = ?", // Selection clause is id. new String[] { videoId }, // Select based on the id. null // Default sort order ); } } }
From source file:cn.edu.nju.dapenti.activity.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { CursorLoader cursorLoader = new CursorLoader(this, FeedData.FeedColumns.GROUPED_FEEDS_CONTENT_URI, new String[] { FeedData.FeedColumns._ID, FeedData.FeedColumns.URL, FeedData.FeedColumns.NAME, FeedData.FeedColumns.IS_GROUP, FeedData.FeedColumns.GROUP_ID, FeedData.FeedColumns.ICON, FeedData.FeedColumns.LAST_UPDATE, FeedData.FeedColumns.ERROR, "(SELECT COUNT(*) FROM " + FeedData.EntryColumns.TABLE_NAME + " WHERE " + FeedData.EntryColumns.IS_READ + " IS NULL AND " + FeedData.EntryColumns.FEED_ID + "=" + FeedData.FeedColumns.TABLE_NAME + "." + FeedData.FeedColumns._ID + ")", "(SELECT COUNT(*) FROM " + FeedData.EntryColumns.TABLE_NAME + " WHERE " + FeedData.EntryColumns.IS_READ + " IS NULL)", "(SELECT COUNT(*) FROM " + FeedData.EntryColumns.TABLE_NAME + " WHERE " + FeedData.EntryColumns.IS_FAVORITE + Constants.DB_IS_TRUE + ")" }, null, null, null);//from w w w . jav a 2s. c o m cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY); return cursorLoader; }
From source file:com.google.samples.apps.iosched.ui.SearchActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(this, ScheduleContract.SearchTopicsSessions.CONTENT_URI, SearchTopicsSessionsQuery.PROJECTION, null, new String[] { args.getString(ARG_QUERY) }, null); }
From source file:com.ivanmagda.inventory.ui.ProductEditor.java
/** * Implement LoaderManager.LoaderCallbacks<Cursor>. *///from w w w. j av a 2 s . c om @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(this, mCurrentProductUri, ProductEntry.PROJECTION_ALL, null, null, null); }
From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListSavedConnectionsActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader cursorLoader = new CursorLoader(this, DBContentProvider.CONNECTIONS_URI, null, null, null, null);//from w w w .j ava 2s. co m return cursorLoader; }
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader cursorLoader = new CursorLoader(this, FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(getIntent().getData().getLastPathSegment()), null, null, null, null);//from w ww.j av a 2 s .c o m cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY); return cursorLoader; }