mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-25 07:51:48 -05:00
small fix and some cleanup in ServiceProgressFragment
This commit is contained in:
parent
1590d8f538
commit
8d1dc940c4
@ -98,24 +98,15 @@ public class ServiceProgressHandler extends Handler {
|
|||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
Bundle data = message.getData();
|
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);
|
MessageStatus status = MessageStatus.fromInt(message.arg1);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case OKAY:
|
case OKAY:
|
||||||
progressDialogFragment.dismissAllowingStateLoss();
|
dismissAllowingStateLoss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXCEPTION:
|
case EXCEPTION:
|
||||||
progressDialogFragment.dismissAllowingStateLoss();
|
dismissAllowingStateLoss();
|
||||||
|
|
||||||
// show error from service
|
// show error from service
|
||||||
if (data.containsKey(DATA_ERROR)) {
|
if (data.containsKey(DATA_ERROR)) {
|
||||||
@ -147,7 +138,7 @@ public class ServiceProgressHandler extends Handler {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PREVENT_CANCEL:
|
case PREVENT_CANCEL:
|
||||||
progressDialogFragment.setPreventCancel(true);
|
setPreventCancel(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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) {
|
protected void onSetProgress(String msg, int progress, int max) {
|
||||||
|
|
||||||
ProgressDialogFragment progressDialogFragment =
|
ProgressDialogFragment progressDialogFragment =
|
||||||
(ProgressDialogFragment) mActivity.getSupportFragmentManager()
|
(ProgressDialogFragment) mActivity.getSupportFragmentManager()
|
||||||
.findFragmentByTag("progressDialog");
|
.findFragmentByTag("progressDialog");
|
||||||
|
|
||||||
|
if (progressDialogFragment == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
progressDialogFragment.setProgress(msg, progress, max);
|
progressDialogFragment.setProgress(msg, progress, max);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user