]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix refreshing the display of the last update stamp
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 12 Mar 2019 20:11:12 +0000 (22:11 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 14 Mar 2019 20:54:57 +0000 (22:54 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java

index 1376e7a9932de18575e7a1abb5ec3543538b35e5..4202a84cc437d9f074ceaa2c42073038eb1ce483 100644 (file)
@@ -216,19 +216,11 @@ public class MainActivity extends ProfileThemedActivity {
 
         Data.lastUpdateDate.addObserver((o, arg) -> {
             Log.d("main", "lastUpdateDate changed");
-            runOnUiThread(() -> {
-                Date date = Data.lastUpdateDate.get();
-                if (date == null) {
-                    tvLastUpdate.setText(R.string.transaction_last_update_never);
-                }
-                else {
-                    final String text = DateFormat.getDateTimeInstance().format(date);
-                    tvLastUpdate.setText(text);
-                    Log.d("despair", String.format("Date formatted: %s", text));
-                }
-            });
+            runOnUiThread(this::updateLastUpdateDisplay);
         });
 
+        updateLastUpdateDisplay();
+
         findViewById(R.id.btn_no_profiles_add)
                 .setOnClickListener(v -> startEditProfileActivity(null));
 
@@ -282,6 +274,19 @@ public class MainActivity extends ProfileThemedActivity {
             }
         });
     }
+    private void updateLastUpdateDisplay() {
+        TextView v = findViewById(R.id.transactions_last_update);
+        Date date = Data.lastUpdateDate.get();
+        if (date == null) {
+            v.setText(R.string.transaction_last_update_never);
+            Log.d("main", "no last update date :(");
+        }
+        else {
+            final String text = DateFormat.getDateTimeInstance().format(date);
+            v.setText(text);
+            Log.d("main", String.format("Date formatted: %s", text));
+        }
+    }
     private void profileThemeChanged() {
         setupProfileColors();