Guest User

Untitled

a guest
Aug 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. package com.apps.camer.mobilevoting;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.annotation.NonNull;
  6. import android.support.annotation.Nullable;
  7. import android.support.v7.app.AppCompatActivity;
  8. import android.util.Log;
  9. import android.widget.Button;
  10. import android.widget.ImageView;
  11. import android.widget.TextView;
  12. import android.widget.Toast;
  13.  
  14. import com.google.firebase.database.DatabaseReference;
  15. import com.google.firebase.database.FirebaseDatabase;
  16. import com.google.firebase.database.Query;
  17. import com.google.firebase.database.DataSnapshot;
  18. import com.google.firebase.database.DatabaseError;
  19. import com.google.firebase.database.DatabaseReference;
  20. import com.google.firebase.database.ChildEventListener;
  21. import com.google.firebase.database.ValueEventListener;
  22.  
  23. import butterknife.BindView;
  24. import butterknife.ButterKnife;
  25. import butterknife.OnClick;
  26.  
  27. public class ActivityVoterInfo extends AppCompatActivity{
  28.  
  29. private static final String TAG = "ActivityVoterInfo";
  30.  
  31. private DatabaseReference mDatabase;
  32.  
  33. private ImageView voter_image;
  34. private TextView voter_name;
  35. private TextView dob;
  36. private TextView voter_occupation;
  37. private TextView address;
  38. private TextView fathName;
  39. private TextView mothName;
  40. final String voter_number = "a666666666666666666";
  41.  
  42. @BindView(R.id.voteButton)
  43. Button voteButton;
  44.  
  45.  
  46.  
  47. @Override
  48. protected void onCreate(@Nullable Bundle savedInstanceState) {
  49. super.onCreate(savedInstanceState);
  50. setContentView(R.layout.activity_voter_info);
  51. ButterKnife.bind(this);
  52.  
  53. mDatabase = FirebaseDatabase.getInstance().getReference();
  54.  
  55. voter_image = findViewById(R.id.imageView);
  56. voter_name = findViewById(R.id.textViewVoterName);
  57. voter_occupation = findViewById(R.id.textView6);
  58. dob = findViewById(R.id.textViewDob);
  59. address = findViewById(R.id.textViewAddress);
  60. fathName = findViewById(R.id.textViewFathersName);
  61. mothName = findViewById(R.id.textViewMothersName);
  62.  
  63. DatabaseReference queryLocation = mDatabase.child("Voters");
  64. Query query = queryLocation.orderByChild("registration_number").equalTo(voter_number);
  65. query.addListenerForSingleValueEvent( new ValueEventListener(){
  66. @Override
  67. public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  68. Voters voter = dataSnapshot.getValue(Voters.class);
  69. voter_name.setText("Kefeh Collins");
  70. voter_occupation.setText("Medical data Science engineer");
  71. address.setText("Toronto Canada");
  72. fathName.setText("Mbveh Kumbo");
  73. mothName.setText("Kumbo Council");
  74. }
  75.  
  76. @Override
  77. public void onCancelled(@NonNull DatabaseError databaseError) {
  78. // Getting Voter details failed, log a message
  79. Log.w(TAG, "loadVoterInfo:onCancelled", databaseError.toException());
  80. // [START_EXCLUDE]
  81. Toast.makeText(ActivityVoterInfo.this, "Failed to load post.",
  82. Toast.LENGTH_SHORT).show();
  83. // [END_EXCLUDE]
  84. }
  85. });
  86.  
  87. }
  88. public class Voters{
  89. public String name;
  90. public String council;
  91. public String polling_Station;
  92. public String occupation;
  93. public String residence;
  94. public String image;
  95.  
  96. public Voters(){
  97.  
  98. }
  99.  
  100. public Voters(String v_name, String v_council, String v_station, String v_occupation, String v_residence, String v_image){
  101.  
  102. this.council = v_council;
  103. this.image = v_image;
  104. this.name = v_name;
  105. this.occupation = v_occupation;
  106. this.residence = v_residence;
  107. this.polling_Station = v_station;
  108. }
  109. }
  110.  
  111. @OnClick(R.id.voteButton)
  112. void vote()
  113. {
  114. startActivity(new Intent(this,MainActivity.class));
  115. }
  116.  
  117. }
Add Comment
Please, Sign In to add comment