Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.Button;
- import android.widget.ProgressBar;
- import android.widget.TextView;
- import com.google.firebase.database.DatabaseReference;
- import com.google.firebase.database.FirebaseDatabase;
- import sonu.enigma.Common.Common;
- import sonu.enigma.Model.QuestionScore;
- public class Done extends AppCompatActivity {
- Button btnTryAgain;
- TextView txtResultScore, getTxtResultQuestion;
- ProgressBar progressBar;
- FirebaseDatabase database;
- DatabaseReference question_score;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_done);
- database = FirebaseDatabase.getInstance();
- question_score=database.getReference("Question_Score");
- txtResultScore=(TextView)findViewById(R.id.txtTotalScore);
- getTxtResultQuestion=(TextView)findViewById(R.id.txtTotalQuestion);
- progressBar=(ProgressBar)findViewById(R.id.doneProgressBar);
- btnTryAgain=(Button)findViewById(R.id.btnTryAgain);
- btnTryAgain.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent= new Intent(Done.this, Home.class);
- startActivity(intent);
- finish();
- }
- });
- Bundle extra= getIntent().getExtras();
- if (extra!=null){
- int score=extra.getInt("SCORE");
- int totalQuestion=extra.getInt("TOTAL");
- int correctAnswer=extra.getInt("CORRECT");
- txtResultScore.setText(String.format("SCORE : %d", score));
- getTxtResultQuestion.setText(String.format("PASSED : %d / %d",correctAnswer, totalQuestion ));
- progressBar.setMax(totalQuestion);
- progressBar.setProgress(correctAnswer);
- question_score.child(String.format("%s_%s", Common.CurrentUser.getUserName(), Common.CategoryId))
- .setValue(new QuestionScore(String.format("%s_%s", Common.CurrentUser.getUserName(), Common.CategoryId),Common.CurrentUser.getUserName(),String.valueOf(score)));
- }
- }
- }
- `**
- `package sonu.enigma.Model;
- /**
- * Created by PAWAN on 01-10-2017.
- */
- public class User {
- private String userName;
- private String password;
- private String email;
- public User(){
- }
- public User(String userName, String password, String email){
- this.userName=userName;
- this.password=password;
- this.email =email;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- }
- `**above is my User.java . **
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement