Search in sources :

Example 1 with SongInfo

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;
    });
}
Also used : SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo) RetrofitHelper(com.lzx.nicemusic.network.RetrofitHelper) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) Consumer(io.reactivex.functions.Consumer) ArrayList(java.util.ArrayList) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) DataHelper(com.lzx.nicemusic.helper.DataHelper) JSONObject(org.json.JSONObject) LogUtil(com.lzx.musiclibrary.utils.LogUtil) Gson(com.google.gson.Gson) R(com.lzx.nicemusic.R) BasePresenter(com.lzx.nicemusic.base.mvp.factory.BasePresenter) Function(io.reactivex.functions.Function) SingerInfo(com.lzx.nicemusic.bean.SingerInfo) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) ResponseBody(okhttp3.ResponseBody) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 2 with SongInfo

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"));
    }
}
Also used : Bundle(android.os.Bundle) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 3 with SongInfo

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);
    });
}
Also used : SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 4 with SongInfo

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;
    });
}
Also used : SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo) AlbumInfo(com.lzx.musiclibrary.aidl.model.AlbumInfo) CommonRequest(com.ximalaya.ting.android.opensdk.datatrasfer.CommonRequest) HashMap(java.util.HashMap) RetrofitHelper(com.lzx.nicemusic.network.RetrofitHelper) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) ArrayList(java.util.ArrayList) RadioList(com.ximalaya.ting.android.opensdk.model.live.radio.RadioList) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) DataHelper(com.lzx.nicemusic.helper.DataHelper) DTransferConstants(com.ximalaya.ting.android.opensdk.constants.DTransferConstants) JSONObject(org.json.JSONObject) LogUtil(com.lzx.musiclibrary.utils.LogUtil) BasePresenter(com.lzx.nicemusic.base.mvp.factory.BasePresenter) Toast(android.widget.Toast) Map(java.util.Map) Radio(com.ximalaya.ting.android.opensdk.model.live.radio.Radio) Observable(io.reactivex.Observable) Schedulers(io.reactivex.schedulers.Schedulers) IDataCallBack(com.ximalaya.ting.android.opensdk.datatrasfer.IDataCallBack) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 5 with SongInfo

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);
    });
}
Also used : SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Aggregations

SongInfo (com.lzx.musiclibrary.aidl.model.SongInfo)31 ArrayList (java.util.ArrayList)9 AlbumInfo (com.lzx.musiclibrary.aidl.model.AlbumInfo)6 List (java.util.List)5 JSONObject (org.json.JSONObject)5 Uri (android.net.Uri)4 RetrofitHelper (com.lzx.nicemusic.network.RetrofitHelper)4 JSONArray (org.json.JSONArray)4 Cursor (android.database.Cursor)3 Gson (com.google.gson.Gson)3 LogUtil (com.lzx.musiclibrary.utils.LogUtil)3 BasePresenter (com.lzx.nicemusic.base.mvp.factory.BasePresenter)3 DataHelper (com.lzx.nicemusic.helper.DataHelper)3 Observable (io.reactivex.Observable)3 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)3 Disposable (io.reactivex.disposables.Disposable)3 Schedulers (io.reactivex.schedulers.Schedulers)3 Bitmap (android.graphics.Bitmap)2 AnimationDrawable (android.graphics.drawable.AnimationDrawable)2 Bundle (android.os.Bundle)2