Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.apps.camer.mobilevoting;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.annotation.Nullable;
- import android.support.v7.app.AppCompatActivity;
- import android.util.Log;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.google.firebase.database.DatabaseReference;
- import com.google.firebase.database.FirebaseDatabase;
- import com.google.firebase.database.Query;
- import com.google.firebase.database.DataSnapshot;
- import com.google.firebase.database.DatabaseError;
- import com.google.firebase.database.DatabaseReference;
- import com.google.firebase.database.ChildEventListener;
- import com.google.firebase.database.ValueEventListener;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- import butterknife.OnClick;
- public class ActivityVoterInfo extends AppCompatActivity{
- private static final String TAG = "ActivityVoterInfo";
- private DatabaseReference mDatabase;
- private ImageView voter_image;
- private TextView voter_name;
- private TextView dob;
- private TextView voter_occupation;
- private TextView address;
- private TextView fathName;
- private TextView mothName;
- final String voter_number = "a666666666666666666";
- @BindView(R.id.voteButton)
- Button voteButton;
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_voter_info);
- ButterKnife.bind(this);
- mDatabase = FirebaseDatabase.getInstance().getReference();
- voter_image = findViewById(R.id.imageView);
- voter_name = findViewById(R.id.textViewVoterName);
- voter_occupation = findViewById(R.id.textView6);
- dob = findViewById(R.id.textViewDob);
- address = findViewById(R.id.textViewAddress);
- fathName = findViewById(R.id.textViewFathersName);
- mothName = findViewById(R.id.textViewMothersName);
- DatabaseReference queryLocation = mDatabase.child("Voters");
- Query query = queryLocation.orderByChild("registration_number").equalTo(voter_number);
- query.addListenerForSingleValueEvent( new ValueEventListener(){
- @Override
- public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
- Voters voter = dataSnapshot.getValue(Voters.class);
- voter_name.setText("Kefeh Collins");
- voter_occupation.setText("Medical data Science engineer");
- address.setText("Toronto Canada");
- fathName.setText("Mbveh Kumbo");
- mothName.setText("Kumbo Council");
- }
- @Override
- public void onCancelled(@NonNull DatabaseError databaseError) {
- // Getting Voter details failed, log a message
- Log.w(TAG, "loadVoterInfo:onCancelled", databaseError.toException());
- // [START_EXCLUDE]
- Toast.makeText(ActivityVoterInfo.this, "Failed to load post.",
- Toast.LENGTH_SHORT).show();
- // [END_EXCLUDE]
- }
- });
- }
- public class Voters{
- public String name;
- public String council;
- public String polling_Station;
- public String occupation;
- public String residence;
- public String image;
- public Voters(){
- }
- public Voters(String v_name, String v_council, String v_station, String v_occupation, String v_residence, String v_image){
- this.council = v_council;
- this.image = v_image;
- this.name = v_name;
- this.occupation = v_occupation;
- this.residence = v_residence;
- this.polling_Station = v_station;
- }
- }
- @OnClick(R.id.voteButton)
- void vote()
- {
- startActivity(new Intent(this,MainActivity.class));
- }
- }
Add Comment
Please, Sign In to add comment