List of usage examples for android.support.v4.content CursorLoader CursorLoader
public CursorLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder)
From source file:com.mstoyanov.music_lessons.StudentsFragment.java
@Override public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) { switch (loaderID) { case STUDENTS_LOADER: return new CursorLoader(getActivity(), // context SchoolContract.STUDENTS_TABLE_CONTENTURI, // uri projection, // projection null, // selection null, // selectionArgs sortOrder // firstName, lastName );/*from w ww. j av a 2 s .co m*/ case STUDENT_DETAILS_LOADER: return new CursorLoader(getActivity(), // context SchoolContract.STUDENTS_TABLE_CONTENTURI, // uri null, // projection selection, // selection selectionArgs, // selectionArgs null // sortOrder ); case LESSONS_LOADER: return new CursorLoader(getActivity(), // context SchoolContract.SCHEDULE_TABLE_CONTENTURI, // uri null, // projection selection, // selection selectionArgs, // selectionArgs null // sortOrder ); default: throw new IllegalArgumentException("Invalid loaderID: " + loaderID); } }
From source file:ac.robinson.mediaphone.activity.NarrativeBrowserActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(NarrativeBrowserActivity.this, NarrativeItem.NARRATIVE_CONTENT_URI, NarrativeItem.PROJECTION_ALL, NarrativeItem.SELECTION_NOT_DELETED, null, NarrativeItem.DEFAULT_SORT_ORDER); }
From source file:cc.mintcoin.wallet.ui.SendingAddressesFragment.java
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { final Uri uri = AddressBookProvider.contentUri(activity.getPackageName()); return new CursorLoader(activity, uri, null, AddressBookProvider.SELECTION_NOTIN, new String[] { walletAddressesSelection != null ? walletAddressesSelection : "" }, AddressBookProvider.KEY_LABEL + " COLLATE LOCALIZED ASC"); }
From source file:com.battlelancer.seriesguide.ui.ActivityFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle args) { String type = getArguments().getString(InitBundle.TYPE); boolean isInfiniteScrolling = ActivitySettings.isInfiniteActivity(getActivity()); // infinite or 30 days activity stream String[][] queryArgs = DBUtils.buildActivityQuery(getActivity(), type, isInfiniteScrolling ? -1 : 30); // prevent upcoming/recent episodes from becoming stale schedulePeriodicDataRefresh(true);//from ww w. jav a 2 s. c o m return new CursorLoader(getActivity(), Episodes.CONTENT_URI_WITHSHOW, ActivityQuery.PROJECTION, queryArgs[0][0], queryArgs[1], queryArgs[2][0]); }
From source file:com.bexkat.feedlib.ItemListFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = new String[] { ItemTable._ID, ItemTable.COLUMN_TITLE, ItemTable.COLUMN_PUBDATE, ItemTable.COLUMN_READ, ItemTable.COLUMN_FAVORITE }; CursorLoader cursorLoader;/*from w w w. j a va 2 s . c o m*/ if (mFeedId != -1) cursorLoader = new CursorLoader(getActivity(), Uri.parse(MyContentProvider.FEEDLIST_CONTENT_URI + "/" + mFeedId), projection, null, null, ItemTable.COLUMN_READ + DatabaseHelper.SORT_ASC + "," + ItemTable.COLUMN_PUBDATE + DatabaseHelper.SORT_DESC); else cursorLoader = new CursorLoader(getActivity(), MyContentProvider.ITEM_CONTENT_URI, projection, ItemTable.COLUMN_FAVORITE + "=?", new String[] { Long.toString(DatabaseHelper.ON) }, ItemTable.COLUMN_READ + DatabaseHelper.SORT_ASC + "," + ItemTable.COLUMN_PUBDATE + DatabaseHelper.SORT_DESC); return cursorLoader; }
From source file:com.kobi.metalsexchange.app.ExchangeRatesFragment.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // Sort order: Descending, by date. String sortOrder = MetalsContract.MetalsRateEntry.COLUMN_DATE + " DESC"; Uri ratesByMetalUri = MetalsContract.MetalsRateEntry.buildMetalsRateWithStartDate(mMetalId, System.currentTimeMillis()); return new CursorLoader(getActivity(), ratesByMetalUri, RATES_COLUMNS, null, null, sortOrder); }
From source file:com.example.android.gcncouponalert.app.CouponsFragment.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { Log.d(LOG_TAG, "onCreateLoader"); // This is called when a new Loader needs to be created. This // fragment only uses one loader, so we don't care about checking the id. // To only show current and future dates, filter the query to return weather only for // dates after or including today. /*//from w w w .java 2 s.c o m // Sort order: Ascending, by date. String sortOrder = CouponsContract.WeatherEntry.COLUMN_DATE + " ASC"; String locationSetting = Utility.getPreferredLocation(getActivity()); Uri weatherForLocationUri = CouponsContract.WeatherEntry.buildWeatherLocationWithStartDate( locationSetting, System.currentTimeMillis()); return new CursorLoader(getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder); */ //String locationSetting = Utility.getPreferredLocation(getActivity()); String locationSetting = Utility.getPreferredLocation(getContext()); int spinner_pos = 0; if (bundle != null) { spinner_pos = bundle.getInt("spinner_pos"); } //String brand_code = "1"; Uri couponUri; if (spinner_pos == 0) { couponUri = CouponsContract.CouponEntry.buildCouponLocation(locationSetting); } else { couponUri = CouponsContract.CouponEntry.buildCouponLocationBrand(locationSetting); } Log.d(LOG_TAG, "locationSetting: " + locationSetting + "; spinner_pos: " + spinner_pos + "; couponUri:" + couponUri.toString()); return new CursorLoader(getActivity(), //getContext(), couponUri, COUPONS_COLUMNS, null, null, CouponsContract.CouponEntry.COLUMN_COUPON_SLOT_INFO); //CouponsContract.CouponEntry.COLUMN_DATE_CREATED + " DESC"); }
From source file:com.orangelabs.rcs.ri.messaging.filetransfer.FileTransferList.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { /* Create a new CursorLoader with the following query parameters. */ return new CursorLoader(this, FileTransferLog.CONTENT_URI, PROJECTION, null, null, SORT_ORDER); }
From source file:com.orangelabs.rcs.ri.messaging.chat.single.SingleChatList.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { /* Create a new CursorLoader with the following query parameters. */ return new CursorLoader(this, Message.CONTENT_URI, PROJECTION, WHERE_CLAUSE_GROUPED, null, SORT_ORDER); }
From source file:com.arcusapp.soundbox.data.MediaProvider.java
/** * Returns a list of SongEntries for the Songs in the specified directory. * // w ww . j a v a2 s .c om * @param directory the directory in which to search * @param projection one key from {@linkplain MediaStore.Audio.Media} to associate on the SongEntry's value * @return a list of SongEntries */ public List<SongEntry> getSongsInAFolder(File directory, String projection) { List<SongEntry> songs = new ArrayList<SongEntry>(); String folder = directory.getPath(); String[] cursorProjection = new String[] { MediaStore.Audio.Media._ID, projection }; String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0 AND " + "SUBSTR(" + MediaStore.Audio.Media.DATA + ",0 , LENGTH('" + folder + "')+1) = '" + folder + "' AND " + "SUBSTR(" + MediaStore.Audio.Media.DATA + ",LENGTH('" + folder + "')+1, 200) LIKE '/%.mp3' AND " + "SUBSTR(" + MediaStore.Audio.Media.DATA + ",LENGTH('" + folder + "')+1, 200) NOT LIKE '/%/%.mp3'"; String sortOrder = MediaStore.Audio.Media.TITLE; CursorLoader cl = new CursorLoader(SoundBoxApplication.getContext(), MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, cursorProjection, selection, null, sortOrder); myCursor = cl.loadInBackground(); while (myCursor.moveToNext()) { songs.add(new SongEntry(myCursor.getString(0), myCursor.getString(1))); } CursorLoader cl2 = new CursorLoader(SoundBoxApplication.getContext(), MediaStore.Audio.Media.INTERNAL_CONTENT_URI, cursorProjection, selection, null, sortOrder); myCursor = cl2.loadInBackground(); while (myCursor.moveToNext()) { songs.add(new SongEntry(myCursor.getString(0), myCursor.getString(1))); } myCursor.close(); return songs; }