Skip to content

Instantly share code, notes, and snippets.

@learntodroid
Created September 24, 2020 05:53
package com.learntodroid.firebaseauthloginregistermvvm.viewmodel;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import com.google.firebase.auth.FirebaseUser;
import com.learntodroid.firebaseauthloginregistermvvm.model.AuthAppRepository;
public class LoggedInViewModel extends AndroidViewModel {
private AuthAppRepository authAppRepository;
private MutableLiveData<FirebaseUser> userLiveData;
private MutableLiveData<Boolean> loggedOutLiveData;
public LoggedInViewModel(@NonNull Application application) {
super(application);
authAppRepository = new AuthAppRepository(application);
userLiveData = authAppRepository.getUserLiveData();
loggedOutLiveData = authAppRepository.getLoggedOutLiveData();
}
public void logOut() {
authAppRepository.logOut();
}
public MutableLiveData<FirebaseUser> getUserLiveData() {
return userLiveData;
}
public MutableLiveData<Boolean> getLoggedOutLiveData() {
return loggedOutLiveData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment