@@ -38,10 +38,23 @@ public final class CompletableProgressDialog extends DialogFragment {
38
38
39
39
public static CompletableProgressDialog show (FragmentManager manager ) {
40
40
CompletableProgressDialog dialog = new CompletableProgressDialog ();
41
- dialog .show (manager , TAG );
41
+ dialog .showAllowingStateLoss (manager , TAG );
42
42
return dialog ;
43
43
}
44
44
45
+ /**
46
+ * This method is adapted from {@link #show(FragmentManager, String)}
47
+ */
48
+ public void showAllowingStateLoss (FragmentManager manager , String tag ) {
49
+ // This prevents us from hitting FragmentManager.checkStateLoss() which
50
+ // throws a runtime exception if state has already been saved.
51
+ if (manager .isStateSaved ()) {
52
+ return ;
53
+ }
54
+
55
+ show (manager , tag );
56
+ }
57
+
45
58
@ NonNull
46
59
@ Override
47
60
public Dialog onCreateDialog (Bundle savedInstanceState ) {
@@ -60,12 +73,18 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
60
73
61
74
public void onComplete (String msg ) {
62
75
setMessage (msg );
63
- mProgress .setVisibility (View .GONE );
64
- mSuccessImage .setVisibility (View .VISIBLE );
76
+
77
+ if (mProgress != null ) {
78
+ mProgress .setVisibility (View .GONE );
79
+ }
80
+
81
+ if (mSuccessImage != null ) {
82
+ mSuccessImage .setVisibility (View .VISIBLE );
83
+ }
65
84
}
66
85
67
86
public void setMessage (CharSequence message ) {
68
- if (mProgress != null ) {
87
+ if (mProgress != null && mMessageView != null ) {
69
88
mMessageView .setText (message );
70
89
} else {
71
90
mMessage = message ;
0 commit comments