Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. import android.content.Intent;
  2. import android.os.Bundle;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.view.View;
  5. import android.widget.Button;
  6. import android.widget.ProgressBar;
  7. import android.widget.TextView;
  8.  
  9. import com.google.firebase.database.DatabaseReference;
  10. import com.google.firebase.database.FirebaseDatabase;
  11.  
  12. import sonu.enigma.Common.Common;
  13. import sonu.enigma.Model.QuestionScore;
  14.  
  15. public class Done extends AppCompatActivity {
  16. Button btnTryAgain;
  17. TextView txtResultScore, getTxtResultQuestion;
  18. ProgressBar progressBar;
  19. FirebaseDatabase database;
  20. DatabaseReference question_score;
  21.  
  22.  
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. setContentView(R.layout.activity_done);
  27.  
  28. database = FirebaseDatabase.getInstance();
  29. question_score=database.getReference("Question_Score");
  30. txtResultScore=(TextView)findViewById(R.id.txtTotalScore);
  31. getTxtResultQuestion=(TextView)findViewById(R.id.txtTotalQuestion);
  32. progressBar=(ProgressBar)findViewById(R.id.doneProgressBar);
  33. btnTryAgain=(Button)findViewById(R.id.btnTryAgain);
  34.  
  35. btnTryAgain.setOnClickListener(new View.OnClickListener() {
  36. @Override
  37. public void onClick(View v) {
  38. Intent intent= new Intent(Done.this, Home.class);
  39. startActivity(intent);
  40. finish();
  41.  
  42. }
  43. });
  44.  
  45. Bundle extra= getIntent().getExtras();
  46. if (extra!=null){
  47. int score=extra.getInt("SCORE");
  48. int totalQuestion=extra.getInt("TOTAL");
  49. int correctAnswer=extra.getInt("CORRECT");
  50.  
  51. txtResultScore.setText(String.format("SCORE : %d", score));
  52. getTxtResultQuestion.setText(String.format("PASSED : %d / %d",correctAnswer, totalQuestion ));
  53. progressBar.setMax(totalQuestion);
  54. progressBar.setProgress(correctAnswer);
  55.  
  56. question_score.child(String.format("%s_%s", Common.CurrentUser.getUserName(), Common.CategoryId))
  57. .setValue(new QuestionScore(String.format("%s_%s", Common.CurrentUser.getUserName(), Common.CategoryId),Common.CurrentUser.getUserName(),String.valueOf(score)));
  58.  
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65. }
  66. }
  67. `**
  68.  
  69. `package sonu.enigma.Model;
  70.  
  71. /**
  72. * Created by PAWAN on 01-10-2017.
  73. */
  74.  
  75. public class User {
  76. private String userName;
  77. private String password;
  78. private String email;
  79. public User(){
  80.  
  81. }
  82. public User(String userName, String password, String email){
  83. this.userName=userName;
  84. this.password=password;
  85. this.email =email;
  86.  
  87.  
  88. }
  89.  
  90. public String getUserName() {
  91. return userName;
  92. }
  93.  
  94. public void setUserName(String userName) {
  95. this.userName = userName;
  96. }
  97.  
  98. public String getPassword() {
  99. return password;
  100. }
  101.  
  102. public void setPassword(String password) {
  103. this.password = password;
  104. }
  105.  
  106. public String getEmail() {
  107. return email;
  108. }
  109.  
  110. public void setEmail(String email) {
  111. this.email = email;
  112. }
  113. }
  114. `**above is my User.java . **
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement