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.aengbee.android.leanback.ui.MainFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == CATEGORY_LOADER) { return new CursorLoader(getActivity(), // Parent activity context VideoContract.VideoEntry.CONTENT_URI, // Table to query new String[] { "DISTINCT " + VideoContract.VideoEntry.COLUMN_CATEGORY }, // Only categories null, // No selection clause null, // No selection arguments VideoContract.VideoEntry.COLUMN_NAME // Default sort order );/*w w w . ja va 2s.com*/ } else { // Assume it is for a video. String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); // This just creates a CursorLoader that gets all videos. return new CursorLoader(getActivity(), // Parent activity context VideoContract.VideoEntry.CONTENT_URI, // Table to query null, // Projection to return - null means return all fields VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?", // Selection clause new String[] { category }, // Select based on the category id. VideoContract.VideoEntry.COLUMN_NAME// Default sort order ); } }
From source file:com.ksharkapps.musicnow.ui.activities.SearchActivity.java
/** * {@inheritDoc}//from ww w . j a v a2s .com */ @Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { final Uri uri = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(mFilterString)); final String[] projection = new String[] { BaseColumns._ID, MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Artists.ARTIST, MediaStore.Audio.Albums.ALBUM, MediaStore.Audio.Media.TITLE, "data1", "data2" }; return new CursorLoader(this, uri, projection, null, null, null); }
From source file:com.antew.redditinpictures.library.ui.RedditImageAdapterViewFragment.java
/** * Instantiate and return a new Loader for the given ID. * * @param id/*from ww w .j av a 2 s . c om*/ * The ID whose loader is to be created. * @param args * Any arguments supplied by the caller. * * @return Return a new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case Constants.Loader.LOADER_REDDIT: return new CursorLoader(getActivity(), RedditContract.RedditData.CONTENT_URI, // uri null, // projection "subreddit = ?", // selection new String[] { mCurrentSubreddit }, // selectionArgs[] RedditContract.Posts.DEFAULT_SORT); // sort case Constants.Loader.LOADER_POSTS: QueryCriteria queryCriteria = getPostsQueryCriteria(); String selection = null; String[] selectionArgs = null; List<String> selectionArgsList = new ArrayList<String>(); // If we have an aggregate subreddit we want to return relevant things. if (SubredditUtil.isAggregateSubreddit(mCurrentSubreddit)) { selection = null; selectionArgs = null; } else if (mCurrentSubreddit.contains("+")) { // Poor mans checking for multis. If we have a multi, we want to handle all of them appropriately. String[] subredditArray = mCurrentSubreddit.split("\\+"); for (String item : subredditArray) { if (selection == null) { selection = RedditContract.PostColumns.SUBREDDIT + " in (?"; } else { selection += ",?"; } selectionArgsList.add(item); } // Close the in statement. selection += ")"; } else { selection = RedditContract.PostColumns.SUBREDDIT + " = ?"; selectionArgsList.add(mCurrentSubreddit); } // If the user doesn't want to see NSFW images, filter them out. Otherwise do nothing. if (!SharedPreferencesHelper.getShowNsfwImages(getActivity())) { if (Strings.isEmpty(selection)) { selection = RedditContract.PostColumns.OVER_18 + " = ?"; } else { selection += " and " + RedditContract.PostColumns.OVER_18 + " = ?"; } selectionArgsList.add("0"); } if (selectionArgsList != null && selectionArgsList.size() > 0) { selectionArgs = selectionArgsList.toArray(new String[] {}); } Ln.d("Retrieveing Posts For %s %s", selection, Strings.toString(selectionArgs)); return new CursorLoader(getActivity(), RedditContract.Posts.CONTENT_URI, // uri queryCriteria.getProjection(), // projection selection, // selection selectionArgs, // selectionArgs[] queryCriteria.getSort()); // sort default: return null; } }
From source file:com.example.android.sampletvinput.MainFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == CATEGORY_LOADER) { return new CursorLoader(getActivity(), // Parent activity context VideoContract.VideoEntry.CONTENT_URI, // Table to query new String[] { "DISTINCT " + VideoContract.VideoEntry.COLUMN_CATEGORY }, // Only categories null, // No selection clause null, // No selection arguments null // Default sort order );/* w ww . ja v a 2 s. co m*/ } else { // Assume it is for a video. String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); // This just creates a CursorLoader that gets all videos. return new CursorLoader(getActivity(), // Parent activity context VideoContract.VideoEntry.CONTENT_URI, // Table to query null, // Projection to return - null means return all fields VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?", // Selection clause new String[] { category }, // Select based on the category id. null // Default sort order ); } }
From source file:com.codebutler.farebot.activities.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle bundle) { return new CursorLoader(this, CardProvider.CONTENT_URI_CARD, CardDBHelper.PROJECTION, null, null, CardsTableColumns.SCANNED_AT + " DESC, " + CardsTableColumns._ID + " DESC"); }
From source file:com.example.android.sampletvinput.VideoDetailsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case RELATED_VIDEO_LOADER: { String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, VideoContract.VideoEntry.COLUMN_CATEGORY + " = ?", new String[] { category }, null); }/* w ww. j a va 2 s . c o m*/ default: { // Loading video from global search. String videoId = args.getString(VideoContract.VideoEntry._ID); return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, VideoContract.VideoEntry._ID + " = ?", new String[] { videoId }, null); } } }
From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri baseUri = OperationsContentProvider.CONTENT_URI; if (parent != null) { return new CursorLoader(getActivity(), baseUri, OperationSchema.COLUMN_ALL, OperationSchema.COLUMN_PARENT_ID + "=\"" + parent.getIdentifier() + "\" AND " + OperationSchema.COLUMN_REQUEST_TYPE + "=" + operationType, null, null);//w w w. j a v a 2s . c om } else { return new CursorLoader(getActivity(), baseUri, OperationSchema.COLUMN_ALL, OperationSchema.COLUMN_REQUEST_TYPE + "=" + operationType, null, null); } }
From source file:org.getlantern.firetweet.fragment.CustomTabsFragment.java
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { return new CursorLoader(getActivity(), Tabs.CONTENT_URI, Tabs.COLUMNS, null, null, Tabs.DEFAULT_SORT_ORDER); }
From source file:de.hshannover.f4.trust.ironcontrol.view.list_activities.ListVendorMetadataActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri uri = null;// w w w. j a v a 2 s . c o m switch (ACTIVE_VIEW) { case OVERVIEW: uri = DBContentProvider.VENDOR_METADATA_URI; System.out.println("onCreateLoader OVERVIEW"); break; case ATTRIBUTES_VIEW: uri = Uri.parse(DBContentProvider.VENDOR_METADATA_URI + "/" + id + "/" + DBContentProvider.VENDOR_META_ATTRIBUTES); System.out.println("onCreateLoader ATTRIBUTES_VIEW"); break; } CursorLoader cursorLoader = new CursorLoader(this, uri, null, null, null, null); return cursorLoader; }
From source file:com.technoxist.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.GROUP_ID, FeedColumns.ICON, FeedColumns.LAST_UPDATE, FeedColumns.ERROR, FEED_UNREAD_NUMBER }, PrefUtils.getBoolean(PrefUtils.SHOW_READ, true) ? "" : "", null, null); cursorLoader.setUpdateThrottle(Constants.UPDATE_THROTTLE_DELAY); return cursorLoader; }