I'm using MVVM structure with Data Binding in my project. Things get weird when it comes to GG/FB Sign In, because they need Context
googleApiClient = new GoogleApiClient.Builder(context)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
startActivityForResult(signInIntent, GOOGLE_AUTH);
GoogleApiClient needs Context so I can't pass it to ViewModel, which receives DataBinding events.
class LoginViewModel(
dataManager: DataManager,
schedulerProvider: SchedulerProvider
) : BaseViewModel<LoginNavigator>(dataManager, schedulerProvider) {
fun loginGoogle(){
setIsLoading(true)
//No idea what to write in here
}
}
Is there any way to use Gg/FB Sign In with MVVM structure ? Or I just have to do the original way (do everything in Activity) ?