Created
May 23, 2019 17:47
-
-
Save mitchtabian/a4ebd7583af804e951d03a20e606412b 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 LiveData<Resource<PlaylistContents>> observePlaylistData(String id) { | |
if (playlistContentsLiveData == null) { | |
playlistContentsLiveData = new MutableLiveData<>(); | |
playlistContentsLiveData.postValue(Resource.loading((PlaylistContents) null)); | |
apiService.getPlaylistContents(CharParser.removeEmptySpaces(id)) | |
.subscribeOn(Schedulers.io()) | |
.subscribe(data -> playlistContentsLiveData.postValue(Resource.success(data)), | |
e -> playlistContentsLiveData.postValue(Resource.error(e.getMessage(), (PlaylistContents) null))); | |
} | |
return playlistContentsLiveData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment