22
33import android .annotation .SuppressLint ;
44import android .app .Activity ;
5- import android .content .Context ;
65import android .content .Intent ;
76
87import javax .inject .Inject ;
2019import io .reactivex .schedulers .Schedulers ;
2120import timber .log .Timber ;
2221
23- import static android .content .Intent .FLAG_ACTIVITY_NEW_TASK ;
24-
2522/**
2623 * fetches the number of images uploaded and number of images reverted.
2724 * Then it calculates the percentage of the images reverted
@@ -37,7 +34,6 @@ public class QuizChecker {
3734 private boolean isUploadCountFetched ;
3835
3936 private CompositeDisposable compositeDisposable = new CompositeDisposable ();
40- public Context context ;
4137
4238 private final SessionManager sessionManager ;
4339 private final OkHttpJsonApiClient okHttpJsonApiClient ;
@@ -50,16 +46,13 @@ public class QuizChecker {
5046
5147 /**
5248 * constructor to set the parameters for quiz
53- * @param context context
5449 * @param sessionManager
5550 * @param okHttpJsonApiClient instance of MediaWikiApi
5651 */
5752 @ Inject
58- public QuizChecker (Context context ,
59- SessionManager sessionManager ,
53+ public QuizChecker (SessionManager sessionManager ,
6054 OkHttpJsonApiClient okHttpJsonApiClient ,
6155 @ Named ("default_preferences" ) JsonKvStore revertKvStore ) {
62- this .context = context ;
6356 this .sessionManager = sessionManager ;
6457 this .okHttpJsonApiClient = okHttpJsonApiClient ;
6558 this .revertKvStore = revertKvStore ;
@@ -70,6 +63,10 @@ public void initQuizCheck(Activity activity) {
7063 setRevertCount (activity );
7164 }
7265
66+ public void cleanup () {
67+ compositeDisposable .clear ();
68+ }
69+
7370 /**
7471 * to fet the total number of images uploaded
7572 */
@@ -151,10 +148,10 @@ private void calculateRevertParameter(Activity activity) {
151148 @ SuppressLint ("StringFormatInvalid" )
152149 private void callQuiz (Activity activity ) {
153150 DialogUtil .showAlertDialog (activity ,
154- context . getResources () .getString (R .string .quiz ),
155- context . getResources () .getString (R .string .quiz_alert_message , REVERT_PERCENTAGE_FOR_MESSAGE ),
156- context . getResources () .getString (R .string .about_translate_proceed ),
157- context . getResources () .getString (android .R .string .cancel ),
151+ activity .getString (R .string .quiz ),
152+ activity .getString (R .string .quiz_alert_message , REVERT_PERCENTAGE_FOR_MESSAGE ),
153+ activity .getString (R .string .about_translate_proceed ),
154+ activity .getString (android .R .string .cancel ),
158155 () -> startQuizActivity (activity ), null );
159156 }
160157
@@ -163,7 +160,7 @@ private void startQuizActivity(Activity activity) {
163160 revertKvStore .putInt (REVERT_SHARED_PREFERENCE , newRevetSharedPrefs );
164161 int newUploadCount = totalUploadCount + revertKvStore .getInt (UPLOAD_SHARED_PREFERENCE , 0 );
165162 revertKvStore .putInt (UPLOAD_SHARED_PREFERENCE , newUploadCount );
166- Intent i = new Intent (context , WelcomeActivity .class );
163+ Intent i = new Intent (activity , WelcomeActivity .class );
167164 i .putExtra ("isQuiz" , true );
168165 activity .startActivity (i );
169166 }
0 commit comments