]> git.ktnx.net Git - mobile-ledger.git/commitdiff
wipe retrieval progress when transaction retrieval is stopped
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 20 Apr 2021 19:46:46 +0000 (22:46 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 20 Apr 2021 19:46:46 +0000 (22:46 +0300)
fixes a glitch when a retrieval error suggests changing profile
configuration, and from there the profile is deleted and activity
restarted because of the change of the active profile. the new activity
instance observes the retrieval result and gets the error and reports it
erroneously

app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java

index c860e41b4f4e691e7011d3ad60bf22ae8c7ff9d9..06f94ee39269babbcf20483a62b37951bdd4487b 100644 (file)
@@ -113,6 +113,8 @@ public class MainModel extends ViewModel {
     public synchronized void stopTransactionsRetrieval() {
         if (retrieveTransactionsTask != null)
             retrieveTransactionsTask.cancel(true);
+        else
+            Data.backgroundTaskProgress.setValue(null);
     }
     public void transactionRetrievalDone() {
         retrieveTransactionsTask = null;
index 7df18278515ab2d1c548cb1ee5288343d2c210f1..c917bb9e1c8d53abc25a5e1ad0189ae49b0bcd02 100644 (file)
@@ -615,14 +615,16 @@ public class MainActivity extends ProfileThemedActivity implements FabManager.Fa
             b.transactionProgressLayout.setVisibility(View.GONE);
         }
     }
-    public void onRetrieveProgress(RetrieveTransactionsTask.Progress progress) {
-        if (progress.getState() == RetrieveTransactionsTask.ProgressState.FINISHED) {
+    public void onRetrieveProgress(@Nullable RetrieveTransactionsTask.Progress progress) {
+        if (progress == null ||
+            progress.getState() == RetrieveTransactionsTask.ProgressState.FINISHED)
+        {
             Logger.debug("progress", "Done");
             b.transactionProgressLayout.setVisibility(View.GONE);
 
             mainModel.transactionRetrievalDone();
 
-            String error = progress.getError();
+            String error = (progress == null) ? null : progress.getError();
             if (error != null) {
                 if (error.equals(RetrieveTransactionsTask.Result.ERR_JSON_PARSER_ERROR))
                     error = getResources().getString(R.string.err_json_parser_error);