Created
June 13, 2019 16:19
-
-
Save mitchtabian/431861cc4c0c75ff08c4c781077d5008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void authenticateWithId(final LiveData<AuthResource<User>> source) { | |
if(cachedUser != null){ | |
cachedUser.setValue(AuthResource.loading((User)null)); | |
cachedUser.addSource(source, new Observer<AuthResource<User>>() { | |
@Override | |
public void onChanged(AuthResource<User> userAuthResource) { | |
cachedUser.setValue(userAuthResource); | |
cachedUser.removeSource(source); | |
if(userAuthResource.status.equals(AuthResource.AuthStatus.ERROR)){ | |
cachedUser.setValue(AuthResource.<User>logout()); | |
} | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment