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.google.android.apps.gutenberg.TimelineFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Activity activity = getActivity();/*ww w .jav a 2 s .c om*/ String eventId = args.getString(ARG_EVENT_ID); if (TextUtils.isEmpty(eventId)) { return null; } switch (id) { case LOADER_ATTENDEES: return new CursorLoader(activity, Table.ATTENDEE.getBaseUri(), Checkin.PROJECTION, Table.Attendee.EVENT_ID + " = ? AND " + Table.Attendee.CHECKIN + " IS NOT NULL", new String[] { eventId }, null); case LOADER_EVENT: return new CursorLoader(activity, Table.EVENT.getItemUri(eventId), new String[] { Table.Event.NAME }, null, null, null); } return null; }
From source file:com.marvin.rocklock.PlaylistUtils.java
/** * Adds a given song to an existing playlist * * @param context the managing activity//from w w w . j a v a 2 s.c o m * @param id the song id to add */ public static void showPlaylistDialog(final RockLockActivity context, final String id) { // Get list of playlists String[] proj = { MediaStore.Audio.Playlists._ID, MediaStore.Audio.Playlists.NAME }; CursorLoader loader = new CursorLoader(context, MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, proj, null, null, null); final Cursor playlistCursor = loader.loadInBackground(); // Show playlists AlertDialog.Builder builder = new AlertDialog.Builder(context); if (playlistCursor.moveToFirst()) { DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { addToPlaylist(context, playlistCursor.getInt(0), id); } }; builder.setCursor(playlistCursor, clickListener, MediaStore.Audio.Playlists.NAME); } else { // No playlists: show create dialog builder.setTitle(context.getString(R.string.new_playlist)); // TODO(sainsley): add default name based on // number of playlists in directory builder.setMessage(context.getString(R.string.enter_playlist_name)); final EditText input = new EditText(context); builder.setView(input); builder.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { String name = input.getText().toString(); ArrayList<String> ids = new ArrayList<String>(); ids.add(id); writePlaylist(context, name, ids); return; } }); } builder.show(); }
From source file:com.example.geronimo.sunshine.app.ForecastFragment.java
public Loader<Cursor> onCreateLoader(int id, Bundle args) { Uri weatherUri = WeatherContract.WeatherEntry.CONTENT_URI; String locationSetting = Utility.getPreferredLocation(getActivity()); // Sort order: Ascending, by date. String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting, System.currentTimeMillis()); cur = getActivity().getContentResolver().query(weatherForLocationUri, null, null, null, sortOrder); return new CursorLoader(getActivity(), weatherForLocationUri, null, null, null, sortOrder); }
From source file:com.dmitrymalkovich.android.githubanalytics.data.source.local.LoaderProvider.java
public Loader<Cursor> createRepositoryLoader() { return new CursorLoader(mContext, RepositoryContract.RepositoryEntry.CONTENT_URI, RepositoryContract.RepositoryEntry.REPOSITORY_COLUMNS, null, null, RepositoryContract.RepositoryEntry.COLUMN_REPOSITORY_NAME + " ASC"); }
From source file:barqsoft.footballscores.ScoresFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), ScoresContract.ScoreEntry.buildMatchesByDateUri(String.valueOf(mTimeDate)), MATCHES_COLUMNS, null, null, null);// w ww . j av a 2 s .c o m }
From source file:com.krysanify.mobile.trackerjacker.DailyMapActivity.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { Uri baseUri;/*from w w w . j a v a 2 s .co m*/ baseUri = TrackData.CONTENT_URI; // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. return new CursorLoader(getApplicationContext(), baseUri, TRACKER_SUMMARY_PROJECTION, null, null, null); }
From source file:com.example.ami1.CheckActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final String account = args.getString("account"); final Uri labelsUri = GmailContract.Labels.getLabelsUri(account); return new CursorLoader(this, labelsUri, null, null, null, null); }
From source file:com.gelakinetic.mtgfam.helpers.AutocompleteCursorAdapter.java
/** * Instantiate and return a new Loader for the given ID. * * @param id 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. *///from ww w . ja v a 2 s. c o m @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. */ String select = "(" + CardDbAdapter.KEY_NAME + ")"; return new CursorLoader(mFragment.getActivity(), SEARCH_URI, CARD_NAME_PROJECTION, select, mAutocompleteFilter, CardDbAdapter.KEY_NAME + " COLLATE LOCALIZED ASC"); }
From source file:com.commonsware.android.arXiv.FavouritesListFragment.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { return new CursorLoader(getActivity(), Feeds.CONTENT_URI, null, null, null, null); }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case ID_LOADER_USER_NAME: return new CursorLoader(getActivity(), infoTable.getUri(), new String[] { infoTable.INFONAME, infoTable.INFOVALUE }, null, null, null); case ID_LOADER_ACCOUNT_BILLS: setListViewAccountBillsVisible(false); // compose whereClause String where = ""; // check if show only open accounts if (application.getAccountsOpenVisible()) { where = "LOWER(STATUS)='open'"; }/* w ww . j av a 2 s . c o m*/ // check if show fav accounts if (application.getAccountFavoriteVisible()) { where = "LOWER(FAVORITEACCT)='true'"; } return new CursorLoader(getActivity(), accountBills.getUri(), accountBills.getAllColumns(), where, null, "upper(" + accountBills.ACCOUNTNAME + ")"); case ID_LOADER_BILL_DEPOSITS: QueryBillDeposits billDeposits = new QueryBillDeposits(getActivity()); return new CursorLoader(getActivity(), billDeposits.getUri(), null, QueryBillDeposits.DAYSLEFT + "<=0", null, null); case ID_LOADER_INCOME_EXPENSES: QueryReportIncomeVsExpenses report = new QueryReportIncomeVsExpenses(getActivity()); return new CursorLoader(getActivity(), report.getUri(), report.getAllColumns(), QueryReportIncomeVsExpenses.Month + "=" + Integer.toString(Calendar.getInstance().get(Calendar.MONTH) + 1) + " AND " + QueryReportIncomeVsExpenses.Year + "=" + Integer.toString(Calendar.getInstance().get(Calendar.YEAR)), null, null); default: return null; } }