From e8c73363b1848804daaddd9a10940c7f8acc1d85 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 28 Jan 2019 21:50:28 +0200 Subject: [PATCH] remove the day separator at the top of the transaction list leave it if the top transaction is not from today --- .../mobileledger/async/UpdateTransactionsTask.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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); -- 2.39.5