Skip to content

Commit dd5c34f

Browse files
committed
closing the dialog, when done.
1 parent 46dd38b commit dd5c34f

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

mobile/src/main/java/io/syslogic/github/dialog/BaseDialogFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ abstract public class BaseDialogFragment extends DialogFragment {
3131
protected SharedPreferences prefs;
3232
@Nullable protected Dialog dialog;
3333

34-
/** By default the dialog can be closed by touching outside of it */
35-
protected boolean cancelOnTouchOutSide = true;
34+
/** By default the dialog cannot be closed by touching outside of it */
35+
protected boolean cancelOnTouchOutSide = false;
3636

3737
public BaseDialogFragment() {}
3838

mobile/src/main/java/io/syslogic/github/dialog/ProgressDialogFragment.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public class ProgressDialogFragment extends BaseDialogFragment implements Progre
3434

3535
private String repoName = null;
3636
private boolean taskCancelled = false;
37-
private int totalTasks = 6;
37+
@SuppressWarnings("FieldCanBeLocal")
38+
private final int totalTasks = 6;
3839
private int currentTask = 0;
3940
private int totalWork = 0;
4041
private int currentWork = 0;
@@ -81,17 +82,15 @@ public void beginTask(String title, int totalWork) {
8182
/** ProgressMonitor: Denote that some work units have been completed. */
8283
@Override
8384
public void update(int completed) {
84-
this.currentWork += completed;
85-
86-
String message = this.currentWork + " / " + this.totalWork;
8785
String percentage;
88-
// if (mDebug) {Log.d(LOG_TAG, "items complete: " + message);}
86+
this.currentWork += completed;
8987
if (this.totalWork == 0) {
9088
percentage = "0.00%";
9189
} else {
92-
percentage = String.format(Locale.ROOT,"%.02f", (float) (this.currentWork / this.totalWork * 100)) + "%";
90+
percentage = String.format(Locale.ROOT,"%.02f", ((float) this.currentWork / (float) this.totalWork) * 100) + "%";
9391
}
9492

93+
String message = this.currentWork + " / " + this.totalWork;
9594
requireActivity().runOnUiThread(() -> {
9695
this.mDataBinding.progressIndicator.setProgress(this.currentWork);
9796
this.mDataBinding.textTaskStatus.setText(message);
@@ -103,11 +102,14 @@ public void update(int completed) {
103102
@Override
104103
public void endTask() {
105104
if (mDebug) {Log.d(LOG_TAG, "endTask " + this.currentTask + " / " + this.totalTasks);}
106-
// if (this.currentTask == this.totalTasks) {this.dismiss();} // TODO: comparison doesn't work.
107-
108-
/* Reset the progress indicator */
109-
requireActivity().runOnUiThread(() ->
110-
this.mDataBinding.progressIndicator.setProgress(0));
105+
if (this.currentTask != this.totalTasks) {
106+
/* Reset the progress indicator. */
107+
requireActivity().runOnUiThread(() ->
108+
this.mDataBinding.progressIndicator.setProgress(0));
109+
} else {
110+
/* Dismiss dialog. */
111+
this.dismiss();
112+
}
111113
}
112114

113115
/** Interface: ProgressMonitor. Check for user task cancellation. */

0 commit comments

Comments
 (0)