Skip to content

Commit 76e9522

Browse files
Avoid showing the quiz pop-up twice to the user
Due to the current flow of code it's possible that in some cases the quiz pop-up is shown to the user twice. This is unnecessary and unintentional. So, change the logic in such a way that the quiz pop-up would be never be shown twice to the user. Fixes: commons-app#3281
1 parent 0049c8b commit 76e9522

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

app/src/main/java/fr/free/nrw/commons/quiz/QuizChecker.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public QuizChecker(SessionManager sessionManager,
5959
}
6060

6161
public void initQuizCheck(Activity activity) {
62-
setUploadCount(activity);
63-
setRevertCount(activity);
62+
calculateRevertParameterAndShowQuiz(activity);
6463
}
6564

6665
public void cleanup() {
@@ -92,7 +91,6 @@ private void setTotalUploadCount(Activity activity, int uploadCount) {
9291
revertKvStore.putInt(UPLOAD_SHARED_PREFERENCE, 0);
9392
}
9493
isUploadCountFetched = true;
95-
calculateRevertParameter(activity);
9694
}
9795

9896
/**
@@ -123,13 +121,14 @@ private void setRevertParameter(Activity activity, int revertCountFetched) {
123121
revertKvStore.putInt(REVERT_SHARED_PREFERENCE, 0);
124122
}
125123
isRevertCountFetched = true;
126-
calculateRevertParameter(activity);
127124
}
128125

129126
/**
130127
* to check whether the criterion to call quiz is satisfied
131128
*/
132-
private void calculateRevertParameter(Activity activity) {
129+
private void calculateRevertParameterAndShowQuiz(Activity activity) {
130+
setUploadCount(activity);
131+
setRevertCount(activity);
133132
if ( revertCount < 0 || totalUploadCount < 0){
134133
revertKvStore.putInt(REVERT_SHARED_PREFERENCE, 0);
135134
revertKvStore.putInt(UPLOAD_SHARED_PREFERENCE, 0);

0 commit comments

Comments
 (0)