@Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
   int id = loader.getId();
   switch (id) {
     case MyExpenses.SPLIT_PART_CURSOR:
       mAdapter.swapCursor(cursor);
   }
 }
Exemple #2
0
 @Override
 public void onLoaderReset(Loader<Cursor> arg0) {
   switch (arg0.getId()) {
     case ExpenseEdit.TRANSACTION_CURSOR:
       mAdapter.swapCursor(null);
       break;
   }
 }
 @Override
 public void onLoaderReset(Loader<Cursor> loader) {
   switch (loader.getId()) {
     case SORTABLE_CURSOR:
       mTemplatesCursor = null;
       mAdapter.swapCursor(null);
       break;
   }
 }
 /* (non-Javadoc)
  * calls {@link #convText for formatting the values retrieved from the cursor}
  * @see android.widget.SimpleCursorAdapter#setViewText(android.widget.TextView, java.lang.String)
  */
 @Override
 public void setViewText(TextView v, String text) {
   switch (v.getId()) {
     case R.id.date:
       text = Utils.convDateTime(text, itemDateFormat);
       break;
     case R.id.amount:
       text = Utils.convAmount(text, mAccount.currency);
   }
   super.setViewText(v, text);
 }
Exemple #5
0
 @Override
 public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
   switch (arg0.getId()) {
     case ExpenseEdit.TRANSACTION_CURSOR:
       mAdapter.swapCursor(c);
       if (c.getCount() > 0) ((ExpenseEdit) getActivity()).disableAccountSpinner();
       break;
     case ExpenseEdit.SUM_CURSOR:
       c.moveToFirst();
       transactionSum = c.getLong(0);
       updateBalance();
   }
 }
 @Override
 public void onLoadFinished(Loader<Cursor> arg0, Cursor data) {
   if (getArguments().getBoolean(KEY_WITH_ROOT)) {
     MatrixCursor extras = new MatrixCursor(projection);
     extras.addRow(
         new String[] {
           "0", getString(R.string.transform_subcategory_to_main),
         });
     mCursor = new MergeCursor(new Cursor[] {extras, data});
   } else {
     mCursor = data;
   }
   mAdapter.swapCursor(mCursor);
 }
 @Override
 public void onLoaderReset(Loader<Cursor> arg0) {
   switch (arg0.getId()) {
     case TRANSACTION_CURSOR:
       mTransactionsCursor = null;
       ((SimpleCursorAdapter) mAdapter).swapCursor(null);
       hasItems = false;
       break;
     case SUM_CURSOR:
       mappedCategories = false;
       break;
     case GROUPING_CURSOR:
       mGroupingCursor = null;
   }
 }
 @Override
 public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
   switch (arg0.getId()) {
     case TRANSACTION_CURSOR:
       mTransactionsCursor = c;
       hasItems = c.getCount() > 0;
       if (!indexesCalculated) {
         columnIndexYear = c.getColumnIndex(KEY_YEAR);
         columnIndexYearOfWeekStart = c.getColumnIndex(KEY_YEAR_OF_WEEK_START);
         columnIndexMonth = c.getColumnIndex(KEY_MONTH);
         columnIndexWeek = c.getColumnIndex(KEY_WEEK);
         columnIndexDay = c.getColumnIndex(KEY_DAY);
         columnIndexAmount = c.getColumnIndex(KEY_AMOUNT);
         columnIndexLabelSub = c.getColumnIndex(KEY_LABEL_SUB);
         columnIndexLabelMain = c.getColumnIndex(KEY_LABEL_MAIN);
         columnIndexComment = c.getColumnIndex(KEY_COMMENT);
         columnIndexReferenceNumber = c.getColumnIndex(KEY_REFERENCE_NUMBER);
         columnIndexPayee = c.getColumnIndex(KEY_PAYEE_NAME);
         columnIndexCrStatus = c.getColumnIndex(KEY_CR_STATUS);
         columnIndexTransferPeer = c.getColumnIndex(KEY_TRANSFER_PEER);
         indexesCalculated = true;
       }
       ((SimpleCursorAdapter) mAdapter).swapCursor(c);
       invalidateCAB();
       break;
     case SUM_CURSOR:
       c.moveToFirst();
       mappedCategories = c.getInt(c.getColumnIndex(KEY_MAPPED_CATEGORIES)) > 0;
       break;
     case GROUPING_CURSOR:
       mGroupingCursor = c;
       // if the transactionscursor has been loaded before the grouping cursor, we need to refresh
       // in order to have accurate grouping values
       if (!indexesGroupingCalculated) {
         columnIndexGroupYear = c.getColumnIndex(KEY_YEAR);
         columnIndexGroupSecond = c.getColumnIndex(KEY_SECOND_GROUP);
         columnIndexGroupSumIncome = c.getColumnIndex(KEY_SUM_INCOME);
         columnIndexGroupSumExpense = c.getColumnIndex(KEY_SUM_EXPENSES);
         columnIndexGroupSumTransfer = c.getColumnIndex(KEY_SUM_TRANSFERS);
         columnIndexGroupMappedCategories = c.getColumnIndex(KEY_MAPPED_CATEGORIES);
         columIndexGroupSumInterim = c.getColumnIndex(KEY_INTERIM_BALANCE);
         indexesGroupingCalculated = true;
       }
       if (mTransactionsCursor != null) ((BaseAdapter) mAdapter).notifyDataSetChanged();
   }
 }
 @Override
 public void onLoaderReset(Loader<Cursor> loader) {
   mAdapter.swapCursor(null);
 }
 @Override
 public void onLoaderReset(Loader<Cursor> arg0) {
   mCursor = null;
   mAdapter.swapCursor(null);
 }
 @Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
   switch (loader.getId()) {
     case SORTABLE_CURSOR:
       mTemplatesCursor = c;
       if (c != null && !indexesCalculated) {
         columnIndexRowId = c.getColumnIndex(KEY_ROWID);
         columnIndexAmount = c.getColumnIndex(KEY_AMOUNT);
         columnIndexLabelSub = c.getColumnIndex(KEY_LABEL_SUB);
         columnIndexComment = c.getColumnIndex(KEY_COMMENT);
         columnIndexPayee = c.getColumnIndex(KEY_PAYEE_NAME);
         columnIndexColor = c.getColumnIndex(KEY_COLOR);
         columnIndexTransferPeer = c.getColumnIndex(KEY_TRANSFER_PEER);
         columnIndexCurrency = c.getColumnIndex(KEY_CURRENCY);
         columnIndexTransferAccount = c.getColumnIndex(KEY_TRANSFER_ACCOUNT);
         columnIndexPlanId = c.getColumnIndex(KEY_PLANID);
         columnIndexTitle = c.getColumnIndex(KEY_TITLE);
         columnIndexPlanInfo = c.getColumnIndex(KEY_PLAN_INFO);
         indexesCalculated = true;
       }
       mAdapter.swapCursor(mTemplatesCursor);
       invalidateCAB();
       if (isCalendarPermissionGranted()
           && mTemplatesCursor != null
           && mTemplatesCursor.moveToFirst()) {
         long needToExpand =
             expandedHandled
                 ? ManageTemplates.NOT_CALLED
                 : ((ManageTemplates) getActivity()).getCalledFromCalendarWithId();
         boolean foundToExpand = false;
         while (!mTemplatesCursor.isAfterLast()) {
           long templateId = mTemplatesCursor.getLong(columnIndexRowId);
           if (needToExpand == templateId) {
             planMonthFragment =
                 PlanMonthFragment.newInstance(
                     mTemplatesCursor.getString(columnIndexTitle),
                     templateId,
                     mTemplatesCursor.getLong(columnIndexPlanId),
                     mTemplatesCursor.getInt(columnIndexColor),
                     false);
             foundToExpand = true;
           }
           mTemplatesCursor.moveToNext();
         }
         if (needToExpand != ManageTemplates.NOT_CALLED) {
           expandedHandled = true;
           if (foundToExpand) {
             planMonthFragment.show(getChildFragmentManager(), CALDROID_DIALOG_FRAGMENT_TAG);
           } else {
             Toast.makeText(
                     getActivity(), R.string.save_transaction_template_deleted, Toast.LENGTH_LONG)
                 .show();
           }
         }
         // look for plans that we could possible relink
         if (!repairTriggered && mTemplatesCursor.moveToFirst()) {
           final ArrayList<String> missingUuids = new ArrayList<>();
           while (!mTemplatesCursor.isAfterLast()) {
             if (!mTemplatesCursor.isNull(columnIndexPlanId)
                 && mTemplatesCursor.isNull(columnIndexPlanInfo)) {
               missingUuids.add(
                   mTemplatesCursor.getString(mTemplatesCursor.getColumnIndex(KEY_UUID)));
             }
             mTemplatesCursor.moveToNext();
           }
           if (missingUuids.size() > 0) {
             new RepairHandler(this)
                 .obtainMessage(0, missingUuids.toArray(new String[missingUuids.size()]))
                 .sendToTarget();
           }
         }
       }
       break;
   }
 }