Esempio n. 1
0
  @Override
  public void onLoadFinished(android.support.v4.content.Loader<Cursor> loader, Cursor cursor) {
    mAdapter.changeCursor(cursor);
    mRecyclerView.getLayoutManager().scrollToPosition(0);

    mEmptyView.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.insert_first_item));
    if (mAdapter.getItemCount() != 0) mEmptyView.clearAnimation();
  }
Esempio n. 2
0
  /**
   * When the delete checked label icon in the toolbar is checked this method is called to removed
   * the checked items.
   *
   * @param context Parent Activity used to get a Content Resolver.
   */
  public void deleteItems(Context context) {
    ArrayList<ContentProviderOperation> operations = new ArrayList<>();
    ContentProviderOperation operation;

    Set<Long> deleteSet = mAdapter.getSelectedRows();

    for (long id : deleteSet) {
      String[] selectionArgs = new String[] {String.valueOf(id)};
      operation =
          ContentProviderOperation.newDelete(MSLContentProvider.CONTENT_URI)
              .withSelection(MSLTable.COLUMN_ID + " = ?", selectionArgs)
              .build();
      operations.add(operation);
    }

    try {
      context.getContentResolver().applyBatch(MSLContentProvider.AUTHORITY, operations);
    } catch (RemoteException | OperationApplicationException ignored) {
    }

    mAdapter.setSelectedRows(new LinkedHashSet<Long>());
  }
Esempio n. 3
0
 @Override
 public void onLoaderReset(android.support.v4.content.Loader<Cursor> loader) {
   mAdapter.changeCursor(null);
 }