diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-22 23:08:03 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-06-22 23:08:03 +0200 |
commit | 8d1dc940c4d1e864aad767e298373b02da55f556 (patch) | |
tree | f88177d83bf52929b6bd3f9c1c518e2ad04735a1 | |
parent | 1590d8f53852415e8d5c857f83685978fc19ed3a (diff) | |
download | open-keychain-8d1dc940c4d1e864aad767e298373b02da55f556.tar.gz open-keychain-8d1dc940c4d1e864aad767e298373b02da55f556.tar.bz2 open-keychain-8d1dc940c4d1e864aad767e298373b02da55f556.zip |
small fix and some cleanup in ServiceProgressFragment
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java index 701bfc053..989b0c4bd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java @@ -98,24 +98,15 @@ public class ServiceProgressHandler extends Handler { public void handleMessage(Message message) { Bundle data = message.getData(); - ProgressDialogFragment progressDialogFragment = - (ProgressDialogFragment) mActivity.getSupportFragmentManager() - .findFragmentByTag("progressDialog"); - - if (progressDialogFragment == null) { - Log.e(Constants.TAG, "Progress has not been updated because mProgressDialogFragment was null!"); - return; - } - MessageStatus status = MessageStatus.fromInt(message.arg1); switch (status) { case OKAY: - progressDialogFragment.dismissAllowingStateLoss(); + dismissAllowingStateLoss(); break; case EXCEPTION: - progressDialogFragment.dismissAllowingStateLoss(); + dismissAllowingStateLoss(); // show error from service if (data.containsKey(DATA_ERROR)) { @@ -147,7 +138,7 @@ public class ServiceProgressHandler extends Handler { break; case PREVENT_CANCEL: - progressDialogFragment.setPreventCancel(true); + setPreventCancel(true); break; default: @@ -156,12 +147,41 @@ public class ServiceProgressHandler extends Handler { } } + private void setPreventCancel(boolean preventCancel) { + ProgressDialogFragment progressDialogFragment = + (ProgressDialogFragment) mActivity.getSupportFragmentManager() + .findFragmentByTag("progressDialog"); + + if (progressDialogFragment == null) { + return; + } + + progressDialogFragment.setPreventCancel(preventCancel); + } + + protected void dismissAllowingStateLoss() { + ProgressDialogFragment progressDialogFragment = + (ProgressDialogFragment) mActivity.getSupportFragmentManager() + .findFragmentByTag("progressDialog"); + + if (progressDialogFragment == null) { + return; + } + + progressDialogFragment.dismissAllowingStateLoss(); + } + + protected void onSetProgress(String msg, int progress, int max) { ProgressDialogFragment progressDialogFragment = (ProgressDialogFragment) mActivity.getSupportFragmentManager() .findFragmentByTag("progressDialog"); + if (progressDialogFragment == null) { + return; + } + if (msg != null) { progressDialogFragment.setProgress(msg, progress, max); } else { |