use of com.xinshang.audient.model.entities.StoreSong in project Audient by komamj.
the class PlaylistAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(PlaylistViewHolder holder, int position) {
StoreSong storePlaylist = mData.get(position);
mGlideRequest.load(storePlaylist).into(holder.mAlbum);
holder.mName.setText(storePlaylist.mediaName);
if (storePlaylist.isPlaying) {
holder.mName.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
} else {
holder.mName.setTextColor(mContext.getResources().getColor(R.color.colorPrimaryText));
}
holder.mArtistName.setText(storePlaylist.artistName);
}
use of com.xinshang.audient.model.entities.StoreSong in project Audient by komamj.
the class PlaylistPresenter method loadStorePlaylist.
@Override
public void loadStorePlaylist() {
String storeId = mRepository.getStoreId();
mRepository.getStorePlaylist(storeId).map(new Function<ApiResponse<List<StoreSong>>, List<StoreSong>>() {
@Override
public List<StoreSong> apply(ApiResponse<List<StoreSong>> listApiResponse) throws Exception {
return listApiResponse.data;
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<StoreSong>>() {
@Override
public void onNext(List<StoreSong> storePlaylists) {
mPlaylist = storePlaylists;
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadStorePlaylist error : " + t.getMessage());
if (mView.isActive()) {
mView.setLoadingIndicator(false);
}
}
@Override
public void onComplete() {
if (mView.isActive()) {
mView.setLoadingIndicator(false);
}
sendCommand(COMMAND_BIND);
}
});
}
use of com.xinshang.audient.model.entities.StoreSong in project Audient by komamj.
the class PlaylistPresenter method loadNowPlaying.
@Override
public void loadNowPlaying(String id) {
Disposable disposable = Flowable.just(id).flatMap(new Function<String, Publisher<List<StoreSong>>>() {
@Override
public Publisher<List<StoreSong>> apply(String s) throws Exception {
List<StoreSong> storePlaylists = new ArrayList<>();
for (StoreSong storePlaylist : mPlaylist) {
StoreSong playlist = new StoreSong();
playlist.id = storePlaylist.id;
playlist.mediaName = storePlaylist.mediaName;
playlist.mediaId = storePlaylist.mediaId;
playlist.storeId = storePlaylist.storeId;
playlist.albumId = storePlaylist.albumId;
playlist.albumName = storePlaylist.albumName;
playlist.artistId = storePlaylist.artistId;
playlist.artistName = storePlaylist.artistName;
playlist.demandId = storePlaylist.demandId;
playlist.demandTime = storePlaylist.demandTime;
playlist.mediaInterval = storePlaylist.mediaInterval;
playlist.mediaSource = storePlaylist.mediaSource;
playlist.joinedDate = storePlaylist.joinedDate;
playlist.userId = storePlaylist.userId;
if (TextUtils.equals(s, storePlaylist.id)) {
playlist.isPlaying = true;
mNowPlaying = storePlaylist;
} else {
playlist.isPlaying = false;
}
storePlaylists.add(playlist);
}
return Flowable.just(storePlaylists);
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new DisposableSubscriber<List<StoreSong>>() {
@Override
public void onNext(List<StoreSong> storePlaylists) {
if (mView.isActive()) {
mView.showNowPlaying(mNowPlaying);
mView.showPlaylist(storePlaylists);
}
}
@Override
public void onError(Throwable t) {
LogUtils.e(TAG, "loadNowPlaying error : " + t.getMessage());
}
@Override
public void onComplete() {
}
});
mDisposables.add(disposable);
}
Aggregations