Skip to content

Commit

Permalink
codinguser#876 - Use AccountType.displayBalance(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanGarf committed Mar 7, 2020
1 parent 535e3d5 commit 8844002
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ protected void displayReport() {
mChart.highlightValues(null);
mChart.invalidate();

TransactionsActivity.displayBalance(mTotalAssets, mAssetsBalance, AccountType.ASSET);
TransactionsActivity.displayBalance(mTotalLiabilities, mLiabilitiesBalance, AccountType.LIABILITY);
AccountType.ASSET.displayBalance(mTotalAssets, mAssetsBalance);
AccountType.LIABILITY.displayBalance(mTotalLiabilities, mLiabilitiesBalance);
// #8xx
TransactionsActivity.displayBalance(mNetWorth, mAssetsBalance.add(mLiabilitiesBalance), null);
AccountType.ASSET.displayBalance(mNetWorth, mAssetsBalance.add(mLiabilitiesBalance));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
import org.gnucash.android.model.Money;
import org.gnucash.android.ui.report.BaseReportFragment;
import org.gnucash.android.ui.report.ReportType;
import org.gnucash.android.ui.transaction.TransactionsActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
Expand Down Expand Up @@ -104,10 +102,9 @@ protected void displayReport() {
loadAccountViews(LIABLITY_ACCOUNT_TYPES, mLiabilitiesTableLayout);
loadAccountViews(EQUITY_ACCOUNT_TYPES, mEquityTableLayout);

TransactionsActivity.displayBalance(mNetWorth,
// #8xx
mAssetsBalance.add(mLiabilitiesBalance),
null);
AccountType.ASSET.displayBalance(mNetWorth,
// #8xx
mAssetsBalance.add(mLiabilitiesBalance));
}

@Override
Expand Down Expand Up @@ -140,9 +137,8 @@ private void loadAccountViews(List<AccountType> accountTypes, TableLayout tableL
((TextView)view.findViewById(R.id.account_name)).setText(name);
TextView balanceTextView = (TextView) view.findViewById(R.id.account_balance);
accountType = AccountType.valueOf(cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_TYPE)));
TransactionsActivity.displayBalance(balanceTextView,
balance,
accountType);
accountType.displayBalance(balanceTextView,
balance);
tableLayout.addView(view);
}

Expand All @@ -157,11 +153,10 @@ private void loadAccountViews(List<AccountType> accountTypes, TableLayout tableL
TextView accountBalance = (TextView) totalView.findViewById(R.id.account_balance);
accountBalance.setTextSize(16);
accountBalance.setTypeface(null, Typeface.BOLD);
TransactionsActivity.displayBalance(accountBalance,
mAccountsDbAdapter.getAccountBalance(accountTypes,
-1,
System.currentTimeMillis()),
accountType);
accountType.displayBalance(accountBalance,
mAccountsDbAdapter.getAccountBalance(accountTypes,
-1,
System.currentTimeMillis()));

tableLayout.addView(totalView);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,9 @@ public void onActivityCreated(Bundle savedInstanceState) {
view.findViewById(R.id.input_accounts_spinner).setEnabled(false);
view.findViewById(R.id.btn_remove_split).setVisibility(View.GONE);

TransactionsActivity.displayBalance(mImbalanceTextView,
new Money(mBaseAmount.negate(),
mCommodity),
accountType);
accountType.displayBalance(mImbalanceTextView,
new Money(mBaseAmount.negate(),
mCommodity));
}

}
Expand Down Expand Up @@ -628,10 +627,9 @@ public void afterTextChanged(Editable editable) {

} // for

TransactionsActivity.displayBalance(mImbalanceTextView,
new Money(imbalance,
mCommodity),
null);
AccountType.ASSET.displayBalance(mImbalanceTextView,
new Money(imbalance,
mCommodity));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.gnucash.android.db.adapter.AccountsDbAdapter;
import org.gnucash.android.db.adapter.ScheduledActionDbAdapter;
import org.gnucash.android.db.adapter.TransactionsDbAdapter;
import org.gnucash.android.model.AccountType;
import org.gnucash.android.model.Money;
import org.gnucash.android.model.ScheduledAction;
import org.gnucash.android.model.Split;
Expand All @@ -26,7 +27,6 @@
import org.gnucash.android.ui.common.FormActivity;
import org.gnucash.android.ui.common.UxArgument;
import org.gnucash.android.ui.passcode.PasscodeLockActivity;
import org.gnucash.android.ui.util.AccountUtils;

