Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Repository {
- fun firebaseAuthWithGoogle(idToken: String,callback: AuthCallback)
- }
- interface AuthCallback {
- fun onSuccess()
- fun onError(error: String)
- }
- class RepositoryImpl(auth: FirebaseAuth) : Repository {
- override fun firebaseAuthWithGoogle(idToken: String,callback: AuthCallback) {
- auth.singInWithCredential().addOnCompleteListener() { task ->
- if (task.isSuccessful) {
- callback.onSuccess()
- } else {
- callback.onError(error: String)
- }
- }
- }
- }
- interface Interactor {
- fun firebaseAuthWithGoogle(idToken: String,callback: AuthCallback)
- }
- class InteractorImpl(private val repository: Repository) : Interactor {
- override fun firebaseAuthWithGoogle(idToken: String,callback: AuthCallback) {
- repository. firebaseAuthWithGoogle(idToken,callback)
- }
- }
- class MainViewModel(private val interactor: Interactor) {
- fun firebaseAuthWithGoogle(idToken: String,callback: AuthCallback) {
- interactor.firebaseAuthWithGoogle(idToken,callback)
- }
- }
- class MainActivity {
- mainViewModel. firebaseAuthWithGoogle("token",object : AuthCalback {
- override fun onSuccess() {
- toast.show()
- }
- override fun onError() {
- toast.show()
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement