]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
fix first run experience
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 905998c20cf66e031a58838d5e41bcd8a9d85aa7..bc164a55333a9d28450a78d346c7720a66e63bee 100644 (file)
@@ -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() {