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.example.vivek.team.EditorActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = { UserDB._ID, UserDB.COLUMN_NAME, UserDB.COLUMN_USERID, UserDB.COLUMN_GENDER, UserDB.COLUMN_BIRTHDAY };/*from w ww. ja v a 2 s .c om*/ return new CursorLoader(this, mCurrentUserUri, projection, null, null, null); }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case RECOMMENDED_VIDEOS_LOADER: { String category = args.getString(VideoContract.VideoEntry.COLUMN_CATEGORY); String query = args.getString(VideoContract.VideoEntry.COLUMN_DESC, ""); Loader<Cursor> c;// w w w. java 2 s .com if (query.contains(" ")) { c = new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " + " ( lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? ) AND " + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " == ? AND " + VideoContract.VideoEntry.COLUMN_CATEGORY + " == ? ", // Selection clause is category. new String[] { SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, queryNormalizer(query), SPECIAL_CHARACTERS, queryNormalizer(query), "1", "KY" }, VideoContract.VideoEntry.COLUMN_NAME// Default sort order ); } else { c = new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " + " ( lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? ) AND " + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " == ? AND " + VideoContract.VideoEntry.COLUMN_CATEGORY + " == ? ", // Selection clause is category. new String[] { SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, "%" + query + "%", "1", "KY" }, VideoContract.VideoEntry.COLUMN_NAME// Default sort order ); } return c; } 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 ); } case 0: { // 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 ); } default: { String query = mQuery; Loader<Cursor> c; if (query.contains(" ")) { c = new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " + " ( lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? ) AND " + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " == ? AND " + VideoContract.VideoEntry.COLUMN_CATEGORY + " == ? ", // Selection clause is category. new String[] { SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, queryNormalizer(query), SPECIAL_CHARACTERS, queryNormalizer(query), "1", "KY" }, VideoContract.VideoEntry.COLUMN_NAME// Default sort order ); } else { c = new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. //VideoContract.VideoEntry.COLUMN_CATEGORY + " = ? AND " + " ( lower ( trim ( " + VideoContract.VideoEntry.COLUMN_NAME + " , ? ) ) LIKE ? OR " + " lower ( trim ( " + VideoContract.VideoEntry.COLUMN_DESC + " , ? ) ) LIKE ? ) AND " + VideoContract.VideoEntry.COLUMN_RATING_SCORE + " == ? AND " + VideoContract.VideoEntry.COLUMN_CATEGORY + " == ? ", // Selection clause is category. new String[] { SPECIAL_CHARACTERS, "%" + query + "%", SPECIAL_CHARACTERS, "%" + query + "%", "1", "KY" }, VideoContract.VideoEntry.COLUMN_NAME// Default sort order ); } return c; } } }
From source file:galilei.kelimekavanozu.activity.PoemHistoryActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getApplicationContext(), PoemContract.CONTENT_URI, null, null, null, PoemContract.SORT_ORDER);//w w w .j a v a 2 s . co m }
From source file:com.example.android.pets.EditorActivity.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // Since the editor shows all pet attributes, define a projection that contains // all columns from the pet table String[] projection = { PetEntry._ID, PetEntry.COLUMN_PET_NAME, PetEntry.COLUMN_PET_BREED, PetEntry.COLUMN_PET_GENDER, PetEntry.COLUMN_PET_WEIGHT }; // This loader will execute the ContentProvider's query method on a background thread return new CursorLoader(this, // Parent activity context mCurrentPetUri, // Query the content URI for the current pet projection, // Columns to include in the resulting Cursor null, // No selection clause null, // No selection arguments null); // Default sort order }
From source file:io.github.protino.codewatch.ui.NavigationDrawerActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(this, LeaderContract.LeaderEntry.buildProfileUri(getWakatimeUid()), null, null, null, null);// ww w .j a va 2 s. com }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
/** * Extract the path from an uri// w w w . ja v a 2 s .c o m * This code was published on StackOverflow by dextor * * @param contentUri uri that contains the file path * @return absolute file path as string */ private String getRealPathFromURI(Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; CursorLoader loader = new CursorLoader(this.getActivity(), contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); }
From source file:com.example.android.pharmacyinventory.EditorActivity.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // Since the editor shows all drug attributes, define a projection that contains // all columns from the pet table String[] projection = { DrugContract.DrugEntry._ID, DrugContract.DrugEntry.COLUMN_DRUG_NAME, DrugContract.DrugEntry.COLUMN_DRUG_QUANTITY, DrugContract.DrugEntry.COLUMN_DRUG_PRICE, DrugContract.DrugEntry.COLUMN_DRUG_SOLD, DrugContract.DrugEntry.COLUMN_DRUG_IMAGE }; // This loader will execute the ContentProvider's query method on a background thread return new CursorLoader(this, // Parent activity context mCurrentDrugUri, // Query the content URI for the current drug projection, // Columns to include in the resulting Cursor null, // No selection clause null, // No selection arguments null); // Default sort order }
From source file:com.xengar.android.englishverbs.ui.DetailsActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = ActivityUtils.allVerbColumns(); return new CursorLoader(this, // Parent activity context VerbEntry.CONTENT_URI, projection, // Columns to include in the resulting Cursor COLUMN_ID + " = ?", // selection clause new String[] { Long.toString(verbID) }, // selection arguments null); // Default sort order }
From source file:com.ptapp.activity.SessionsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle data) { LOGD(TAG, "onCreateLoader, id=" + id + ", data=" + data); final Intent intent = BaseActivity.fragmentArgumentsToIntent(data); Uri sessionsUri = intent.getData();//w w w .j a v a 2s . c o m if ((id == SessionsQuery.NORMAL_TOKEN || id == SessionsQuery.SEARCH_TOKEN) && sessionsUri == null) { LOGD(TAG, "intent.getData() is null, setting to default sessions search"); /*sessionsUri = ScheduleContract.Sessions.CONTENT_URI;*/ /*sessionsUri = PTAppContract.ClassSubject.CONTENT_URI;*/ sessionsUri = PTAppContract.StaffEngagement.CONTENT_STAFF_GROUPS_URI; } Loader<Cursor> loader = null; //Log.d(TAG, "teacherId onCreateLoader: " + SharedPrefUtil.getPrefTeacherUserId(getActivity())); String selectionWhere = PTAppContract.StaffEngagement.STAFF_ID + " = ?"; /*String[] selectionArgs = new String[]{SharedPrefUtil.getPrefTeacherUserId(getActivity())};*/ //TODO:get the staff ID from the sharedPref. String[] selectionArgs = new String[] { String.valueOf(2) }; if (id == SessionsQuery.NORMAL_TOKEN) { LOGD(TAG, "Creating educator loader for " + sessionsUri + ", selectionWhere " + selectionWhere); loader = new CursorLoader(getActivity(), sessionsUri, SessionsQuery.NORMAL_PROJECTION, selectionWhere, selectionArgs, null); /*loader = new CursorLoader(getActivity(), sessionsUri, SessionsQuery.NORMAL_PROJECTION, selectionWhere, selectionArgs, PTAppContract.Courses.SORT_BY_COURSE_NAME);*/ } return loader; }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { int state = args.getInt("state", 4); switch (state) { case RECOMMENDED_VIDEOS_LOADER: { return CursorLoaderNormalizer(args.getString(VideoContract.VideoEntry.COLUMN_DESC, "")); }//ww w .j ava 2s . c om case QUEUE_VIDEOS_LOADER: { //Long videoId = args.getLong(VideoContract.VideoEntry._ID); return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. VideoContract.VideoEntry._ID + " IN ( ? ) OR " + VideoContract.VideoEntry.COLUMN_CARD_IMG + " LIKE ? ", // Selection clause is id. // Selection clause is category. new String[] { TextUtils.join(",", mBook), "%add.jpg" }, // Select based on the id. null//"INSTR (',"+TextUtils.join(",", mBook)+",', ',' || "+ VideoContract.VideoEntry._ID + " || ',')" // Default sort order ); } case SEARCH_VIDEOS_LOADER: { // Loading a specific video. return CursorLoaderNormalizer(mQuery); } default: { if (mQuery == null) { return new CursorLoader(getActivity(), VideoContract.VideoEntry.CONTENT_URI, null, // Projection to return - null means return all fields. VideoContract.VideoEntry._ID + " IN ( ? ) OR " + VideoContract.VideoEntry.COLUMN_CARD_IMG + " LIKE ? ", // Selection clause is id. // Selection clause is category. new String[] { TextUtils.join(",", mBook), "%add.jpg" }, // Select based on the id. null//"INSTR (',"+TextUtils.join(",", mBook)+",', ',' || "+ VideoContract.VideoEntry._ID + " || ',')" // Default sort order ); } else return CursorLoaderNormalizer(mQuery); } } }