Java Code Examples for com.google.firebase.auth.FirebaseUser#isAnonymous()

The following examples show how to use com.google.firebase.auth.FirebaseUser#isAnonymous() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfileActivity.java    From friendlypix-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    FirebaseUser currentUser = mAuth.getCurrentUser();
    if (currentUser != null && !currentUser.isAnonymous()) {
        dismissProgressDialog();
        showSignedInUI(currentUser);
    } else {
        showSignedOutUI();
    }
}
 
Example 2
Source File: AnonymousUpgradeActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private void updateUI() {
    FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();

    if (currentUser == null) {
        // Not signed in
        mAnonSignInButton.setEnabled(true);
        mLaunchUIButton.setEnabled(false);
        mResolveMergeButton.setEnabled(false);
        mSignOutButton.setEnabled(false);
    } else if (mPendingCredential == null && currentUser.isAnonymous()) {
        // Anonymous user, waiting for linking
        mAnonSignInButton.setEnabled(false);
        mLaunchUIButton.setEnabled(true);
        mResolveMergeButton.setEnabled(false);
        mSignOutButton.setEnabled(true);
    } else if (mPendingCredential == null && !currentUser.isAnonymous()) {
        // Fully signed in
        mAnonSignInButton.setEnabled(false);
        mLaunchUIButton.setEnabled(false);
        mResolveMergeButton.setEnabled(false);
        mSignOutButton.setEnabled(true);
    } else if (mPendingCredential != null) {
        // Signed in anonymous, awaiting merge conflict
        mAnonSignInButton.setEnabled(false);
        mLaunchUIButton.setEnabled(false);
        mResolveMergeButton.setEnabled(true);
        mSignOutButton.setEnabled(true);
    }
}
 
Example 3
Source File: AnonymousUpgradeActivity.java    From FirebaseUI-Android with Apache License 2.0 5 votes vote down vote up
private String getUserIdentifier(FirebaseUser user) {
    if (user.isAnonymous()) {
        return user.getUid();
    } else if (!TextUtils.isEmpty(user.getEmail())) {
        return user.getEmail();
    } else if (!TextUtils.isEmpty(user.getPhoneNumber())) {
        return user.getPhoneNumber();
    } else {
        return "unknown";
    }
}