]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
better shadow under main header in dark mode
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / MainActivity.java
index 5efc2f84f386180a930fd24ea7164d8344efd180..1674c029a45dfda2b525cad2402cca1c235903c3 100644 (file)
@@ -29,6 +29,7 @@ import android.os.Build;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.animation.AnimationUtils;
 import android.widget.LinearLayout;
 import android.widget.ProgressBar;
@@ -335,15 +336,15 @@ public class MainActivity extends ProfileThemedActivity {
                      mainModel.clearUpdateError();
                  });
     }
-    private void scheduleDataRetrievalIfStale(Date lastUpdate) {
+    private void scheduleDataRetrievalIfStale(long lastUpdate) {
         long now = new Date().getTime();
-        if ((lastUpdate == null) || (now > (lastUpdate.getTime() + (24 * 3600 * 1000)))) {
-            if (lastUpdate == null)
+        if ((lastUpdate == 0) || (now > (lastUpdate + (24 * 3600 * 1000)))) {
+            if (lastUpdate == 0)
                 Logger.debug("db::", "WEB data never fetched. scheduling a fetch");
             else
                 Logger.debug("db", String.format(Locale.ENGLISH,
                         "WEB data last fetched at %1.3f and now is %1.3f. re-fetching",
-                        lastUpdate.getTime() / 1000f, now / 1000f));
+                        lastUpdate / 1000f, now / 1000f));
 
             mainModel.scheduleTransactionListRetrieval();
         }
@@ -460,7 +461,7 @@ public class MainActivity extends ProfileThemedActivity {
         updateLastUpdateTextFromDB();
     }
     private void updateLastUpdateDisplay(Date newValue) {
-        LinearLayout l = findViewById(R.id.transactions_last_update_layout);
+        ViewGroup l = findViewById(R.id.transactions_last_update_layout);
         TextView v = findViewById(R.id.transactions_last_update);
         if (newValue == null) {
             l.setVisibility(View.INVISIBLE);
@@ -473,8 +474,6 @@ public class MainActivity extends ProfileThemedActivity {
             l.setVisibility(View.VISIBLE);
             Logger.debug("main", String.format("Date formatted: %s", text));
         }
-
-        scheduleDataRetrievalIfStale(newValue);
     }
     private void profileThemeChanged() {
         storeThemeIdInPrefs(profile.getThemeHue());
@@ -580,6 +579,8 @@ public class MainActivity extends ProfileThemedActivity {
         else {
             mainModel.lastUpdateDate.postValue(new Date(last_update));
         }
+        scheduleDataRetrievalIfStale(last_update);
+
     }
     public void onStopTransactionRefreshClick(View view) {
         Logger.debug("interactive", "Cancelling transactions refresh");