From: Damyan Ivanov Date: Tue, 20 Apr 2021 19:46:46 +0000 (+0300) Subject: wipe retrieval progress when transaction retrieval is stopped X-Git-Tag: v0.18.0~71 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=b033938cc547329fd4bab5b15304a099b10360e0;p=mobile-ledger.git wipe retrieval progress when transaction retrieval is stopped 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 --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java index c860e41b..06f94ee3 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/MainModel.java @@ -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; 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 7df18278..c917bb9e 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 @@ -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);