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.jpventura.alexandria.AddBook.java
@Override public android.support.v4.content.Loader<Cursor> onCreateLoader(int id, Bundle args) { if (ean.getText().length() == 0) { return null; }//ww w .j ava2 s . c o m String eanStr = ean.getText().toString(); if (eanStr.length() == 10 && !eanStr.startsWith("978")) { eanStr = "978" + eanStr; } return new CursorLoader(getActivity(), AlexandriaContract.BookEntry.buildFullBookUri(Long.parseLong(eanStr)), null, null, null, null); }
From source file:com.fbartnitzek.tasteemall.filter.AttributeFilterTextTabFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case ATTRIBUTE_VALUES_LOADER_ID: String alias = DatabaseContract.ALIASES.get(mBaseEntity) + "."; JSONObject json = new JSONObject(); Uri uri;//www.j ava 2 s . c om try { json.put(mBaseEntity, new JSONObject().put(mAttributeName, new JSONObject().put( DatabaseContract.Operations.CONTAINS, DatabaseContract.encodeValue(mAttributeFilter)))); uri = DatabaseContract.buildUriWithJson(json); } catch (UnsupportedEncodingException | JSONException e) { e.printStackTrace(); throw new RuntimeException("invalid json query " + json.toString()); } // Log.v(LOG_TAG, "onCreateLoader, hashCode=" + this.hashCode() + ", uri=" + uri +"]"); return new CursorLoader(getActivity(), uri, new String[] { "DISTINCT " + alias + mAttributeName }, null, null, alias + mAttributeName + " ASC"); default: throw new RuntimeException("wrong loaderId in " + AttributeFilterTextTabFragment.class.getSimpleName()); } }
From source file:com.kyakujin.android.autoeco.ui.BatteryFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle arg) { switch (id) { case BatteryQuery.LOADER_ID: return new CursorLoader(getActivity(), Uri.withAppendedPath(BatteryTbl.CONTENT_URI, String.valueOf(mCurrentBatteryId)), BatteryQuery.PROJECTION, null, null, null); default:/*from w ww .j av a 2s .c om*/ break; } return null; }
From source file:com.example.puter.sunshine.app.DetailFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { if (null != mUri) { return new CursorLoader(getActivity(), mUri, DETAIL_COLUMNS, null, null, null); }//w ww . j a va2 s . c om return null; }
From source file:com.example.android.ennis.barrett.popularmovies.MainFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { Log.v(TAG, "onCreateLoader executed"); switch (id) { case 0:/*from w w w .j a v a 2 s. c o m*/ String whereClause = null; String[] whereArgs = null; if (args != null) { whereClause = args.getString(LOADER_BUNDLE_KEY) + " = ?"; whereArgs = new String[] { "1" }; } return new CursorLoader(getActivity(), TMDbContract.Movies.URI, null, // projection (col to return) whereClause, // where clause whereArgs, // where args (values to insert in the ?) null); // Sort order default: Log.v(TAG, "onCreateLoader , default case chosen"); return null; } }
From source file:com.damianhinch.sunshine.ForecastFragment.java
@Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { String locationSetting = Helpers.getUserPreferredLocation(getActivity()); // Sort order: Ascending, by date. String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC"; Uri weatherForLocationUri = WeatherContract.WeatherEntry.buildWeatherLocationWithStartDate(locationSetting, System.currentTimeMillis()); return new CursorLoader(getActivity(), weatherForLocationUri, FORECAST_COLUMNS, null, null, sortOrder); }
From source file:com.airg.android.permission.sample.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(final int id, final Bundle args) { if (CONTACTS_LOADER != id) throw new IllegalArgumentException("Unknown loader id: " + id); return new CursorLoader(this, ContactsContract.Contacts.CONTENT_URI, new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }, null, null, ContactsContract.Contacts.DISPLAY_NAME + " ASC"); }
From source file:com.appjma.appdeployer.AppsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case LOADER_APPS: return new CursorLoader(getActivity(), AppContract.Apps.CONTENT_URI, AppsAdapter.PROJECTION, AppContract.Apps.DELETED + " == 0", null, AppContract.Apps.UPDATED_AT); default:/*from ww w.ja v a 2s. com*/ throw new RuntimeException("Unknown laoder id: " + id); } }
From source file:com.conferenceengineer.android.iosched.ui.AnnouncementsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), ScheduleContract.Announcements.CONTENT_URI, AnnouncementsQuery.PROJECTION, null, null, ScheduleContract.Announcements.DEFAULT_SORT); }
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If the activity was started with the "create shortcut" action, we // remember this to change the behavior upon a search. if (Intent.ACTION_CREATE_SHORTCUT.equals(getActivity().getIntent().getAction())) { mCreateShortcut = true;//ww w . java 2 s . com } if (savedInstanceState != null) { mStackLevel = savedInstanceState.getInt("level"); } CursorLoader cursorLoader = new CursorLoader(getActivity(), Journeys.CONTENT_URI, PROJECTION, null, //selection, null, //selectionArgs, Journeys.HISTORY_SORT_ORDER); Cursor cursor = cursorLoader.loadInBackground(); mAdapter = new JourneyAdapter(getActivity(), cursor); }