From: Damyan Ivanov Date: Tue, 12 Mar 2019 20:11:12 +0000 (+0200) Subject: fix refreshing the display of the last update stamp X-Git-Tag: v0.8~18 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=8b399301f8373f2e62712649af53d6c2b6c07182;p=mobile-ledger.git fix refreshing the display of the last update stamp --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 1376e7a9..4202a84c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -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();