Skip to content

Commit 908d3c4

Browse files
authored
Removed butterknife from the quiz result activity (#5425)
1 parent 94b2f89 commit 908d3c4

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

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

+16-14
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818

1919
import com.dinuscxj.progressbar.CircleProgressBar;
2020

21+
import fr.free.nrw.commons.databinding.ActivityQuizResultBinding;
2122
import java.io.File;
2223
import java.io.FileOutputStream;
2324

24-
import butterknife.BindView;
25-
import butterknife.ButterKnife;
26-
import butterknife.OnClick;
2725
import fr.free.nrw.commons.R;
2826
import fr.free.nrw.commons.contributions.MainActivity;
2927

@@ -33,20 +31,19 @@
3331
*/
3432
public class QuizResultActivity extends AppCompatActivity {
3533

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;
4035
private final int NUMBER_OF_QUESTIONS = 5;
4136
private final int MULTIPLIER_TO_GET_PERCENTAGE = 20;
4237

4338
@Override
4439
protected void onCreate(Bundle savedInstanceState) {
4540
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);
4745

48-
ButterKnife.bind(this);
49-
setSupportActionBar(toolbar);
46+
binding.quizResultNext.setOnClickListener(view -> launchContributionActivity());
5047

5148
if ( getIntent() != null) {
5249
Bundle extras = getIntent().getExtras();
@@ -60,22 +57,27 @@ protected void onCreate(Bundle savedInstanceState) {
6057
}
6158
}
6259

60+
@Override
61+
protected void onDestroy() {
62+
binding = null;
63+
super.onDestroy();
64+
}
65+
6366
/**
6467
* to calculate and display percentage and score
6568
* @param score
6669
*/
6770
public void setScore(int score) {
6871
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);
7174
String message = getResources().getString(R.string.congratulatory_message_quiz,per + "%");
72-
congratulatoryMessageText.setText(message);
75+
binding.congratulatoryMessage.setText(message);
7376
}
7477

7578
/**
7679
* to go to Contibutions Activity
7780
*/
78-
@OnClick(R.id.quiz_result_next)
7981
public void launchContributionActivity(){
8082
startActivityWithFlags(
8183
this, MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,

app/src/main/res/layout/activity_quiz_result.xml

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
android:orientation="vertical"
66
android:layout_width="match_parent">
77

8-
<include layout="@layout/toolbar"/>
8+
<include
9+
android:id="@+id/toolbar"
10+
layout="@layout/toolbar"/>
911

1012
<androidx.cardview.widget.CardView
1113
android:layout_height="match_parent"
@@ -24,16 +26,12 @@
2426
android:layout_width="match_parent"
2527
android:layout_height="match_parent">
2628

27-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
28-
xmlns:tools="http://schemas.android.com/tools"
29+
<LinearLayout
2930
android:layout_width="match_parent"
3031
android:layout_height="wrap_content"
31-
xmlns:app="http://schemas.android.com/apk/res-auto"
3232
android:orientation="vertical"
33-
tools:context="fr.free.nrw.commons.quiz.QuizResultActivity"
3433
android:id="@+id/quiz_result">
3534

36-
3735
<TextView
3836
android:layout_width="wrap_content"
3937
android:layout_height="wrap_content"

0 commit comments

Comments
 (0)