use of com.google.firebase.auth.FirebaseUser in project Pepper_v0 by SamDaQueen.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// loading the default fragment
loadFragment(new CategoryFragment());
BottomNavigationView navigation = findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
Bundle bundle = getIntent().getBundleExtra("items");
if (bundle != null)
arrayList = bundle.getParcelableArrayList("order");
// Firebase Authentication
mUsername = ANONYMOUS;
mFirebaseAuth = FirebaseAuth.getInstance();
mAuthStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// user signed in
onSignedInInitialize(user.getDisplayName());
} else {
// user signed out
onSignedOutCleanup();
startActivityForResult(AuthUI.getInstance().createSignInIntentBuilder().setIsSmartLockEnabled(false).setAvailableProviders(Arrays.asList(new AuthUI.IdpConfig.GoogleBuilder().build(), new AuthUI.IdpConfig.EmailBuilder().build(), new AuthUI.IdpConfig.PhoneBuilder().build())).setLogo(R.drawable.pepper_500px).build(), RC_SIGN_IN);
}
}
};
}
use of com.google.firebase.auth.FirebaseUser in project Pepper_v0 by SamDaQueen.
the class ProfileFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_profile, container, false);
// Sign out Button
signoutbtn = rootView.findViewById(R.id.button8);
signOutFunction();
// Get User Details
textView = rootView.findViewById(R.id.textView);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user != null)
if (user.getDisplayName() != null)
textView.setText(user.getDisplayName());
// Displaying Credits
creditsbtn = rootView.findViewById(R.id.button9);
creditsbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getActivity(), Credits.class));
}
});
// share
share = rootView.findViewById(R.id.button10);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onInviteClicked();
}
});
// image
if (flag == true) {
imageView = rootView.findViewById(R.id.imageView);
hint = rootView.findViewById(R.id.hint);
setImageView();
}
return rootView;
}
use of com.google.firebase.auth.FirebaseUser in project OnlineCanteen by josephgunawan97.
the class AccountUtil method createRole.
private static Task<Void> createRole(String role) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
DatabaseReference reference = firebaseDatabase.getReference("role");
return reference.child(firebaseUser.getUid()).setValue(role);
}
use of com.google.firebase.auth.FirebaseUser in project OnlineCanteen by josephgunawan97.
the class AccountUtil method uploadProfilePicture.
private static UploadTask uploadProfilePicture(Uri profilePictureUri) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageReference = storage.getReference();
StorageReference directoryReference = storageReference.child("profilepics");
StorageReference profilePictureReference = directoryReference.child(firebaseUser.getUid() + ".jpg");
if (profilePictureUri != null) {
return profilePictureReference.putFile(profilePictureUri);
} else
return null;
}
use of com.google.firebase.auth.FirebaseUser in project OnlineCanteen by josephgunawan97.
the class AccountUtil method updateUserInformationOnDatabase.
private static Task<Void> updateUserInformationOnDatabase(User user) {
FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
DatabaseReference reference = firebaseDatabase.getReference("users");
return reference.child(firebaseUser.getUid()).setValue(user);
}
Aggregations