Search in sources :

Example 16 with SongInfo

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

Example 17 with SongInfo

use of com.lzx.musiclibrary.aidl.model.SongInfo in project MusicLibrary by lizixian18.

the class PlayController method playMusicByIndex.

void playMusicByIndex(int index, boolean isJustPlay) {
    if (mQueueManager.getPlayingQueue().size() == 0) {
        return;
    }
    if (!QueueHelper.isIndexPlayable(index, mQueueManager.getPlayingQueue())) {
        return;
    }
    SongInfo playInfo = mQueueManager.getPlayingQueue().get(index);
    setCurrentQueueItem(playInfo, isJustPlay);
}
Also used : SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 18 with SongInfo

use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.

the class DialogMusicListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ItemHolder holder, int position) {
    SongInfo info = mMusicInfos.get(position);
    holder.mMusicTitle.setText(info.getSongName() + "(" + info.getAlbumInfo().getAlbumName() + ")" + " - " + info.getArtist());
    AnimationDrawable animationDrawable = (AnimationDrawable) holder.mImageAnim.getDrawable();
    if (MusicManager.isCurrMusicIsPlayingMusic(info)) {
        holder.mMusicTitle.setTextColor(Color.parseColor("#BE0D36"));
        holder.mImageAnim.setVisibility(View.VISIBLE);
        if (MusicManager.isPlaying()) {
            animationDrawable.start();
        } else {
            animationDrawable.stop();
        }
    } else {
        holder.mMusicTitle.setTextColor(ContextCompat.getColor(mContext, R.color.font_color));
        animationDrawable.stop();
        holder.mImageAnim.setVisibility(View.INVISIBLE);
    }
    holder.mBtnDelete.setOnClickListener(v -> {
        mDbManager.asyDeleteInfoInPlayList(info).subscribe(aBoolean -> {
            boolean isPlayNext = MusicManager.isCurrMusicIsPlayingMusic(info);
            MusicManager.get().deleteSongInfoOnPlayList(info, isPlayNext);
            mMusicInfos.remove(info);
            notifyItemRemoved(position);
            if (position != mMusicInfos.size()) {
                notifyItemRangeChanged(position, mMusicInfos.size() - position);
            }
            if (mMusicInfos.size() == 0) {
                mContext.sendBroadcast(new Intent(Constans.ACTION_STOP_MUSIC));
            }
        }, throwable -> {
            Toast.makeText(mContext, "删除失败", Toast.LENGTH_SHORT).show();
        });
    });
    holder.itemView.setOnClickListener(v -> {
        SpUtil.getInstance().putString(Constans.LAST_PLAYING_MUSIC, info.getSongId());
        MusicManager.get().playMusicByInfo(info);
    });
}
Also used : AnimationDrawable(android.graphics.drawable.AnimationDrawable) Intent(android.content.Intent) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo)

Example 19 with SongInfo

use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.

the class DbManager method queryPlayList.

/**
 * 获取播放列表
 *
 * @return
 */
private List<SongInfo> queryPlayList() {
    Uri uri = MusicContentProvider.SONG_LIST_URI;
    Cursor cursor = mResolver.query(uri, null, null, null, null);
    if (cursor == null) {
        return new ArrayList<>();
    }
    List<SongInfo> musicInfos = new ArrayList<>();
    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));
        SongInfo info = new SongInfo();
        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);
        musicInfos.add(info);
    }
    cursor.close();
    return musicInfos;
}
Also used : AlbumInfo(com.lzx.musiclibrary.aidl.model.AlbumInfo) ArrayList(java.util.ArrayList) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo) Cursor(android.database.Cursor) Uri(android.net.Uri)

Example 20 with SongInfo

use of com.lzx.musiclibrary.aidl.model.SongInfo in project NiceMusic by lizixian18.

the class DbManager method savePlayList.

/**
 * 保存播放列表
 *
 * @param list
 */
private void savePlayList(List<SongInfo> list) {
    clearPlayList();
    Uri uri = MusicContentProvider.SONG_LIST_URI;
    for (SongInfo info : list) {
        if (info.getAlbumInfo() == null) {
            throw new RuntimeException("albumInfo must not be null.");
        }
        ContentValues values = new ContentValues();
        values.put(DbConstants.MUSIC_ID, info.getSongId());
        values.put(DbConstants.ARTIST, info.getArtist());
        values.put(DbConstants.MUSIC_TITLE, info.getSongName());
        values.put(DbConstants.ALBUM_TITLE, info.getAlbumInfo().getAlbumName());
        values.put(DbConstants.DURATION, info.getDuration());
        values.put(DbConstants.COVER, info.getSongCover());
        values.put(DbConstants.URL, info.getSongUrl());
        mResolver.insert(uri, values);
    }
}
Also used : ContentValues(android.content.ContentValues) SongInfo(com.lzx.musiclibrary.aidl.model.SongInfo) Uri(android.net.Uri)

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