use of com.google.firebase.auth.FirebaseUser in project BloodHub by kazijehangir.
the class LoginActivity method setView.
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void setView(String userId, final String email) {
final String uid = userId;
final Context context = getApplicationContext();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
FirebaseDatabase.getInstance().getReference().child("users").child(uid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User user = dataSnapshot.getValue(User.class);
String account_type = user.account_type;
showProgress(false);
if (account_type.equals("individual")) {
Intent intent;
intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra("mEmail", email);
startActivity(intent);
} else if (account_type.equals("organization")) {
Intent intent;
intent = new Intent(LoginActivity.this, MainActivityOrg.class);
intent.putExtra("mEmail", email);
startActivity(intent);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return;
}
use of com.google.firebase.auth.FirebaseUser in project BloodHub by kazijehangir.
the class UserProfile method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
mUserReference = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid());
}
use of com.google.firebase.auth.FirebaseUser in project BloodHub by kazijehangir.
the class SplashActivity method onStart.
@Override
public void onStart() {
super.onStart();
mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null) {
setView(currentUser.getUid(), currentUser.getEmail());
} else {
setContentView(R.layout.activity_fscreen);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SplashActivity.this, EmergencyRequestActivity.class);
startActivity(intent);
}
});
Button button1 = (Button) findViewById(R.id.button2);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
startActivity(intent);
}
});
}
}
use of com.google.firebase.auth.FirebaseUser in project BloodHub by kazijehangir.
the class UserProfileOrg method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_org_profile);
mUserReference = FirebaseDatabase.getInstance().getReference().child("users").child(user.getUid());
}
use of com.google.firebase.auth.FirebaseUser in project Firebase-Helper by AtifAbbAsi19.
the class FireBaseHelper method deleteUserAuthAccount.
public void deleteUserAuthAccount(FireBaseOnTaskComplete onTaskComplete) {
if (onTaskComplete != null) {
this.onTaskCompleteInterface = onTaskComplete;
final FirebaseUser currentUser = mAuth.getInstance().getCurrentUser();
currentUser.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
onTaskCompleteInterface.onComplete(task);
if (task.isSuccessful()) {
// Log.d(LOG_TAG, "OK! Works fine!");
// startActivity(new Intent(Main3WelcomeActivity.this, Main3Activity.class));
// finish();
} else {
// Log.w(LOG_TAG, "Something is wrong!");
}
}
});
}
}
Aggregations