@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projectionFields = new String[]{ ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_URI }; CursorLoader cursorLoader = new CursorLoader(MainActivity.this, ContactsContract.Contacts.CONTENT_URI, projectionFields, null, null, null); return cursorLoader; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri uri; switch (id) { case LOADER_CAN_UPDATE: uri = AppProvider.getCanUpdateUri(); break; case LOADER_KNOWN_VULN: uri = AppProvider.getInstalledWithKnownVulnsUri(); break; default: throw new IllegalStateException("Unknown loader requested: " + id); } return new CursorLoader( activity, uri, Schema.AppMetadataTable.Cols.ALL, null, null, Schema.AppMetadataTable.Cols.NAME); }
@Override public CursorLoader onCreateLoader(int id, Bundle args) { Uri uri; if (TextUtils.isEmpty(currentFilterString)) { uri = InstalledAppProvider.getContentUri(); } else { uri = InstalledAppProvider.getSearchUri(currentFilterString); } return new CursorLoader( getActivity(), uri, InstalledAppTable.Cols.ALL, null, null, InstalledAppTable.Cols.APPLICATION_LABEL); }
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { //checking on rotate if (mAttachedFragment != null && mAttachedFragment.getActivity() != null) { if (favflag == 0) { return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.MyNews.CONTENT_URI, null, null, null, null); } else { if (favflag == 1) { return new CursorLoader(mAttachedFragment.getActivity(), NewsProvider.NewsFavourite.CONTENT_URI_FAVOURITE, null, null, null, null); } } } return null; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String selection = ""; if (mOnlyWithPhoneNumbers) { selection = ContactsContract.Contacts.HAS_PHONE_NUMBER; } switch (id) { case CONTACTS_LOADER_ID: return new CursorLoader(this, CONTACTS_URI, CONTACTS_PROJECTION, selection, null, CONTACTS_SORT); case CONTACT_DETAILS_LOADER_ID: return new CursorLoader(this, CONTACT_DETAILS_URI, CONTACT_DETAILS_PROJECTION, selection, null, null); case GROUPS_LOADER_ID: return new CursorLoader(this, GROUPS_URI, GROUPS_PROJECTION, GROUPS_SELECTION, null, GROUPS_SORT); } return null; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader loader = new CursorLoader(getContext()); loader.setUri(ChuckContentProvider.TRANSACTION_URI); if (!TextUtils.isEmpty(currentFilter)) { if (TextUtils.isDigitsOnly(currentFilter)) { loader.setSelection("responseCode LIKE ?"); loader.setSelectionArgs(new String[]{ currentFilter + "%" }); } else { loader.setSelection("path LIKE ?"); loader.setSelectionArgs(new String[]{ "%" + currentFilter + "%" }); } } loader.setProjection(HttpTransaction.PARTIAL_PROJECTION); loader.setSortOrder("requestDate DESC"); return loader; }
private static String getRealPathBelowVersion(Context context, Uri uri) { String filePath = null; LogUtils.i(TAG, "method -> getRealPathBelowVersion " + uri + " path:" + uri.getPath() + " getAuthority:" + uri.getAuthority()); String[] projection = {MediaStore.Images.Media.DATA}; CursorLoader loader = new CursorLoader(context, uri, projection, null, null, null); Cursor cursor = loader.loadInBackground(); if (cursor != null) { cursor.moveToFirst(); filePath = cursor.getString(cursor.getColumnIndex(projection[0])); cursor.close(); } if (filePath == null) { filePath = uri.getPath(); } return filePath; }
/** * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor. * * @param loaderId The loader ID for which we need to create a loader * @param loaderArgs Any arguments supplied by the caller * * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) { switch (loaderId) { case ID_DETAIL_LOADER: return new CursorLoader(this, mUri, WEATHER_DETAIL_PROJECTION, null, null, null); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
@SuppressLint("NewApi") public static String getRealPathFromURI_API11to18(Context context, Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; String result = null; try { CursorLoader cursorLoader = new CursorLoader(context, contentUri, proj, null, null, null); Cursor cursor = cursorLoader.loadInBackground(); if (cursor != null) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); result = cursor.getString(column_index); } } catch (Exception e){ e.printStackTrace(); } return result; }
@Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
public static CursorLoader newInstance(Context context, Album album, boolean capture) { if (album.isAll()) { return new AlbumMediaLoader( context, QUERY_URI, PROJECTION, SELECTION_ALL, SELECTION_ALL_ARGS, ORDER_BY, capture); } else { return new AlbumMediaLoader( context, QUERY_URI, PROJECTION, SELECTION_ALBUM, getSelectionAlbumArgs(album.getId()), ORDER_BY, false); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = { PlantEntry._ID, PlantEntry.COLUMN_NAME, PlantEntry.COLUMN_PRICE, PlantEntry.COLUMN_CART_QUANTITY }; String selection = PlantEntry.COLUMN_CART_QUANTITY + " > 0"; return new CursorLoader(this, PlantEntry.CONTENT_URI, projection, selection, null, null); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] projection = { PlantEntry._ID, PlantEntry.COLUMN_NAME, PlantEntry.COLUMN_DESCRIPTION, PlantEntry.COLUMN_PRICE }; String selection = PlantEntry._ID + " = " + mItemId; return new CursorLoader(this, PlantEntry.CONTENT_URI, projection, selection, null, null); }
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { // 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. // Sort order: Ascending, by date. String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; String locationSetting = Utility.getPreferredLocation(getActivity()); Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate( locationSetting, System.currentTimeMillis()); return new CursorLoader(getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id == CHANNELS_LOADER) { return new CursorLoader( getActivity(), ChannelEntry.CONTENT_URI, CHANNEL_COLUMNS, TextUtils.isEmpty(category) ? null : ChannelEntry.TABLE_NAME + "." + ChannelEntry.COLUMN_CHANNEL_CATEGORY_ID + " = ?", TextUtils.isEmpty(category) ? null : new String[]{String.valueOf(category)}, Utility.getPrefSortChannelOrder(sortBy)); } return null; }
public static CursorLoader create(Context context, int id, Bundle bundle) { LocalFileLoader loader = null; switch (id){ case ALL_BOOK_FILE: loader = new LocalFileLoader(context); break; default: loader = null; break; } if (loader != null) { return loader; } throw new IllegalArgumentException("The id of Loader is invalid!"); }
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { final Uri contentUri = CallLog.Calls.CONTENT_URI.buildUpon() .appendQueryParameter("limit", "100") .build(); final String[] projection = { CallLog.Calls._ID, CallLog.Calls.CACHED_NAME, CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.DURATION, CallLog.Calls.TYPE }; final String sortOrder = CallLog.Calls.DEFAULT_SORT_ORDER; return new CursorLoader(this, contentUri, projection, null, null, sortOrder); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. return new CursorLoader(this, ActivityDiaryContract.DiaryImage.CONTENT_URI, PROJECTION_IMG, ActivityDiaryContract.DiaryImage.TABLE_NAME + "." + ActivityDiaryContract.DiaryImage.DIARY_ID + "=? AND " + ActivityDiaryContract.DiaryImage._DELETED + "=0", mCurrentDiaryUri == null ? new String[]{"0"}:new String[]{mCurrentDiaryUri.getLastPathSegment()}, ActivityDiaryContract.DiaryImage.SORT_ORDER_DEFAULT); }
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { switch (id) { case LOG_REQUEST_ID: { return new CursorLoader(getActivity(), mLogSession.getSessionEntriesUri(), LOG_PROJECTION, null, null, LogContract.Log.TIME); } } return null; }
public String getRealPathFromURI(Uri contentUri) { String[] proj = {MediaStore.Images.Media.DATA}; CursorLoader loader = new CursorLoader(getActivity(), contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); if (cursor != null && cursor.moveToFirst()) { int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); String result = cursor.getString(column_index); cursor.close(); return result; } return null; }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { CursorLoader cursorLoader = new CursorLoader(CollectionActivity.this, CanvasDownloadTable.CONTENT_URI, // URI null, // projection fields null, // the selection criteria null, // the selection args null // the sort order ); return cursorLoader; }
/** * Carregar o cursor conforme a hora inicial, final e {@link FilterWatts} */ @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { iOhaEnergyUseLogHelper.onBeginLoader(); String selections; String[] selectionsArgs; switch (this.filterWatts) { case PHASE1: case PHASE2: case PHASE3: case TOTAL: selections = String.format("(%s BETWEEN ? AND ?) AND (%s BETWEEN ? AND ?)", EnergyUseLogEntry._ID, this.filterWatts.getFieldName()); selectionsArgs = new String[]{Long.toString(this.beginDateTime), Long.toString(this.endDateTime), Double.toString(this.beginWatts), Double.toString(this.endWatts)}; break; case NONE: default: selections = String.format("%s BETWEEN ? AND ?", EnergyUseLogEntry._ID); selectionsArgs = new String[]{Long.toString(this.beginDateTime), Long.toString(this.endDateTime)}; break; } return new CursorLoader( this.iOhaEnergyUseLogHelper.getContext(), CONTENT_URI_LOG, LOG_COLUMNS, selections, selectionsArgs, String.format("%s ASC", EnergyUseLogEntry._ID) ); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { this.swipeRefreshLayout.setRefreshing(true); if (id == R.id.nav_energy_use_day) { //Carregar o cursor com o a utilização de energia por dia. return new CursorLoader( this, OhaEnergyUseContract.getUriDays(new Date()), null, null, null, String.format("%s DESC", EnergyUseLogEntry._ID) ); } else if (id == R.id.nav_energy_use_bill) { //Carregar o cursor com o a utilização de energia por conta. return new CursorLoader( this, CONTENT_URI_BILL, null, null, null, String.format("%s DESC", EnergyUseBillEntry.COLUMN_FROM)); } return null; }
/** * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be * created. This Activity only uses one loader, so we don't necessarily NEED to check the * loaderId, but this is certainly best practice. * * @param loaderId The loader ID for which we need to create a loader * @param bundle Any arguments supplied by the caller * @return A new Loader instance that is ready to start loading. */ @Override public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) { switch (loaderId) { case ID_FORECAST_LOADER: /* URI for all rows of weather data in our weather table */ Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI; /* Sort order: Ascending by date */ String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; /* * A SELECTION in SQL declares which rows you'd like to return. In our case, we * want all weather data from today onwards that is stored in our weather table. * We created a handy method to do that in our WeatherEntry class. */ String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards(); return new CursorLoader(this, forecastQueryUri, MAIN_FORECAST_PROJECTION, selection, null, sortOrder); default: throw new RuntimeException("Loader Not Implemented: " + loaderId); } }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id != URL_LOAD_LOCAL_MUSIC) return null; return new CursorLoader( mView.getContext(), MEDIA_URI, PROJECTIONS, WHERE, null, ORDER_BY ); }
public static CursorLoader newInstance(Context context, Album album, boolean capture) { String selection; String[] selectionArgs; boolean enableCapture; if (album.isAll()) { if (SelectionSpec.getInstance().onlyShowImages()) { selection = SELECTION_ALL_FOR_SINGLE_MEDIA_TYPE; selectionArgs = getSelectionArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE); } else if (SelectionSpec.getInstance().onlyShowVideos()) { selection = SELECTION_ALL_FOR_SINGLE_MEDIA_TYPE; selectionArgs = getSelectionArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO); } else { selection = SELECTION_ALL; selectionArgs = SELECTION_ALL_ARGS; } enableCapture = capture; } else { if (SelectionSpec.getInstance().onlyShowImages()) { selection = SELECTION_ALBUM_FOR_SINGLE_MEDIA_TYPE; selectionArgs = getSelectionAlbumArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE, album.getId()); } else if (SelectionSpec.getInstance().onlyShowVideos()) { selection = SELECTION_ALBUM_FOR_SINGLE_MEDIA_TYPE; selectionArgs = getSelectionAlbumArgsForSingleMediaType(MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO, album.getId()); } else { selection = SELECTION_ALBUM; selectionArgs = getSelectionAlbumArgs(album.getId()); } enableCapture = false; } return new AlbumMediaLoader(context, selection, selectionArgs, enableCapture); }
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (id != LOADER_ID) { return null; } return new CursorLoader( activity, CategoryProvider.getAllCategories(), Schema.CategoryTable.Cols.ALL, null, null, null ); }