@@ -43,6 +43,8 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
43
43
ImageButton retryButton ;
44
44
@ BindView (R .id .cancelButton )
45
45
ImageButton cancelButton ;
46
+ @ BindView (R .id .pauseResumeButton )
47
+ ImageButton pauseResumeButton ;
46
48
47
49
48
50
private int position ;
@@ -93,7 +95,11 @@ public void init(final int position, final Contribution contribution) {
93
95
case Contribution .STATE_IN_PROGRESS :
94
96
stateView .setVisibility (View .GONE );
95
97
progressView .setVisibility (View .VISIBLE );
96
- imageOptions .setVisibility (View .GONE );
98
+ addToWikipediaButton .setVisibility (View .GONE );
99
+ pauseResumeButton .setVisibility (View .VISIBLE );
100
+ cancelButton .setVisibility (View .GONE );
101
+ retryButton .setVisibility (View .GONE );
102
+ imageOptions .setVisibility (View .VISIBLE );
97
103
final long total = contribution .getDataLength ();
98
104
final long transferred = contribution .getTransferred ();
99
105
if (transferred == 0 || transferred >= total ) {
@@ -102,10 +108,23 @@ public void init(final int position, final Contribution contribution) {
102
108
progressView .setProgress ((int ) (((double ) transferred / (double ) total ) * 100 ));
103
109
}
104
110
break ;
111
+ case Contribution .STATE_PAUSED :
112
+ stateView .setVisibility (View .VISIBLE );
113
+ stateView .setText (R .string .paused );
114
+ setResume ();
115
+ progressView .setVisibility (View .GONE );
116
+ cancelButton .setVisibility (View .GONE );
117
+ retryButton .setVisibility (View .GONE );
118
+ pauseResumeButton .setVisibility (View .VISIBLE );
119
+ imageOptions .setVisibility (View .VISIBLE );
120
+ break ;
105
121
case Contribution .STATE_FAILED :
106
122
stateView .setVisibility (View .VISIBLE );
107
123
stateView .setText (R .string .contribution_state_failed );
108
124
progressView .setVisibility (View .GONE );
125
+ cancelButton .setVisibility (View .VISIBLE );
126
+ retryButton .setVisibility (View .VISIBLE );
127
+ pauseResumeButton .setVisibility (View .GONE );
109
128
imageOptions .setVisibility (View .VISIBLE );
110
129
break ;
111
130
}
@@ -187,4 +206,34 @@ public void imageClicked() {
187
206
public void wikipediaButtonClicked () {
188
207
callback .addImageToWikipedia (contribution );
189
208
}
209
+
210
+ /**
211
+ * Triggers a callback for pause/resume
212
+ */
213
+ @ OnClick (R .id .pauseResumeButton )
214
+ public void onPauseResumeButtonClicked () {
215
+ if (pauseResumeButton .getTag ().toString ().equals ("pause" )) {
216
+ callback .pauseUpload (contribution );
217
+ setResume ();
218
+ } else {
219
+ callback .resumeUpload (contribution );
220
+ setPaused ();
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Update pause/resume button to show pause state
226
+ */
227
+ private void setPaused () {
228
+ pauseResumeButton .setImageResource (R .drawable .pause_icon );
229
+ pauseResumeButton .setTag (R .string .pause );
230
+ }
231
+
232
+ /**
233
+ * Update pause/resume button to show resume state
234
+ */
235
+ private void setResume () {
236
+ pauseResumeButton .setImageResource (R .drawable .play_icon );
237
+ pauseResumeButton .setTag (R .string .resume );
238
+ }
190
239
}
0 commit comments