@@ -34,7 +34,7 @@ public class ProgressDialogFragment extends BaseDialogFragment implements Progre
34
34
private String repoName = null ;
35
35
36
36
private boolean taskCancelled = false ;
37
- private int totalTasks = 0 ;
37
+ private int totalTasks = 4 ;
38
38
private int currentTask = 0 ;
39
39
private int totalWork = 0 ;
40
40
private int currentWork = 0 ;
@@ -58,21 +58,23 @@ public void setRepositoryName(String repoName) {
58
58
/** ProgressMonitor: Advise the monitor of the total number of subtasks. */
59
59
@ Override
60
60
public void start (int totalTasks ) {
61
- this .totalTasks = totalTasks ;
61
+ // this.totalTasks = totalTasks;
62
62
}
63
63
64
64
/** ProgressMonitor: Begin processing a single task. */
65
65
@ SuppressLint ("SetTextI18n" )
66
66
@ Override
67
67
public void beginTask (String title , int totalWork ) {
68
- this .currentTask ++;
69
68
this .totalWork = totalWork ;
70
- this .currentWork = 0 ;
69
+ this .currentTask ++;
70
+ this .currentWork =0 ;
71
71
if (mDebug ) {
72
72
Log .d (LOG_TAG , "beginTask " + this .currentTask + ": " + title + ": " + totalWork + " items" );
73
73
}
74
- requireActivity ().runOnUiThread (() ->
75
- this .mDataBinding .textCurrentTaskTitle .setText (title ));
74
+ requireActivity ().runOnUiThread (() -> {
75
+ this .mDataBinding .progressIndicator .setMax (totalWork );
76
+ this .mDataBinding .textTaskTitle .setText (title );
77
+ });
76
78
}
77
79
78
80
/** ProgressMonitor: Denote that some work units have been completed. */
@@ -81,17 +83,23 @@ public void beginTask(String title, int totalWork) {
81
83
public void update (int completed ) {
82
84
this .currentWork += completed ;
83
85
String message = this .currentWork + " / " + this .totalWork ;
84
- if (mDebug ) {Log .d (LOG_TAG , "items complete: " + message );}
85
- requireActivity ().runOnUiThread (() ->
86
- this .mDataBinding .textDownloadStatus .setText (message )
87
- );
86
+ // if (mDebug) {Log.d(LOG_TAG, "items complete: " + message);}
87
+ requireActivity ().runOnUiThread (() -> {
88
+ this .mDataBinding .progressIndicator .setProgress (this .currentWork );
89
+ this .mDataBinding .textTaskStatus .setText (message );
90
+ });
88
91
}
89
92
90
93
/** ProgressMonitor: Finish the current task, so the next can begin. */
91
94
@ Override
92
95
public void endTask () {
93
- if (mDebug ) {Log .d (LOG_TAG , "endTask " + this .currentTask );}
94
- if (this .currentTask == this .totalTasks ) {this .dismiss ();}
96
+ if (mDebug ) {Log .d (LOG_TAG , "endTask " + this .currentTask + " / " + this .totalTasks );}
97
+ // if (this.currentTask == this.totalTasks) {this.dismiss();} // TODO: comparison doesn't work.
98
+
99
+ /* Reset the progress indicator */
100
+ requireActivity ().runOnUiThread (() -> {
101
+ this .mDataBinding .progressIndicator .setProgress (0 );
102
+ });
95
103
}
96
104
97
105
/** Interface: ProgressMonitor. Check for user task cancellation. */
0 commit comments