@@ -110,6 +110,9 @@ public class AchievementsActivity extends NavigationBaseActivity {
110
110
111
111
private CompositeDisposable compositeDisposable = new CompositeDisposable ();
112
112
113
+ // To keep track of the number of wiki edits made by a user
114
+ private int numberOfEdits = 0 ;
115
+
113
116
/**
114
117
* This method helps in the creation Achievement screen and
115
118
* dynamically set the size of imageView
@@ -140,8 +143,8 @@ protected void onCreate(Bundle savedInstanceState) {
140
143
progressBar .setVisibility (View .VISIBLE );
141
144
142
145
hideLayouts ();
143
- setAchievements ();
144
146
setWikidataEditCount ();
147
+ setAchievements ();
145
148
initDrawer ();
146
149
}
147
150
@@ -230,12 +233,24 @@ private void setAchievements() {
230
233
Timber .d ("success" );
231
234
layoutImageReverts .setVisibility (View .INVISIBLE );
232
235
imageView .setVisibility (View .INVISIBLE );
233
- showSnackBarWithRetry ();
236
+ // If the number of edits made by the user are more than 150,000
237
+ // in some cases such high number of wiki edit counts cause the
238
+ // achievements calculator to fail in some cases, for more details
239
+ // refer Issue: #3295
240
+ if (numberOfEdits <= 150000 ) {
241
+ showSnackBarWithRetry (false );
242
+ } else {
243
+ showSnackBarWithRetry (true );
244
+ }
234
245
}
235
246
},
236
247
t -> {
237
248
Timber .e (t , "Fetching achievements statistics failed" );
238
- showSnackBarWithRetry ();
249
+ if (numberOfEdits <= 150000 ) {
250
+ showSnackBarWithRetry (false );
251
+ } else {
252
+ showSnackBarWithRetry (true );
253
+ }
239
254
}
240
255
));
241
256
}
@@ -259,19 +274,31 @@ private void setWikidataEditCount() {
259
274
.getWikidataEdits (userName )
260
275
.subscribeOn (Schedulers .io ())
261
276
.observeOn (AndroidSchedulers .mainThread ())
262
- .subscribe (edits -> wikidataEditsText .setText (String .valueOf (edits )), e -> {
277
+ .subscribe (edits -> {
278
+ numberOfEdits = edits ;
279
+ wikidataEditsText .setText (String .valueOf (edits ));
280
+ }, e -> {
263
281
Timber .e ("Error:" + e );
264
282
}));
265
283
}
266
284
267
285
/**
268
286
* Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
269
287
* listener passed
288
+ * @param tooManyAchievements if this value is true it means that the number of achievements of the
289
+ * user are so high that it wrecks havoc with the Achievements calculator due to which request may time
290
+ * out. Well this is the Ultimate Achievement
270
291
*/
271
- private void showSnackBarWithRetry () {
272
- progressBar .setVisibility (View .GONE );
273
- ViewUtil .showDismissibleSnackBar (findViewById (android .R .id .content ),
274
- R .string .achievements_fetch_failed , R .string .retry , view -> setAchievements ());
292
+ private void showSnackBarWithRetry (boolean tooManyAchievements ) {
293
+ if (tooManyAchievements ) {
294
+ progressBar .setVisibility (View .GONE );
295
+ ViewUtil .showDismissibleSnackBar (findViewById (android .R .id .content ),
296
+ R .string .achievements_fetch_failed_ultimate_achievement , R .string .retry , view -> setAchievements ());
297
+ } else {
298
+ progressBar .setVisibility (View .GONE );
299
+ ViewUtil .showDismissibleSnackBar (findViewById (android .R .id .content ),
300
+ R .string .achievements_fetch_failed , R .string .retry , view -> setAchievements ());
301
+ }
275
302
}
276
303
277
304
/**
@@ -504,4 +531,4 @@ private boolean checkAccount(){
504
531
return true ;
505
532
}
506
533
507
- }
534
+ }
0 commit comments