@Override
  public Loader<Cursor> onCreateLoader(int id, Bundle bundle) {
    switch (id) {
      case LOADER_PARENT_CATEGORY:
        {
          Uri uri = CategoriesProvider.uriCategory(parentId);
          String[] projection = new String[] {Tables.Categories.TITLE, Tables.Categories.LEVEL};

          return new CursorLoader(getActivity(), uri, projection, null, null, null);
        }

      case LOADER_TRANSACTIONS:
        {
          Uri uri = TransactionsProvider.uriTransactions();
          String[] projection =
              new String[] {
                "max(" + Tables.Transactions.DATE + ")",
                "count(" + Tables.Transactions.T_ID + ")",
                "avg("
                    + Tables.Transactions.AMOUNT
                    + " * case "
                    + Tables.Categories.CategoriesChild.T_TYPE
                    + " when "
                    + Tables.Categories.Type.EXPENSE
                    + " then "
                    + Tables.Currencies.CurrencyFrom.T_EXCHANGE_RATE
                    + " else "
                    + Tables.Currencies.CurrencyTo.T_EXCHANGE_RATE
                    + " end)"
              };
          String selection =
              Tables.Transactions.CATEGORY_ID
                  + "=? and "
                  + Tables.Transactions.STATE
                  + "=? and "
                  + Tables.Transactions.DELETE_STATE
                  + "=? and "
                  + Tables.Transactions.SHOW_IN_TOTALS
                  + "=?";
          String[] selectionArgs =
              new String[] {
                String.valueOf(itemId),
                String.valueOf(Tables.Transactions.State.CONFIRMED),
                String.valueOf(Tables.DeleteState.NONE),
                "1"
              };

          return new CursorLoader(getActivity(), uri, projection, selection, selectionArgs, null);
        }
    }
    return super.onCreateLoader(id, bundle);
  }
  @Override
  protected Loader<Cursor> createItemLoader(Context context, long itemId) {
    Uri uri = CategoriesProvider.uriCategory(itemId);
    String[] projection =
        new String[] {
          Tables.Categories.PARENT_ID,
          Tables.Categories.TITLE,
          Tables.Categories.COLOR,
          Tables.Categories.TYPE,
          Tables.Categories.LEVEL
        };

    return new CursorLoader(getActivity(), uri, projection, null, null, null);
  }
 @Override
 protected boolean onDeleteItem(Context context, long[] itemIds) {
   API.deleteItems(CategoriesProvider.uriCategories(), itemIds);
   return true;
 }