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.example.linhdq.test.documents.viewing.single.TableOfContentsActivity.java
@Override public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) { final Uri documentUri = getIntent().getData(); final String selection = DocumentContentProvider.Columns.PARENT_ID + "=? OR " + DocumentContentProvider.Columns.ID + "=?"; final String[] args = new String[] { documentUri.getLastPathSegment(), documentUri.getLastPathSegment() }; return new CursorLoader(this, DocumentContentProvider.CONTENT_URI, PROJECTION, selection, args, "created ASC"); }
From source file:android.example.com.rottentomatillos.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { // When the LoaderManager initalizes the loader, this code is run. A CursorLoader is // specifically designed to load cursors from ContentProviders. return new CursorLoader(this, Movie.CONTENT_URI, null, null, null, null); }
From source file:com.dabay6.android.apps.carlog.ui.fuel.fragments.FuelHistoryListFragment.java
/** * {@inheritDoc}/*from w w w . ja v a 2s. c o m*/ */ @Override public Loader<Cursor> onCreateLoader(final int i, final Bundle bundle) { final String selection = Columns.VEHICLE_ID.getName() + " = ?"; final String[] selectionArgs; selectionArgs = (vehicleId == null) ? new String[] { "-1" } : new String[] { vehicleId.toString() }; return new CursorLoader(getActivity(), FuelHistory.CONTENT_URI, FuelHistory.PROJECTION, selection, selectionArgs, SortOrder.DEFAULT_FUEL_HISTORY_ORDER.toString()); }
From source file:com.fbartnitzek.tasteemall.filter.AttributeFilterSelectTabFragment.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;//from w w w .j a v a 2 s .co m try { json.put(mBaseEntity, new JSONObject()); uri = DatabaseContract.buildUriWithJson(json); } catch (UnsupportedEncodingException | JSONException e) { e.printStackTrace(); throw new RuntimeException("invalid json query " + json.toString()); } return new CursorLoader(getActivity(), uri, new String[] { "DISTINCT " + alias + mAttributeName }, null, null, alias + mAttributeName + " ASC"); default: throw new RuntimeException( "wrong loaderId in " + AttributeFilterSelectTabFragment.class.getSimpleName()); } }
From source file:com.android.example.wordlistloader.MainActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String queryUri = CONTENT_URI.toString(); String[] projection = new String[] { CONTENT_PATH }; return new CursorLoader(this, Uri.parse(queryUri), projection, null, null, null); }
From source file:com.enadein.carlogbook.ui.AddUpdateFuelLogActivity.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { String[] queryCols = new String[] { ProviderDescriptor.DataValue.Cols._ID, ProviderDescriptor.DataValue.Cols.NAME }; CursorLoader cursorLoader = null;//from www .j a v a 2 s . com switch (id) { case LOADER_STATION: { cursorLoader = new CursorLoader(this, ProviderDescriptor.DataValue.CONTENT_URI, queryCols, "TYPE = ?", new String[] { String.valueOf(ProviderDescriptor.DataValue.Type.STATION) }, null); break; } case LOADER_TYPE: { cursorLoader = new CursorLoader(this, ProviderDescriptor.DataValue.CONTENT_URI, queryCols, "TYPE = ?", new String[] { String.valueOf(ProviderDescriptor.DataValue.Type.FUEL) }, null); break; } } return cursorLoader; }
From source file:com.ksk.droidbatterybooster.provider.OptimalMode.java
/** * Get mode cursor loader for all modes. * // w ww . j a v a 2 s . c om * @param context to query the database. * @return cursor loader with all the optimal modes. */ public static CursorLoader getModesCursorLoader(Context context) { return new CursorLoader(context, DataProviderApi.OptimalModesColumns.CONTENT_URI, QUERY_COLUMNS, null, null, DEFAULT_SORT_ORDER); }
From source file:com.alchemiasoft.book.fragment.BookDetailFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch (id) { case ID_LOADER_BOOK: return new CursorLoader(getActivity(), BookDB.Book.create(args.getLong(ARG_BOOK_ID)), null, null, null, null);/*w w w .j a va 2s . c o m*/ default: throw new IllegalArgumentException("Id=" + id + " is not supported."); } }
From source file:com.g11x.checklistapp.ImportantInformationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_important_information); // TODO: fetch from content provider if (data == null) { data = new ArrayList<>(); data.add("one"); data.add("two"); data.add("three"); }// w ww. jav a2s. c o m final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.important_information_recycler_view); recyclerView.setHasFixedSize(true); LinearLayoutManager layoutManger = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManger); FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.fab); floatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ImportantInformationActivity.this.onFloatingActionButtonClick(); } }); final TextView emptyListInfo = (TextView) findViewById(R.id.important_information_empty); Intent intent = getIntent(); if (intent.getExtras() != null && intent.getExtras().get("title") != null) { View view = findViewById(R.id.activity_important_information); String message = String.format(getString(R.string.created_important_information_item), intent.getExtras().get("title")); Snackbar.make(view, message, Snackbar.LENGTH_LONG).show(); } getSupportLoaderManager().initLoader(0, null, new LoaderManager.LoaderCallbacks<Cursor>() { @Override public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { return new CursorLoader(ImportantInformationActivity.this, Database.ImportantInformation.CONTENT_URI, PROJECTION, null, null, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { refreshUi(cursor.getCount()); if (adapter == null) { if (cursor != null) { adapter = new Adapter(cursor); recyclerView.setAdapter(adapter); } } else { adapter.swapCursor(cursor); } } @Override public void onLoaderReset(Loader<Cursor> loader) { adapter.swapCursor(null); } private void refreshUi(int itemCount) { if (itemCount > 0) { recyclerView.setVisibility(View.VISIBLE); emptyListInfo.setVisibility(View.GONE); } else { emptyListInfo.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.GONE); } } }); }
From source file:com.odoo.news.News.java
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { return new CursorLoader(getActivity(), db().uri(), null, null, null, OColumn.ROW_ID + " desc"); }