use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class ArtistPresenter method getSongList.
private Observable<List<SongInfo>> getSongList(String artistId) {
return RetrofitHelper.getMusicApi().requestArtistSongList(artistId, 20).map(responseBody -> {
List<SongInfo> list = DataHelper.fetchArtistJSONFromUrl(responseBody);
List<SongInfo> newList = new ArrayList<>();
for (SongInfo info : list) {
RetrofitHelper.getMusicApi().playMusic(info.getSongId()).map(responseUrlBody -> {
String json = responseUrlBody.string();
json = json.substring(1, json.length() - 2);
JSONObject jsonObject = new JSONObject(json);
JSONObject bitrate = jsonObject.getJSONObject("bitrate");
return bitrate.getString("file_link");
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(url -> {
info.setSongUrl(url);
newList.add(info);
}, throwable -> {
LogUtil.i("1error = " + throwable.getMessage());
});
}
return newList;
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class HomeActivity method getNotificationIntentData.
/**
* 示例:
* 获取点击通知栏传递过来的信息
*/
private void getNotificationIntentData(Intent intent) {
SongInfo songInfo = intent.getParcelableExtra("songInfo");
if (songInfo != null) {
LogUtil.i("songInfo = " + songInfo.getSongName());
}
Bundle bundle = intent.getBundleExtra("bundleInfo");
if (bundle != null) {
LogUtil.i("bundle = " + bundle.getString("name"));
}
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class ChartTopAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ChartHolder holder, int position) {
SongInfo info = mSongInfos.get(position);
GlideUtil.loadImageByUrl(mContext, info.getSongCover(), holder.mMusicCover);
holder.mMusicName.setText(info.getSongName());
holder.mSongerName.setText(info.getArtist());
holder.mMusicCover.setOnClickListener(v -> {
ArtistDetailActivity.launch(mContext, info);
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class SongListPresenter method getSongList.
private Observable<List<SongInfo>> getSongList(String title) {
int type = getListType(title);
return RetrofitHelper.getMusicApi().requestMusicList(type, size, offset).map(responseBody -> {
List<SongInfo> list = DataHelper.fetchJSONFromUrl(responseBody);
List<SongInfo> newList = new ArrayList<>();
for (SongInfo info : list) {
RetrofitHelper.getMusicApi().playMusic(info.getSongId()).map(responseUrlBody -> {
String json = responseUrlBody.string();
json = json.substring(1, json.length() - 2);
JSONObject jsonObject = new JSONObject(json);
JSONObject bitrate = jsonObject.getJSONObject("bitrate");
return bitrate.getString("file_link");
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(url -> {
info.setSongUrl(url);
newList.add(info);
}, throwable -> {
LogUtil.i("1error = " + throwable.getMessage());
});
}
return newList;
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class HomeSongSection method onBindItemViewHolder.
@Override
public void onBindItemViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
SongHolder holder = (SongHolder) viewHolder;
SongInfo info = mSongInfos.get(position);
GlideUtil.loadImageByUrl(mContext, info.getSongCover(), holder.mMusicCover);
holder.mSongName.setText(info.getSongName());
holder.mArtistName.setText(info.getArtist());
holder.itemView.setOnClickListener(v -> {
ArtistDetailActivity.launch(mContext, info);
});
}
Aggregations