Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed butterknife from the quiz result activity #5425

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions app/src/main/java/fr/free/nrw/commons/quiz/QuizResultActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

import com.dinuscxj.progressbar.CircleProgressBar;

import fr.free.nrw.commons.databinding.ActivityQuizResultBinding;
import java.io.File;
import java.io.FileOutputStream;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.MainActivity;

Expand All @@ -33,20 +31,19 @@
*/
public class QuizResultActivity extends AppCompatActivity {

@BindView(R.id.result_progress_bar) CircleProgressBar resultProgressBar;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.congratulatory_message) TextView congratulatoryMessageText;

private ActivityQuizResultBinding binding;
private final int NUMBER_OF_QUESTIONS = 5;
private final int MULTIPLIER_TO_GET_PERCENTAGE = 20;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz_result);
binding = ActivityQuizResultBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

setSupportActionBar(binding.toolbar.toolbar);

ButterKnife.bind(this);
setSupportActionBar(toolbar);
binding.quizResultNext.setOnClickListener(view -> launchContributionActivity());

if ( getIntent() != null) {
Bundle extras = getIntent().getExtras();
Expand All @@ -60,22 +57,27 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

@Override
protected void onDestroy() {
binding = null;
super.onDestroy();
}

/**
* to calculate and display percentage and score
* @param score
*/
public void setScore(int score) {
int per = score * MULTIPLIER_TO_GET_PERCENTAGE;
resultProgressBar.setProgress(per);
resultProgressBar.setProgressTextFormatPattern(score +" / " + NUMBER_OF_QUESTIONS);
binding.resultProgressBar.setProgress(per);
binding.resultProgressBar.setProgressTextFormatPattern(score +" / " + NUMBER_OF_QUESTIONS);
String message = getResources().getString(R.string.congratulatory_message_quiz,per + "%");
congratulatoryMessageText.setText(message);
binding.congratulatoryMessage.setText(message);
}

/**
* to go to Contibutions Activity
*/
@OnClick(R.id.quiz_result_next)
public void launchContributionActivity(){
startActivityWithFlags(
this, MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/res/layout/activity_quiz_result.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
android:orientation="vertical"
android:layout_width="match_parent">

<include layout="@layout/toolbar"/>
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>

<androidx.cardview.widget.CardView
android:layout_height="match_parent"
Expand All @@ -24,16 +26,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="fr.free.nrw.commons.quiz.QuizResultActivity"
android:id="@+id/quiz_result">


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down