From: Damyan Ivanov Date: Mon, 28 Jan 2019 19:50:28 +0000 (+0200) Subject: remove the day separator at the top of the transaction list X-Git-Tag: v0.4~4 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=e8c73363b1848804daaddd9a10940c7f8acc1d85;p=mobile-ledger.git remove the day separator at the top of the transaction list leave it if the top transaction is not from today --- diff --git a/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java index 0f3d022a..042da8ab 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java @@ -63,7 +63,8 @@ public class UpdateTransactionsTask extends AsyncTask { Log.d("UTT", sql); SQLiteDatabase db = MLDB.getReadableDatabase(); - Date lastDate = null; + String lastDateString = Globals.formatLedgerDate(new Date()); + Date lastDate = Globals.parseLedgerDate(lastDateString); boolean odd = true; try (Cursor cursor = db.rawQuery(sql, params)) { while (cursor.moveToNext()) { @@ -73,12 +74,9 @@ public class UpdateTransactionsTask extends AsyncTask { String dateString = cursor.getString(1); Date date = Globals.parseLedgerDate(dateString); - if ((lastDate == null) || !lastDate.equals(date)) { - boolean showMonth = (lastDate == null) || (date != null) && - (date.getMonth() != - lastDate.getMonth() || - date.getYear() != - lastDate.getYear()); + if (!lastDateString.equals(dateString)) { + boolean showMonth = (date.getMonth() != lastDate.getMonth() || + date.getYear() != lastDate.getYear()); newList.add(new TransactionListItem(date, showMonth)); } newList.add( @@ -86,6 +84,7 @@ public class UpdateTransactionsTask extends AsyncTask { // Log.d("UTT", String.format("got transaction %d", transaction_id)); lastDate = date; + lastDateString = dateString; odd = !odd; } Data.transactions.set(newList);