Guest User

Untitled

a guest
Jan 23rd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4. setContentView(R.layout.activity_login);
  5.  
  6. MngEmail = (EditText)findViewById(R.id.MngEmailField);
  7. MngPassword = (EditText)findViewById(R.id.mngPass);
  8. MngFrgtPass = (TextView)findViewById(R.id.MngForText);
  9. MngLoginBtn = (Button)findViewById(R.id.MngBtn);
  10. loadingbar = new ProgressDialog(this);
  11.  
  12. MngAuth = FirebaseAuth.getInstance();
  13. SuperAdminUId = MngAuth.getCurrentUser().getUid();
  14. String key = MngRef.child("SchoolData").child(SuperAdminUId).getKey();
  15.  
  16. MngRef = FirebaseDatabase.getInstance().getReference().child("SchoolData").child(SuperAdminUId).child(key);
  17.  
  18. MngFrgtPass.setOnClickListener(new View.OnClickListener() {
  19. @Override
  20. public void onClick(View v) {
  21. // TO Dooo
  22. }
  23. });
  24.  
  25. MngLoginBtn.setOnClickListener(new View.OnClickListener() {
  26. @Override
  27. public void onClick(View v) {
  28. Query query = MngRef.orderByChild("SchoolEmail").equalTo(MngEmail.getText().toString().trim());
  29. query.addListenerForSingleValueEvent(new ValueEventListener() {
  30. @Override
  31. public void onDataChange(DataSnapshot dataSnapshot) {
  32. if (dataSnapshot.exists()) {
  33. // dataSnapshot is the "issue" node with all children with id 0
  34.  
  35. for (DataSnapshot user : dataSnapshot.getChildren()) {
  36. // do something with the individual "issues"
  37. School schoolinfo = user.getValue(School.class);
  38.  
  39. if (schoolinfo.equals(MngPassword.getText().toString().trim())) {
  40. sendMngToMain();
  41. } else {
  42. Toast.makeText(login.this, "Password is wrong", Toast.LENGTH_LONG).show();
  43. }
  44. }
  45. } else {
  46. Toast.makeText(login.this, "User not found", Toast.LENGTH_LONG).show();
  47. }
  48. }
  49.  
  50. @Override
  51. public void onCancelled(DatabaseError databaseError) {
  52.  
  53. }
  54. });
  55. }
  56. });
  57. }
Add Comment
Please, Sign In to add comment