Search in sources :

Example 1 with CurrentUserUtility

use of com.example.c4q.capstone.utils.currentuser.CurrentUserUtility in project Grupp by tmoronta1208.

the class LoginActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // button views
    signInButton = findViewById(R.id.google_button);
    emailLogInButton = findViewById(R.id.btn_login);
    // publicUserDatabaseReference = firebaseDatabase.getReference().child(Constants.PUBLIC_USER);
    // getUserData();
    emailLogInButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            signIn();
        }
    });
    signInButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            signIn();
        }
    });
    mAuthListner = new FirebaseAuth.AuthStateListener() {

        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            if (firebaseAuth.getCurrentUser() != null) {
                CurrentUserUtility currentUserUtility = new CurrentUserUtility();
                currentUserUtility.getCurrentPublicUser(new PublicUserListener() {

                    @Override
                    public void publicUserExists(Boolean userExists) {
                        Log.w("TAG", "login user exist" + userExists);
                        if (userExists) {
                            Log.w("TAG", "login user has profile" + userExists);
                            startActivity(new Intent(LoginActivity.this, UserProfileActivity.class));
                        } else {
                            Log.w("TAG", "login user does not have profile " + userExists);
                            startActivity(new Intent(LoginActivity.this, OnBoardActivity.class));
                        }
                    }
                });
                startActivity(new Intent(LoginActivity.this, OnBoardActivity.class));
            }
        }
    };
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    // Build a GoogleSignInClient with the options specified by gso.
    mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
}
Also used : Intent(android.content.Intent) View(android.view.View) PublicUserListener(com.example.c4q.capstone.utils.currentuser.PublicUserListener) CurrentUserUtility(com.example.c4q.capstone.utils.currentuser.CurrentUserUtility) OnBoardActivity(com.example.c4q.capstone.userinterface.user.onboarding.OnBoardActivity) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions) UserProfileActivity(com.example.c4q.capstone.userinterface.user.UserProfileActivity) FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 2 with CurrentUserUtility

use of com.example.c4q.capstone.utils.currentuser.CurrentUserUtility in project Grupp by tmoronta1208.

the class UserProfileActivity method pushEventInviteNotifications.

public void pushEventInviteNotifications() {
    final Context mContext = getApplicationContext();
    CurrentUserUtility currentUserUtility = new CurrentUserUtility();
    currentUserUtility.getSingleEventInviteList(CurrentUser.userID, new UserEventListener() {

        @Override
        public void getUserEventList(Map<String, UserEvent> userEventMap) {
            if (userEventMap != null) {
                Log.d(TAG, "notifications not null");
                for (String s : userEventMap.keySet()) {
                    String eventName = userEventMap.get(s).getEvent_name();
                    String userName = userEventMap.get(s).getEvent_organizer_full_name();
                    String title = userName;
                    String desc = "You're invited to " + eventName + "!";
                    new InviteNotifications(title, desc, getApplicationContext(), userEventMap.get(s).getEvent_id());
                }
            } else {
                Log.d(TAG, "notifications null");
            }
        }
    });
// 
}
Also used : Context(android.content.Context) CurrentUserUtility(com.example.c4q.capstone.utils.currentuser.CurrentUserUtility) UserEventListener(com.example.c4q.capstone.utils.currentuser.UserEventListener) InviteNotifications(com.example.c4q.capstone.userinterface.alerts.InviteNotifications) UserEvent(com.example.c4q.capstone.database.events.UserEvent)

Aggregations

CurrentUserUtility (com.example.c4q.capstone.utils.currentuser.CurrentUserUtility)2 Context (android.content.Context)1 Intent (android.content.Intent)1 View (android.view.View)1 UserEvent (com.example.c4q.capstone.database.events.UserEvent)1 InviteNotifications (com.example.c4q.capstone.userinterface.alerts.InviteNotifications)1 UserProfileActivity (com.example.c4q.capstone.userinterface.user.UserProfileActivity)1 OnBoardActivity (com.example.c4q.capstone.userinterface.user.onboarding.OnBoardActivity)1 PublicUserListener (com.example.c4q.capstone.utils.currentuser.PublicUserListener)1 UserEventListener (com.example.c4q.capstone.utils.currentuser.UserEventListener)1 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)1 FirebaseAuth (com.google.firebase.auth.FirebaseAuth)1