use of com.xinshang.audient.model.entities.Audient 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);
}
use of com.xinshang.audient.model.entities.Audient in project Audient by komamj.
the class PlaylistFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setLoadingIndicator(true);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (mPresenter != null) {
mPresenter.unSubscribe();
mPresenter.subscribe();
}
}
});
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent, R.color.colorPrimaryDark, R.color.colorPrimary);
mAdapter = new PlaylistAdapter(mContext);
mAdapter.setEventListener(new PlaylistAdapter.EventListener() {
@Override
public void onFavoriteMenuClick(Audient audient) {
Intent intent = new Intent(mContext, MyFavoritesActivity.class);
intent.putExtra(Constants.KEY_AUDIENT, audient);
mContext.startActivity(intent);
}
});
mRecyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new AudientItemDecoration(mContext));
mRecyclerView.setAdapter(mAdapter);
}
use of com.xinshang.audient.model.entities.Audient in project Audient by komamj.
the class SearchPresenter method loadSearchResults.
@Override
public void loadSearchResults(String keyword) {
LogUtils.i(TAG, "loadSearchResults :" + keyword);
mDisposables.clear();
if (isInvalid(keyword)) {
if (mView.isActive()) {
mView.showEmpty(true);
}
return;
}
if (mView != null) {
mView.showProgressBar(true);
}
Disposable disposable = mRepository.getSearchReult(keyword).map(new Function<SearchResult, List<Audient>>() {
@Override
public List<Audient> apply(SearchResult searchResult) throws Exception {
return searchResult.dataBean.audients;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Audient>>() {
@Override
public void onNext(List<Audient> audients) {
if (mView.isActive()) {
mView.showProgressBar(false);
mView.showAudients(audients);
mView.showEmpty(audients.isEmpty());
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadSearchResults error :" + t.toString());
if (mView.isActive()) {
mView.showProgressBar(false);
mView.showLoadingError();
}
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
use of com.xinshang.audient.model.entities.Audient in project Audient by komamj.
the class FavoriteDetailFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
LogUtils.i(TAG, "onViewCreated");
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (mPresenter != null) {
mPresenter.loadData(mFavorite.favoritesId);
}
}
});
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimaryDark, R.color.colorPrimary, R.color.colorAccent);
setLoadingIndicator(true);
mAdapter = new FavoritesSongAdapter(mContext);
mAdapter.setEventListener(new FavoritesSongAdapter.EventListener() {
@Override
public void onDeleteEventChanged(Favorite.FavoritesSong favoritesSong) {
if (mPresenter != null) {
mPresenter.deleteFavoriteSong(favoritesSong);
}
}
@Override
public void onPlaylistChanged(Audient audient) {
PaymentDialogFragment.show(getChildFragmentManager(), audient);
}
});
mRecyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new AudientItemDecoration(mContext));
mRecyclerView.setAdapter(mAdapter);
if (mPresenter != null) {
mPresenter.loadData(mFavorite.favoritesId);
}
}
use of com.xinshang.audient.model.entities.Audient in project Audient by komamj.
the class MinePresenter method loadDynamics.
@Override
public void loadDynamics() {
Disposable disposable = mRepository.getAudientTests().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<Audient>>() {
@Override
public void onNext(List<Audient> audients) {
if (mView.isActive()) {
mView.showUserProgressBar(false);
mView.showDynamics(audients);
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadDynamics error " + t.toString());
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
Aggregations