From: Damyan Ivanov Date: Fri, 12 Apr 2019 15:11:08 +0000 (+0300) Subject: fix first run experience X-Git-Tag: v0.9.4~1 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=ab42c559ad21aaf85d977f390e68b638346f51d7;p=mobile-ledger.git 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 --- 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() {