Resources rm = getResources();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Resources.Theme theme = getTheme();
- Globals.tableRowOddBG = rm.getColor(R.color.table_row_odd_bg, theme);
- Globals.tableRowEvenBG = rm.getColor(R.color.table_row_even_bg, theme);
+ Globals.tableRowDarkBG = rm.getColor(R.color.table_row_dark_bg, theme);
+ Globals.tableRowLightBG = rm.getColor(R.color.table_row_light_bg, theme);
Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark, theme);
Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text, theme);
}
else {
- Globals.tableRowOddBG = rm.getColor(R.color.table_row_odd_bg);
- Globals.tableRowEvenBG = rm.getColor(R.color.table_row_even_bg);
+ Globals.tableRowDarkBG = rm.getColor(R.color.table_row_dark_bg);
+ Globals.tableRowLightBG = rm.getColor(R.color.table_row_light_bg);
Globals.primaryDark = rm.getColor(R.color.design_default_color_primary_dark);
Globals.defaultTextColor = rm.getColor(android.R.color.tab_indicator_text);
}
Log.d("UTT", sql);
SQLiteDatabase db = MLDB.getReadableDatabase();
Date lastDate = null;
+ boolean odd = true;
try (Cursor cursor = db.rawQuery(sql, params)) {
while (cursor.moveToNext()) {
if (isCancelled()) return null;
lastDate.getYear());
newList.add(new TransactionListItem(date, showMonth));
}
- newList.add(new TransactionListItem(new LedgerTransaction(transaction_id)));
+ newList.add(
+ new TransactionListItem(new LedgerTransaction(transaction_id), odd));
// Log.d("UTT", String.format("got transaction %d", transaction_id));
lastDate = date;
+ odd = !odd;
}
Data.transactions.set(newList);
Log.d("UTT", "transaction list value updated");
private Date date;
private boolean monthShown;
private LedgerTransaction transaction;
+ private boolean odd;
public TransactionListItem(Date date, boolean monthShown) {
this.type = Type.DELIMITER;
this.date = date;
this.monthShown = monthShown;
}
- public TransactionListItem(LedgerTransaction transaction) {
+ public TransactionListItem(LedgerTransaction transaction, boolean isOdd) {
this.type = Type.TRANSACTION;
this.transaction = transaction;
+ this.odd = isOdd;
}
@NonNull
public Type getType() {
public LedgerTransaction getTransaction() {
return transaction;
}
+ public boolean isOdd() {
+ return odd;
+ }
public enum Type {TRANSACTION, DELIMITER}
}
if (position % 2 == 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
- .setBackgroundColor(rm.getColor(R.color.table_row_even_bg, ctx.getTheme()));
- else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_even_bg));
+ .setBackgroundColor(rm.getColor(R.color.table_row_dark_bg, ctx.getTheme()));
+ else holder.row.setBackgroundColor(rm.getColor(R.color.table_row_dark_bg));
}
else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) holder.row
public void markDrawerItemCurrent(int id) {
TextView item = drawer.findViewById(id);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- item.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg, getTheme()));
+ item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg, getTheme()));
}
else {
- item.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg));
+ item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg));
}
@ColorInt int transparent = getResources().getColor(android.R.color.transparent);
// tr.getAccounts().size()));
TransactionLoader loader = new TransactionLoader();
- loader.execute(new TransactionLoaderParams(tr, holder, position, boldAccountName));
+ loader.execute(new TransactionLoaderParams(tr, holder, position, boldAccountName,
+ item.isOdd()));
// WORKAROUND what seems to be a bug in CardHolder somewhere
// when a view that was previously holding a delimiter is re-purposed
@Override
protected Void doInBackground(TransactionLoaderParams... p) {
LedgerTransaction tr = p[0].transaction;
+ boolean odd = p[0].odd;
SQLiteDatabase db = MLDB.getReadableDatabase();
tr.loadData(db);
- publishProgress(new TransactionLoaderStep(p[0].holder, p[0].position, tr));
+ publishProgress(new TransactionLoaderStep(p[0].holder, p[0].position, tr, odd));
int rowIndex = 0;
for (LedgerTransactionAccount acc : tr.getAccounts()) {
case HEAD:
holder.tvDescription.setText(step.getTransaction().getDescription());
- if (step.getPosition() % 2 == 0) {
- holder.row.setBackgroundColor(Globals.tableRowEvenBG);
- }
- else {
- holder.row.setBackgroundColor(Globals.tableRowOddBG);
- }
+ if (step.isOdd()) holder.row.setBackgroundColor(Globals.tableRowDarkBG);
+ else holder.row.setBackgroundColor(Globals.tableRowLightBG);
break;
case ACCOUNTS:
TransactionRowHolder holder;
int position;
String boldAccountName;
+ boolean odd;
TransactionLoaderParams(LedgerTransaction transaction, TransactionRowHolder holder,
- int position, String boldAccountName) {
+ int position, String boldAccountName, boolean odd) {
this.transaction = transaction;
this.holder = holder;
this.position = position;
this.boldAccountName = boldAccountName;
+ this.odd = odd;
}
}
}
\ No newline at end of file
private LedgerTransactionAccount account;
private int accountPosition;
private String boldAccountName;
+ private boolean odd;
public TransactionLoaderStep(TransactionRowHolder holder, int position,
- LedgerTransaction transaction) {
+ LedgerTransaction transaction, boolean isOdd) {
this.step = TransactionListAdapter.LoaderStep.HEAD;
this.holder = holder;
this.transaction = transaction;
this.position = position;
+ this.odd = isOdd;
}
public TransactionLoaderStep(TransactionRowHolder holder, LedgerTransactionAccount account,
int accountPosition, String boldAccountName) {
public LedgerTransactionAccount getAccount() {
return account;
}
+ public boolean isOdd() {
+ return odd;
+ }
}
public final class Globals {
@ColorInt
- public static int tableRowEvenBG;
+ public static int tableRowLightBG;
@ColorInt
- public static int tableRowOddBG;
+ public static int tableRowDarkBG;
@ColorInt
public static int primaryDark, defaultTextColor;
public static String[] monthNames;
<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright © 2018 Damyan Ivanov.
+ ~ Copyright © 2019 Damyan Ivanov.
~ This file is part of Mobile-Ledger.
~ Mobile-Ledger is free software: you can distribute it and/or modify it
~ under the term of the GNU General Public License as published by
<color name="colorPrimaryDark">#42148c</color>
<color name="colorAccent">#724db6</color>
<color name="drawer_background">#ffffffff</color>
- <color name="table_row_even_bg">#286c33d4</color>
- <color name="table_row_odd_bg">#28ddcbff</color>
+ <color name="table_row_dark_bg">#286c33d4</color>
+ <color name="table_row_light_bg">#28ddcbff</color>
<color name="header_border">#804a148c</color>
</resources>