use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class DbManager method querySongInfoById.
/**
* 获取一条音乐信息
*/
private SongInfo querySongInfoById(String songId) {
Uri uri = MusicContentProvider.SONG_LIST_URI;
Cursor cursor = mResolver.query(uri, null, DbConstants.MUSIC_ID + " = ?", new String[] { songId }, null);
if (cursor == null) {
return null;
}
SongInfo info = new SongInfo();
while (cursor.moveToNext()) {
String musicId = cursor.getString(cursor.getColumnIndex(DbConstants.MUSIC_ID));
String artist = cursor.getString(cursor.getColumnIndex(DbConstants.ARTIST));
String musicTitle = cursor.getString(cursor.getColumnIndex(DbConstants.MUSIC_TITLE));
String albumTitle = cursor.getString(cursor.getColumnIndex(DbConstants.ALBUM_TITLE));
long duration = cursor.getLong(cursor.getColumnIndex(DbConstants.DURATION));
String cover = cursor.getString(cursor.getColumnIndex(DbConstants.COVER));
String url = cursor.getString(cursor.getColumnIndex(DbConstants.URL));
info.setSongId(musicId);
info.setArtist(artist);
info.setSongName(musicTitle);
info.setDuration(duration);
info.setSongCover(cover);
info.setSongUrl(url);
AlbumInfo albumInfo = new AlbumInfo();
albumInfo.setAlbumName(albumTitle);
info.setAlbumInfo(albumInfo);
}
cursor.close();
return info;
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class DataHelper method fetchArtistJSONFromUrl.
public static List<SongInfo> fetchArtistJSONFromUrl(ResponseBody responseBody) throws IOException, JSONException {
List<SongInfo> musicInfos = new ArrayList<>();
JSONObject jsonObject = new JSONObject(responseBody.string());
JSONArray array = jsonObject.getJSONArray("songlist");
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
SongInfo info = getSongInfo(null, object, i);
musicInfos.add(info);
}
return musicInfos;
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class MainModel method loadMainData.
/**
* 1、新歌榜,2、热歌榜,11、摇滚榜,12、爵士,16、流行,
* 21、欧美金曲榜,22、经典老歌榜,23、情歌对唱榜,
* 24、影视金曲榜,25、网络歌曲榜
*
* @return
*/
public Observable<List<SongInfo>> loadMainData() {
List<SongInfo> infoList = new ArrayList<>();
return RetrofitHelper.getMusicApi().requestMusicList(1, 4, 0).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(2, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(11, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(12, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(16, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(21, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(22, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(23, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(24, 4, 0);
}).flatMap(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
return RetrofitHelper.getMusicApi().requestMusicList(25, 4, 0);
}).map(responseBody -> {
infoList.addAll(DataHelper.fetchJSONFromUrl(responseBody));
String json = new Gson().toJson(infoList);
// CacheManager.getImpl().saveCache(CacheManager.KEY_HOME_LIST_DATA, json);
return infoList;
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class SongListPresenter method requestLiveList.
@Override
public void requestLiveList(String title) {
int mRadioType = 2;
int mProvinceCode = 360000;
Map<String, String> map = new HashMap<String, String>();
map.put(DTransferConstants.RADIOTYPE, "" + mRadioType);
map.put(DTransferConstants.PROVINCECODE, "" + mProvinceCode);
CommonRequest.getRadios(map, new IDataCallBack<RadioList>() {
@Override
public void onSuccess(RadioList object) {
if (object != null && object.getRadios() != null) {
List<SongInfo> musicInfos = new ArrayList<>();
for (int i = 0; i < object.getRadios().size(); i++) {
Radio radio = object.getRadios().get(i);
SongInfo info = new SongInfo();
// 音乐id
info.setSongId(String.valueOf(radio.getDataId()));
// 音乐标题
info.setSongName(radio.getRadioName());
// 音乐封面
info.setSongCover(radio.getCoverUrlLarge());
// 音乐播放地址
info.setSongUrl(radio.getRate64AacUrl());
// 类型(流派)
info.setGenre(radio.getKind());
// 类型
info.setType(radio.getKind());
// 音乐大小
info.setSize("");
// 音乐长度
info.setDuration(0);
// 音乐艺术家
info.setArtist(radio.getRadioName());
// 媒体的曲目号码(序号:1234567……)
info.setTrackNumber(i);
AlbumInfo albumInfo = new AlbumInfo();
// 专辑id
albumInfo.setAlbumId(String.valueOf(radio.getDataId()));
// 专辑名称
albumInfo.setAlbumName(radio.getProgramName());
// 专辑封面
albumInfo.setAlbumCover(radio.getCoverUrlLarge());
// 专辑音乐数
albumInfo.setSongCount(0);
// 专辑播放数
albumInfo.setPlayCount(0);
info.setAlbumInfo(albumInfo);
musicInfos.add(info);
}
mView.onGetSongListSuccess(musicInfos, title);
mView.onGetLiveSongSuccess(musicInfos);
}
}
@Override
public void onError(int code, String message) {
LogUtil.i("直播 = " + message);
Toast.makeText(mContext, "获取直播数据失败", Toast.LENGTH_SHORT).show();
}
});
}
use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.
the class QueueManager method updateSongCoverBitmap.
/**
* 更新音乐艺术家信息
*
* @param musicId
* @param bitmap
* @param icon
*/
public void updateSongCoverBitmap(String musicId, Bitmap bitmap, Bitmap icon) {
SongInfo musicInfo = QueueHelper.getMusicInfoById(mPlayingQueue, musicId);
if (musicInfo == null) {
return;
}
musicInfo.setSongCoverBitmap(bitmap);
int index = mPlayingQueue.indexOf(musicInfo);
mPlayingQueue.set(index, musicInfo);
}
Aggregations