import java.text.DateFormat;
import java.util.Date;
Expand Down Expand Up @@ -75,10 +75,11 @@ public SplitAmountViewHolder(View view,
? splitCreditView
: splitDebitView;

TransactionsActivity.displayBalance(balanceView,
quantity,
AccountsDbAdapter.getInstance()
.getAccountType(split.getAccountUID()));
final AccountType accountType = AccountsDbAdapter.getInstance()
.getAccountType(split.getAccountUID());

accountType.displayBalance(balanceView,
quantity);
}

} // Class SplitAmountViewHolder
Expand Down Expand Up @@ -161,9 +162,10 @@ private void bindViews(){
// Define in which field (Debit or Credit) the balance shall be displayed
TextView balanceTextView = accountBalance.isNegative() ? mCreditBalance : mDebitBalance ;

TransactionsActivity.displayBalance(balanceTextView,
accountBalance,
accountsDbAdapter.getAccountType(mAccountUID));
final AccountType accountType = accountsDbAdapter.getAccountType(mAccountUID);

accountType.displayBalance(balanceTextView,
accountBalance);

//
// Détails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.gnucash.android.db.adapter.DatabaseAdapter;
import org.gnucash.android.db.adapter.SplitsDbAdapter;
import org.gnucash.android.db.adapter.TransactionsDbAdapter;
import org.gnucash.android.model.AccountType;
import org.gnucash.android.model.Money;
import org.gnucash.android.model.Split;
import org.gnucash.android.model.Transaction;
Expand Down Expand Up @@ -275,10 +276,12 @@ public void onBindViewHolderCursor(ViewHolder holder, Cursor cursor) {

final String transactionUID = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.TransactionEntry.COLUMN_UID));
Money amount = mTransactionsDbAdapter.getBalance(transactionUID, mAccountUID);
TransactionsActivity.displayBalance(holder.transactionAmount,
amount,
GnuCashApplication.getAccountsDbAdapter()
.getAccountType(mAccountUID));

final AccountType accountType = GnuCashApplication.getAccountsDbAdapter()
.getAccountType(mAccountUID);

accountType.displayBalance(holder.transactionAmount,
amount);

long dateMillis = cursor.getLong(cursor.getColumnIndexOrThrow(DatabaseSchema.TransactionEntry.COLUMN_TIMESTAMP));
String dateText = TransactionsActivity.getPrettyDateFormat(getActivity(), dateMillis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
import android.widget.TextView;

import org.gnucash.android.R;
import org.gnucash.android.app.GnuCashApplication;
import org.gnucash.android.db.adapter.CommoditiesDbAdapter;
import org.gnucash.android.db.adapter.PricesDbAdapter;
import org.gnucash.android.model.AccountType;
import org.gnucash.android.model.Commodity;
import org.gnucash.android.model.Money;
import org.gnucash.android.model.Price;
import org.gnucash.android.ui.transaction.OnTransferFundsListener;
import org.gnucash.android.ui.transaction.TransactionsActivity;
import org.gnucash.android.util.AmountParser;

import java.math.BigDecimal;
Expand Down Expand Up @@ -98,10 +97,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View view = inflater.inflate(R.layout.dialog_transfer_funds, container, false);
ButterKnife.bind(this, view);

TransactionsActivity.displayBalance(mStartAmountLabel,
mOriginAmount,
// TODO TW C 2020-03-05 : A vérifier
null);
// TODO TW C 2020-03-05 : A vérifier
AccountType.ASSET.displayBalance(mStartAmountLabel,
mOriginAmount);

String fromCurrencyCode = mOriginAmount.getCommodity().getCurrencyCode();
mFromCurrencyLabel.setText(fromCurrencyCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.crashlytics.android.Crashlytics;

import org.gnucash.android.db.adapter.AccountsDbAdapter;
import org.gnucash.android.model.AccountType;
import org.gnucash.android.model.Money;
import org.gnucash.android.ui.transaction.TransactionsActivity;

import java.lang.ref.WeakReference;

Expand Down Expand Up @@ -76,9 +76,10 @@ protected void onPostExecute(Money balance) {

if (balanceTextView != null) {

TransactionsActivity.displayBalance(balanceTextView,
balance,
accountsDbAdapter.getAccountType(mAccountUID));
final AccountType accountType = accountsDbAdapter.getAccountType(mAccountUID);

accountType.displayBalance(balanceTextView,
balance);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ private void setSwitchTextAndColor(final boolean isCredit) {
// Set text color of views
//

@ColorInt final int color = AccountType.getAmountColor(isCredit,
getAccountType());
@ColorInt final int color = getAccountType().getAmountColor(isCredit);

TransactionTypeSwitch.this.setTextColor(color);
mAmountEditText.setTextColor(color);
Expand Down

0 comments on commit 8844002

Please sign in to comment.