@@ -110,6 +110,9 @@ public class AchievementsActivity extends NavigationBaseActivity {
110110
111111 private CompositeDisposable compositeDisposable = new CompositeDisposable ();
112112
113+ // To keep track of the number of wiki edits made by a user
114+ private int numberOfEdits = 0 ;
115+
113116 /**
114117 * This method helps in the creation Achievement screen and
115118 * dynamically set the size of imageView
@@ -140,8 +143,8 @@ protected void onCreate(Bundle savedInstanceState) {
140143 progressBar .setVisibility (View .VISIBLE );
141144
142145 hideLayouts ();
143- setAchievements ();
144146 setWikidataEditCount ();
147+ setAchievements ();
145148 initDrawer ();
146149 }
147150
@@ -230,12 +233,24 @@ private void setAchievements() {
230233 Timber .d ("success" );
231234 layoutImageReverts .setVisibility (View .INVISIBLE );
232235 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+ }
234245 }
235246 },
236247 t -> {
237248 Timber .e (t , "Fetching achievements statistics failed" );
238- showSnackBarWithRetry ();
249+ if (numberOfEdits <= 150000 ) {
250+ showSnackBarWithRetry (false );
251+ } else {
252+ showSnackBarWithRetry (true );
253+ }
239254 }
240255 ));
241256 }
@@ -259,19 +274,31 @@ private void setWikidataEditCount() {
259274 .getWikidataEdits (userName )
260275 .subscribeOn (Schedulers .io ())
261276 .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 -> {
263281 Timber .e ("Error:" + e );
264282 }));
265283 }
266284
267285 /**
268286 * Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
269287 * 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
270291 */
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+ }
275302 }
276303
277304 /**
@@ -504,4 +531,4 @@ private boolean checkAccount(){
504531 return true ;
505532 }
506533
507- }
534+ }
0 commit comments