@Override
 public Loader<Cursor> onCreateLoader(int id, Bundle arg1) {
   if (getActivity() == null) {
     return null;
   }
   switch (id) {
     case MyExpenses.SPLIT_PART_CURSOR:
       CursorLoader cursorLoader =
           new CursorLoader(
               getActivity(),
               TransactionProvider.TRANSACTIONS_URI,
               null,
               "parent_id = ?",
               new String[] {String.valueOf(mTransaction.getId())},
               null);
       return cursorLoader;
   }
   return null;
 }
 @Override
 public void onClick(DialogInterface dialog, int which) {
   MyExpenses ctx = (MyExpenses) getActivity();
   if (ctx != null && which == AlertDialog.BUTTON_POSITIVE) {
     if (mTransaction.transfer_peer != null && DbUtils.hasParent(mTransaction.transfer_peer)) {
       Toast.makeText(
               getActivity(),
               getString(R.string.warning_splitpartcategory_context),
               Toast.LENGTH_LONG)
           .show();
       return;
     }
     Intent i = new Intent(ctx, ExpenseEdit.class);
     i.putExtra(KEY_ROWID, mTransaction.getId());
     i.putExtra(DatabaseConstants.KEY_TRANSFER_ENABLED, ctx.transferEnabled());
     // i.putExtra("operationType", operationType);
     ctx.startActivityForResult(i, MyExpenses.EDIT_TRANSACTION_REQUEST);
   } else {
     this.dismiss();
   }
 }
Esempio n. 3
0
 public void testAccount() throws RemoteException, OperationApplicationException {
   Account account, restored = null;
   Long openingBalance = (long) 100;
   account = new Account("TestAccount", openingBalance, "Testing with Junit");
   account.setCurrency("EUR");
   assertEquals("EUR", account.currency.getCurrencyCode());
   account.save();
   assertTrue(account.getId() > 0);
   restored = Account.getInstanceFromDb(account.getId());
   assertEquals(account, restored);
   Long trAmount = (long) 100;
   Transaction op1 = Transaction.getNewInstance(account.getId());
   op1.setAmount(new Money(account.currency, trAmount));
   op1.comment = "test transaction";
   op1.save();
   assertEquals(account.getTotalBalance().getAmountMinor().longValue(), openingBalance + trAmount);
   Account.delete(account.getId());
   assertNull(
       "Account deleted, but can still be retrieved", Account.getInstanceFromDb(account.getId()));
   assertNull(
       "Account delete should delete transaction, but operation can still be retrieved",
       Transaction.getInstanceFromDb(op1.getId()));
 }