18
18
19
19
import com .dinuscxj .progressbar .CircleProgressBar ;
20
20
21
+ import fr .free .nrw .commons .databinding .ActivityQuizResultBinding ;
21
22
import java .io .File ;
22
23
import java .io .FileOutputStream ;
23
24
24
- import butterknife .BindView ;
25
- import butterknife .ButterKnife ;
26
- import butterknife .OnClick ;
27
25
import fr .free .nrw .commons .R ;
28
26
import fr .free .nrw .commons .contributions .MainActivity ;
29
27
33
31
*/
34
32
public class QuizResultActivity extends AppCompatActivity {
35
33
36
- @ BindView (R .id .result_progress_bar ) CircleProgressBar resultProgressBar ;
37
- @ BindView (R .id .toolbar ) Toolbar toolbar ;
38
- @ BindView (R .id .congratulatory_message ) TextView congratulatoryMessageText ;
39
-
34
+ private ActivityQuizResultBinding binding ;
40
35
private final int NUMBER_OF_QUESTIONS = 5 ;
41
36
private final int MULTIPLIER_TO_GET_PERCENTAGE = 20 ;
42
37
43
38
@ Override
44
39
protected void onCreate (Bundle savedInstanceState ) {
45
40
super .onCreate (savedInstanceState );
46
- setContentView (R .layout .activity_quiz_result );
41
+ binding = ActivityQuizResultBinding .inflate (getLayoutInflater ());
42
+ setContentView (binding .getRoot ());
43
+
44
+ setSupportActionBar (binding .toolbar .toolbar );
47
45
48
- ButterKnife .bind (this );
49
- setSupportActionBar (toolbar );
46
+ binding .quizResultNext .setOnClickListener (view -> launchContributionActivity ());
50
47
51
48
if ( getIntent () != null ) {
52
49
Bundle extras = getIntent ().getExtras ();
@@ -60,22 +57,27 @@ protected void onCreate(Bundle savedInstanceState) {
60
57
}
61
58
}
62
59
60
+ @ Override
61
+ protected void onDestroy () {
62
+ binding = null ;
63
+ super .onDestroy ();
64
+ }
65
+
63
66
/**
64
67
* to calculate and display percentage and score
65
68
* @param score
66
69
*/
67
70
public void setScore (int score ) {
68
71
int per = score * MULTIPLIER_TO_GET_PERCENTAGE ;
69
- resultProgressBar .setProgress (per );
70
- resultProgressBar .setProgressTextFormatPattern (score +" / " + NUMBER_OF_QUESTIONS );
72
+ binding . resultProgressBar .setProgress (per );
73
+ binding . resultProgressBar .setProgressTextFormatPattern (score +" / " + NUMBER_OF_QUESTIONS );
71
74
String message = getResources ().getString (R .string .congratulatory_message_quiz ,per + "%" );
72
- congratulatoryMessageText .setText (message );
75
+ binding . congratulatoryMessage .setText (message );
73
76
}
74
77
75
78
/**
76
79
* to go to Contibutions Activity
77
80
*/
78
- @ OnClick (R .id .quiz_result_next )
79
81
public void launchContributionActivity (){
80
82
startActivityWithFlags (
81
83
this , MainActivity .class , Intent .FLAG_ACTIVITY_CLEAR_TOP ,
0 commit comments