From ab42c559ad21aaf85d977f390e68b638346f51d7 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 12 Apr 2019 18:11:08 +0300 Subject: [PATCH] fix first run experience hide the no profiles screen and show the main screen when the first profile is created properly trigger a data retrieval operation also when the data is stale --- .../mobileledger/ui/activity/MainActivity.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 905998c2..bc164a55 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 @@ -319,8 +319,11 @@ public class MainActivity extends ProfileThemedActivity { onProfileChanged(null); updateLastUpdateTextFromDB(); - Date lastUpdate = Data.lastUpdateDate.get(); + scheduleDataRetrievalIfStale(); + } + private void scheduleDataRetrievalIfStale() { + Date lastUpdate = Data.lastUpdateDate.get(); long now = new Date().getTime(); if ((lastUpdate == null) || (now > (lastUpdate.getTime() + (24 * 3600 * 1000)))) { if (lastUpdate == null) Log.d("db::", "WEB data never fetched. scheduling a fetch"); @@ -367,6 +370,11 @@ public class MainActivity extends ProfileThemedActivity { MobileLedgerProfile profile = Data.profile.get(); MainActivity.this.runOnUiThread(() -> { + boolean haveProfile = profile != null; + findViewById(R.id.no_profiles_layout).setVisibility(haveProfile ? View.GONE : View.VISIBLE); + findViewById(R.id.pager_layout) + .setVisibility(haveProfile ? View.VISIBLE : View.VISIBLE); + Data.transactions.clear(); Log.d("transactions", "requesting list reload"); TransactionListViewModel.scheduleTransactionListReload(); @@ -419,6 +427,10 @@ public class MainActivity extends ProfileThemedActivity { fab.hide(); } } + + updateLastUpdateTextFromDB(); + + scheduleDataRetrievalIfStale(); }); } private void updateLastUpdateDisplay() { -- 2.39.5