]> git.ktnx.net Git - mobile-ledger.git/commitdiff
remove the day separator at the top of the transaction list
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 28 Jan 2019 19:50:28 +0000 (21:50 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 29 Jan 2019 02:49:39 +0000 (02:49 +0000)
leave it if the top transaction is not from today

app/src/main/java/net/ktnx/mobileledger/async/UpdateTransactionsTask.java

index 0f3d022ad785905a004d337f3f7233ca02ee72c7..042da8ab50db02e8165019300f045c851a6acdc5 100644 (file)
@@ -63,7 +63,8 @@ public class UpdateTransactionsTask extends AsyncTask<String, Void, String> {
 
             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, Void, String> {
                     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<String, Void, String> {
 //                    Log.d("UTT", String.format("got transaction %d", transaction_id));
 
                     lastDate = date;
+                    lastDateString = dateString;
                     odd = !odd;
                 }
                 Data.transactions.set(newList);