Guest User

Untitled

a guest
Jan 24th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. auth = FirebaseAuth.getInstance();
  2.  
  3. if (auth.getCurrentUser() != null) {
  4.  
  5. if(loginflag.equals("0")){
  6. startActivity(new Intent(LoginActivity.this, HomeUsers.class));
  7. finish();
  8. }
  9. else if (loginflag.equals("1")) {
  10. startActivity(new Intent(LoginActivity.this, HomeEducator.class));
  11. finish();
  12. }
  13. }
  14. }
  15.  
  16.  
  17. private void loginControl() {
  18.  
  19. FirebaseUser user = auth.getCurrentUser();
  20. String id = user.getUid();
  21. DatabaseReference FirebaseRef = FirebaseDatabase.getInstance().getReference().child("users").child(id);
  22.  
  23. FirebaseRef.addValueEventListener(new ValueEventListener() {
  24. @Override
  25. public void onDataChange(DataSnapshot snapshot) {
  26.  
  27. if(snapshot.exists()){
  28. loginflag = snapshot.child("flag").getValue().toString();
  29. }
  30. }
  31. @Override
  32. public void onCancelled(DatabaseError databaseError) {
  33. }
  34. });
  35. }
Add Comment
Please, Sign In to add comment