Skip to content

Commit bc1aa8d

Browse files
committed
made essential changes
1 parent 7fb75a9 commit bc1aa8d

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

app/src/main/java/fr/free/nrw/commons/achievements/AchievementsActivity.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,18 @@ private void setAchievements() {
238238
// achievements calculator to fail in some cases, for more details
239239
// refer Issue: #3295
240240
if (numberOfEdits <= 150000) {
241-
showSnackBarWithRetry();
241+
showSnackBarWithRetry(false);
242242
} else {
243-
showSnackBarUltimateAchievementWithRetry();
243+
showSnackBarWithRetry(true);
244244
}
245245
}
246246
},
247247
t -> {
248248
Timber.e(t, "Fetching achievements statistics failed");
249249
if (numberOfEdits <= 150000) {
250-
showSnackBarWithRetry();
250+
showSnackBarWithRetry(false);
251251
} else {
252-
showSnackBarUltimateAchievementWithRetry();
252+
showSnackBarWithRetry(true);
253253
}
254254
}
255255
));
@@ -275,7 +275,7 @@ private void setWikidataEditCount() {
275275
.subscribeOn(Schedulers.io())
276276
.observeOn(AndroidSchedulers.mainThread())
277277
.subscribe(edits -> {
278-
numberOfEdits += edits;
278+
numberOfEdits = edits;
279279
wikidataEditsText.setText(String.valueOf(edits));
280280
}, e -> {
281281
Timber.e("Error:" + e);
@@ -285,22 +285,20 @@ private void setWikidataEditCount() {
285285
/**
286286
* Shows a snack bar which has an action button which on click dismisses the snackbar and invokes the
287287
* 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
288291
*/
289-
private void showSnackBarWithRetry() {
290-
progressBar.setVisibility(View.GONE);
291-
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),
292-
R.string.achievements_fetch_failed, R.string.retry, view -> setAchievements());
293-
}
294-
295-
/**
296-
* Shows a snack bar which tells the users that their wiki edit count is so high that it (in some cases)
297-
* wreks havoc with the Achievements calculator due to which request may time out
298-
* Well this is the Ultimate Achievement
299-
*/
300-
private void showSnackBarUltimateAchievementWithRetry() {
301-
progressBar.setVisibility(View.GONE);
302-
ViewUtil.showDismissibleSnackBar(findViewById(android.R.id.content),
303-
R.string.achievements_fetch_failed_ultimate_achievement, 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+
}
304302
}
305303

306304
/**

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ Upload your first media by tapping on the add button.</string>
459459
<string name="display_location_permission_title">Display location permission</string>
460460
<string name="display_location_permission_explanation">Ask for location permission when needed for nearby notification card view feature.</string>
461461
<string name="achievements_fetch_failed">Something went wrong, We could not fetch your achievements</string>
462-
<string name="achievements_fetch_failed_ultimate_achievement">Congratulations!, Your achievements are so high that they break out achievements calculator. This is the Ultimate Achievement.</string>
462+
<string name="achievements_fetch_failed_ultimate_achievement">Congratulations! You've made so many contributions our achievements calculation system can't cope. This is the ultimate achievement.</string>
463463
<string name="ends_on">Ends on:</string>
464464
<string name="display_campaigns">Display campaigns</string>
465465
<string name="display_campaigns_explanation">See the ongoing campaigns</string>

0 commit comments

Comments
 (0)