コード例 #1
0
 public static Spinner configureCurrencySpinner(
     View view, Context context, AdapterView.OnItemSelectedListener listener) {
   Spinner spinner = (Spinner) view.findViewById(R.id.Currency);
   ArrayAdapter<Account.CurrencyEnum> curAdapter =
       new ArrayAdapter<Account.CurrencyEnum>(
           context,
           android.R.layout.simple_spinner_item,
           android.R.id.text1,
           Account.CurrencyEnum.values());
   curAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   spinner.setAdapter(curAdapter);
   spinner.setOnItemSelectedListener(listener);
   spinner.setSelection(
       Account.CurrencyEnum.valueOf(Account.getLocaleCurrency().getCurrencyCode()).ordinal());
   return spinner;
 }
コード例 #2
0
 public void testGetAggregateAccountFromDb() {
   insertData();
   Account.clear();
   String currency = Account.getLocaleCurrency().getCurrencyCode();
   Cursor c =
       getMockContentResolver()
           .query(
               TransactionProvider.CURRENCIES_URI,
               new String[] {KEY_ROWID},
               KEY_CODE + " = ?",
               new String[] {currency},
               null);
   c.moveToFirst();
   long id = 0 - c.getLong(0);
   c.close();
   AggregateAccount aa = (AggregateAccount) Account.getInstanceFromDb(id);
   assertEquals(currency, aa.currency.getCurrencyCode());
   assertEquals(openingBalance.longValue() * 2, aa.openingBalance.getAmountMinor().longValue());
 }