use of se.zinokader.spotiq.feature.search.preview.PreviewPlayer in project SpotiQ by ZinoKader.
the class PlaylistSearchPresenter method onCreate.
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
songPreviewPlayer = new PreviewPlayer();
restartableLatestCache(LOAD_USER_RESTARTABLE_ID, () -> spotifyRepository.getMe(spotifyCommunicatorService.getWebApi()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS)), (lobbyView, userPrivate) -> {
user = new User(userPrivate.id, userPrivate.display_name, userPrivate.images);
}, (lobbyView, throwable) -> {
Log.d(LogTag.LOG_SEARCH, "Error when getting user Spotify data");
});
restartableReplay(LOAD_PLAYLISTS_RESTARTABLE_ID, () -> getUserPlaylists().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()), (playlistSearchView, playlistSimplePager) -> {
playlistSearchView.updatePlaylists(playlistSimplePager.items);
}, (playlistSearchView, throwable) -> {
Log.d(LogTag.LOG_SEARCH, "Error when getting user Spotify data");
});
if (savedState == null) {
start(LOAD_USER_RESTARTABLE_ID);
start(LOAD_PLAYLISTS_RESTARTABLE_ID);
}
}
use of se.zinokader.spotiq.feature.search.preview.PreviewPlayer in project SpotiQ by ZinoKader.
the class SongSearchPresenter method onCreate.
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
songPreviewPlayer = new PreviewPlayer();
// load user data and user search suggestions
restartableLatestCache(LOAD_USER_RESTARTABLE_ID, () -> spotifyRepository.getMe(spotifyCommunicatorService.getWebApi()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS)), (songSearchView, userPrivate) -> {
user = new User(userPrivate.id, userPrivate.display_name, userPrivate.images);
// load personalized search suggestions
Map<String, Object> searchOptions = new HashMap<>();
searchOptions.put(SpotifyService.LIMIT, SpotifyConstants.TOP_TRACKS_QUERY_RESPONSE_LIMIT);
searchOptions.put(SpotifyService.TIME_RANGE, SpotifyConstants.TIME_RANGE_SHORT);
spotifyRepository.getMyTopTracks(searchOptions, spotifyCommunicatorService.getWebApi()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).retryWhen(throwable -> throwable.delay(ApplicationConstants.REQUEST_RETRY_DELAY_SEC, TimeUnit.SECONDS)).subscribe(tracks -> {
List<Song> songSuggestions = TrackMapper.tracksToSongs(tracks, user);
SongSearchSuggestionsBuilder suggestionsBuilder = new SongSearchSuggestionsBuilder(songSuggestions, ApplicationConstants.MAX_SONG_SUGGESTIONS);
songSearchView.updateSearchSuggestions(suggestionsBuilder);
});
}, (songSearchView, throwable) -> {
Log.d(LogTag.LOG_SEARCH, "Error when getting user Spotify data");
});
if (savedState == null) {
start(LOAD_USER_RESTARTABLE_ID);
}
}
Aggregations