Removed butterknife from the quiz result activity (#5425)

This commit is contained in:
Paul Hawke 2024-01-10 08:03:08 -06:00 committed by GitHub
parent 94b2f891ab
commit 908d3c43a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 20 deletions

View file

@ -18,12 +18,10 @@ import androidx.appcompat.widget.Toolbar;
import com.dinuscxj.progressbar.CircleProgressBar; import com.dinuscxj.progressbar.CircleProgressBar;
import fr.free.nrw.commons.databinding.ActivityQuizResultBinding;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.MainActivity; import fr.free.nrw.commons.contributions.MainActivity;
@ -33,20 +31,19 @@ import fr.free.nrw.commons.contributions.MainActivity;
*/ */
public class QuizResultActivity extends AppCompatActivity { public class QuizResultActivity extends AppCompatActivity {
@BindView(R.id.result_progress_bar) CircleProgressBar resultProgressBar; private ActivityQuizResultBinding binding;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.congratulatory_message) TextView congratulatoryMessageText;
private final int NUMBER_OF_QUESTIONS = 5; private final int NUMBER_OF_QUESTIONS = 5;
private final int MULTIPLIER_TO_GET_PERCENTAGE = 20; private final int MULTIPLIER_TO_GET_PERCENTAGE = 20;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_result); binding = ActivityQuizResultBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
ButterKnife.bind(this); setSupportActionBar(binding.toolbar.toolbar);
setSupportActionBar(toolbar);
binding.quizResultNext.setOnClickListener(view -> launchContributionActivity());
if ( getIntent() != null) { if ( getIntent() != null) {
Bundle extras = getIntent().getExtras(); Bundle extras = getIntent().getExtras();
@ -60,22 +57,27 @@ public class QuizResultActivity extends AppCompatActivity {
} }
} }
@Override
protected void onDestroy() {
binding = null;
super.onDestroy();
}
/** /**
* to calculate and display percentage and score * to calculate and display percentage and score
* @param score * @param score
*/ */
public void setScore(int score) { public void setScore(int score) {
int per = score * MULTIPLIER_TO_GET_PERCENTAGE; int per = score * MULTIPLIER_TO_GET_PERCENTAGE;
resultProgressBar.setProgress(per); binding.resultProgressBar.setProgress(per);
resultProgressBar.setProgressTextFormatPattern(score +" / " + NUMBER_OF_QUESTIONS); binding.resultProgressBar.setProgressTextFormatPattern(score +" / " + NUMBER_OF_QUESTIONS);
String message = getResources().getString(R.string.congratulatory_message_quiz,per + "%"); String message = getResources().getString(R.string.congratulatory_message_quiz,per + "%");
congratulatoryMessageText.setText(message); binding.congratulatoryMessage.setText(message);
} }
/** /**
* to go to Contibutions Activity * to go to Contibutions Activity
*/ */
@OnClick(R.id.quiz_result_next)
public void launchContributionActivity(){ public void launchContributionActivity(){
startActivityWithFlags( startActivityWithFlags(
this, MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP, this, MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,

View file

@ -5,7 +5,9 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent"> android:layout_width="match_parent">
<include layout="@layout/toolbar"/> <include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_height="match_parent" android:layout_height="match_parent"
@ -24,16 +26,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
tools:context="fr.free.nrw.commons.quiz.QuizResultActivity"
android:id="@+id/quiz_result"> android:id="@+id/quiz_result">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"