use of com.xinshang.audient.model.entities.LyricResult in project Audient by komamj.
the class NowPlayingPresenter method loadNowPlaying.
@Override
public void loadNowPlaying() {
mDisposables.clear();
Disposable disposable = mRepository.getNowPlayingResult().map(new Function<NowPlayingResponse, Audient>() {
@Override
public Audient apply(NowPlayingResponse nowPlayingResult) throws Exception {
return nowPlayingResult.audient;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).doOnNext(new Consumer<Audient>() {
@Override
public void accept(Audient audient) throws Exception {
if (mView.isActive()) {
mView.showNowPlaying(audient);
}
}
}).observeOn(Schedulers.io()).flatMap(new Function<Audient, Publisher<Lyric>>() {
@Override
public Publisher<Lyric> apply(Audient audient) throws Exception {
return mRepository.getLyricResult(audient.mediaId).map(new Function<LyricResult, Lyric>() {
@Override
public Lyric apply(LyricResult lyricResult) throws Exception {
return lyricResult.lyric;
}
});
}
}).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<Lyric>() {
@Override
public void onNext(Lyric lyric) {
if (mView.isActive()) {
mView.showLyric(lyric);
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadNowPlaying error :" + t.toString());
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
Aggregations