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.beesham.popularmovies.DetailsFragment.java
private CursorLoader loadFromMovieFavoriteEntry() { String[] projection = new String[] { MoviesFavoriteEntry._ID, MoviesFavoriteEntry.COLUMN_MOVIE_ID, MoviesFavoriteEntry.COLUMN_MOVIE_TITLE, MoviesFavoriteEntry.COLUMN_MOVIE_SYNOPSIS, MoviesFavoriteEntry.COLUMN_MOVIE_POSTER, MoviesFavoriteEntry.COLUMN_MOVIE_RELEASE_DATE, MoviesFavoriteEntry.COLUMN_MOVIE_USER_RATING, MoviesFavoriteEntry.COLUMN_MOVIE_TRAILERS, MoviesFavoriteEntry.COLUMN_MOVIE_REVIEWS }; if (mUri != null) { String selection = MoviesFavoriteEntry.COLUMN_MOVIE_TITLE + "=?"; String[] selectionArgs = { mUri.getPathSegments().get(1) }; return new CursorLoader(getActivity(), MoviesFavoriteEntry.CONTENT_URI, projection, selection, selectionArgs, null);/*from w w w . j a v a2 s . co m*/ } return null; }
From source file:com.odoo.addons.notes.Notes.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle data) { String selection = ""; List<String> args = new ArrayList<>(); Uri uri = db().uri();// ww w.j ava 2s . co m switch (mCurrentKey) { case Notes: args.add(mStageId + ""); selection += "stage_id = ? and open = ? and trashed = ?"; args.add("true"); args.add("0"); break; case Reminders: selection += " reminder != ?"; args.add("0"); break; case Archive: selection += " open = ? and trashed = ?"; args.add("false"); args.add("0"); break; case Deleted: selection += " trashed = ?"; args.add("1"); break; case TagFilter: uri = ((NoteNote) db()).filterTag(); args.add(extra.getInt("tag_id") + ""); break; } if (mFilter != null) { selection += " and name like ?"; args.add("%" + mFilter + "%"); } String[] arguments = args.toArray(new String[args.size()]); return new CursorLoader(getActivity(), uri, null, selection, arguments, " sequence"); }
From source file:com.ant.sunshine.app.fragments.ForecastFragment.java
@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(getCurrentActivity()); Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting, System.currentTimeMillis()); return new CursorLoader(getCurrentActivity(), weatherForLocationUri, ForecastConstants.FORECAST_COLUMNS, null, null, sortOrder);/*from w ww .j a va 2 s.co m*/ }
From source file:com.murrayc.galaxyzoo.app.ClassifyFragment.java
@Nullable private Loader<Cursor> onCreateLoaderGetNextId() { final String itemId = getItemId(); if (TextUtils.isEmpty(itemId)) { return null; }//from w w w .j a v a 2 s . co m //Asynchronously get the actual ID, //because we have just asked for the "next" item. final Activity activity = getActivity(); final Uri.Builder builder = Item.CONTENT_URI.buildUpon(); builder.appendPath(itemId); showLoadingInProgress(true); return new CursorLoader(activity, builder.build(), mColumns, null, // No where clause, return all records. We already specify just one via the itemId in the URI null, // No where clause, therefore no where column values. null // Use the default sort order. ); }
From source file:com.orangelabs.rcs.ri.messaging.chat.group.GroupChatList.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { /* Create a new CursorLoader with the following query parameters. */ return new CursorLoader(this, ChatLog.GroupChat.CONTENT_URI, PROJECTION, null, null, SORT_ORDER); }
From source file:com.jimandreas.popularmovies.MovieDetailFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (null != mUri) { // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. return new CursorLoader(getActivity(), mUri, MOVIE_COLUMNS, null, null, null); }/*from w w w. j a va 2s . c om*/ /* * See Audacity Advanced Android training for more info on this * rather nice handling of visibility: * * So Much Real Estate Part 3 (solution) * https://www.youtube.com/watch?v=jkK-Uxx6dLQ * * Basically the fragment is parented to a CardView when * running on a Tablet, in Landscape or Portrait orientation. * This nulls out the simultaneous presentation of the detail view * before the info is retrieved in the cursor. */ ViewParent vp = getView().getParent(); if (vp != null && vp instanceof CardView) { ((View) vp).setVisibility(View.INVISIBLE); } return null; }
From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), SipProfile.ACCOUNT_URI, new String[] { SipProfile.FIELD_ID + " AS " + BaseColumns._ID, SipProfile.FIELD_ID, SipProfile.FIELD_DISPLAY_NAME, SipProfile.FIELD_WIZARD, SipProfile.FIELD_ACTIVE }, null, null, null);/* ww w . jav a 2 s . c o m*/ }
From source file:com.example.locationprovider.app.MainActivity.java
/** * */// w w w .j ava 2s . c om @Override public Loader onCreateLoader(int id, Bundle args) { Uri uri = MockLocationProvider.uri; return new CursorLoader(this, uri, null, null, null, null); }
From source file:br.com.mybaby.contatos.ContactDetailFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { final Uri uri = Uri.withAppendedPath(mContactUri, Contacts.Data.CONTENT_DIRECTORY); switch (id) { // Two main queries to load the required information case ContactDetailQuery.QUERY_ID: // This query loads main contact details, see // ContactDetailQuery for more information. return new CursorLoader(getActivity(), mContactUri, ContactDetailQuery.PROJECTION, null, null, null); // case ContactAddressQuery.QUERY_ID: // // This query loads contact address details, see // // ContactAddressQuery for more information. // return new CursorLoader(getActivity(), uri, // ContactAddressQuery.PROJECTION, // ContactAddressQuery.SELECTION, // null, null); case ContactPhoneQuery.QUERY_ID: return new CursorLoader(getActivity(), uri, ContactPhoneQuery.PROJECTION, ContactPhoneQuery.SELECTION, null, null);//from w w w . j a v a2s .com } return null; }
From source file:com.glandorf1.joe.wsprnetviewer.app.WsprFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // 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. // TODO: Filter the query to only return data from today and the previous N days. // Calendar cal = Calendar.getInstance(); // cal.setTime(new Date()); // cal.add(Calendar.DATE, -7); // N= 7 // Date cutoffDate = cal.getTime(); // String startTimestamp = WsprNetContract.getDbTimestampString(cutoffDate); // Sort order: Descending, by timestamp. String sortOrder = WsprNetContract.SignalReportEntry.COLUMN_TIMESTAMPTEXT + " DESC"; String txCall = Utility.getFilterCallsign(getActivity(), true), rxCall = Utility.getFilterCallsign(getActivity(), false); String txGridsquare = Utility.getFilterGridsquare(getActivity(), true), rxGridsquare = Utility.getFilterGridsquare(getActivity(), false); txCall = Utility.filterCleanupForSQL(txCall); rxCall = Utility.filterCleanupForSQL(rxCall); txGridsquare = Utility.filterCleanupForSQL(txGridsquare); rxGridsquare = Utility.filterCleanupForSQL(rxGridsquare); mSelection = ""; if (Utility.isFiltered(getActivity())) { // When adding filters, be sure to update onResume(), and save the preference value below, too. String prefAndOr = Utility.isFilterAnd(getActivity()) ? " and " : " or "; String sAndOr = " "; if (txCall.length() > 0) { sAndOr = (mSelection.length() > 0) ? prefAndOr : ""; mSelection += sAndOr + "(" + WsprNetContract.SignalReportEntry.COLUMN_TX_CALLSIGN + " like '" + txCall + "')"; }/*from w w w . j av a 2 s . com*/ if (rxCall.length() > 0) { sAndOr = (mSelection.length() > 0) ? prefAndOr : ""; mSelection += sAndOr + "(" + WsprNetContract.SignalReportEntry.COLUMN_RX_CALLSIGN + " like '" + rxCall + "')"; } if (txGridsquare.length() > 0) { sAndOr = (mSelection.length() > 0) ? prefAndOr : ""; mSelection += sAndOr + "(" + WsprNetContract.SignalReportEntry.COLUMN_TX_GRIDSQUARE + " like '" + txGridsquare + "')"; } if (rxGridsquare.length() > 0) { sAndOr = (mSelection.length() > 0) ? prefAndOr : ""; mSelection += sAndOr + "(" + WsprNetContract.SignalReportEntry.COLUMN_RX_GRIDSQUARE + " like '" + rxGridsquare + "')"; } // Examples of resulting 'selection' clause: // tx_callsign like 'D%' // (tx_gridsquare like 'D%') and (rx_callsign like 'N%') // (tx_gridsquare like 'D%') or (rx_callsign like 'N%') if (mSelection.length() > 0) { // Remind user that items are filtered, in case the result is not what they expect. Toast.makeText(getActivity(), getActivity().getString(R.string.toast_filter_items), Toast.LENGTH_LONG).show(); } } int mainDisplayPreference = Utility.getMainDisplayPreference(getActivity()); if (mWsprAdapter.mainDisplayFormat != mainDisplayPreference) { // Update the gridsquare/callsign heading text based on the display layout. switch (mainDisplayPreference) { case Utility.MAIN_DISPLAY_CALLSIGN: // fit everything into 2 lines of display mTVGridCallHeader.setText(getActivity().getString(R.string.callsign)); mTVGridCallHeader.setTextColor(getResources().getColor(R.color.wspr_brown)); break; case Utility.MAIN_DISPLAY_GRIDCALL: // fit everything into 4 lines of display String g = getActivity().getString(R.string.grid); String c = getActivity().getString(R.string.call); Spannable s = new SpannableString(g + "/" + c); // In "Grid/Call", make "grid" black, "Call" brown, and "/" somewhere between. // Release: For "Grid", set the span to be 1 extra character. s.setSpan(new ForegroundColorSpan(Color.BLACK), 0, g.length() + 0, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Debug: For the "/", set the span to be 2 characters; it will won't display in the color if the span is only 1 character. s.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.wspr_brown2)), g.length() + 0, g.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); s.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.wspr_brown)), g.length() + 1, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mTVGridCallHeader.setText(s); break; case Utility.MAIN_DISPLAY_GRIDSQUARE: // fit everything into 2 lines of display default: mTVGridCallHeader.setText(getActivity().getString(R.string.gridsquare)); mTVGridCallHeader.setTextColor(Color.BLACK); } } // Save some of the preferences to detect if they've changed in onResume(). mGridsquare = Utility.getPreferredGridsquare(getActivity()); mWsprAdapter.mainDisplayFormat = mainDisplayPreference; mFilterTxCallsign = Utility.getFilterCallsign(getActivity(), true); mFilterRxCallsign = Utility.getFilterCallsign(getActivity(), false); mFilterTxGridsquare = Utility.getFilterGridsquare(getActivity(), true); mFilterRxGridsquare = Utility.getFilterGridsquare(getActivity(), false); mFilterAnd = Utility.isFilterAnd(getActivity()); mFiltered = Utility.isFiltered(getActivity()); Uri wsprUri; wsprUri = WsprNetContract.SignalReportEntry.buildWspr(); // Create and return a CursorLoader that will take care of creating a Cursor for the data being displayed. return new CursorLoader(getActivity(), // context wsprUri, // URI WSPR_COLUMNS, // String[] projection mSelection, // String selection null, // String[] selectionArgs sortOrder // String sortOrder ); }