Search in sources :

Example 1 with Playlist

use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.

the class NeteaseMusicListActivity method showAddPlaylistDialog.

@Override
public void showAddPlaylistDialog(List<Playlist> playlists, Music music) {
    if (playlists == null) {
        ToastUtils.show("暂无歌单");
        return;
    }
    new MaterialDialog.Builder(this).title("增加到歌单").items(playlists).itemsCallback((dialog, itemView, which, text) -> {
        Playlist playlist = playlists.get(which);
        Log.d("addDialog", which + "----" + playlists.get(which).getId() + "------" + music.getId());
        mPresenter.collectMusic(playlist.getId(), music);
    }).build().show();
}
Also used : Playlist(com.cyl.musiclake.bean.Playlist) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog)

Example 2 with Playlist

use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.

the class DBDaoImpl method getAllPlaylistForCursor.

@Override
public List<Playlist> getAllPlaylistForCursor(Cursor cursor) {
    List<Playlist> results = new ArrayList<>();
    // 再遍历游标cursor,获取数据库中的值
    LogUtil.d(TAG, cursor.getCount() + "----");
    if (cursor.getCount() > 0) {
        while (cursor.moveToNext()) {
            Playlist playlist = new MusicCursorWrapper(cursor).getPlaylist();
            LogUtil.d(TAG, playlist.toString() + "----");
            results.add(playlist);
        }
    }
    // 记得关闭游标
    cursor.close();
    return results;
}
Also used : Playlist(com.cyl.musiclake.bean.Playlist) ArrayList(java.util.ArrayList)

Example 3 with Playlist

use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.

the class PlaylistDetailFragment method onOptionsItemSelected.

@SuppressLint("ResourceAsColor")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch(id) {
        case R.id.action_delete_playlist:
            new MaterialDialog.Builder(getContext()).title("提示").content("是否删除这个歌单?").onPositive((dialog, which) -> {
                mPresenter.deletePlaylist(mPlaylist);
            // PlaylistLoader.deletePlaylist(getActivity(), mPlaylist.getId());
            // RxBus.getInstance().post(new Playlist());
            // onBackPress();
            }).positiveText("确定").negativeText("取消").show();
            break;
        case R.id.action_rename_playlist:
            new MaterialDialog.Builder(getActivity()).title("重命名歌单").positiveText("确定").negativeText("取消").inputRangeRes(2, 10, R.color.red).inputType(InputType.TYPE_CLASS_TEXT).input("输入歌单名", mPlaylist.getName(), false, (dialog, input) -> Log.e("=====", input.toString())).onPositive((dialog, which) -> {
                String title = dialog.getInputEditText().getText().toString();
                mPresenter.renamePlaylist(mPlaylist, title);
            }).positiveText("确定").negativeText("取消").show();
            break;
        case R.id.action_share:
            Intent intent3 = new Intent(getActivity(), EditActivity.class);
            StringBuilder content = new StringBuilder();
            if (musicList.size() > 0) {
                content = new StringBuilder("分享歌单\n");
            }
            for (int i = 0; i < musicList.size(); i++) {
                content.append(musicList.get(i).getTitle()).append("---").append(musicList.get(i).getArtist());
                content.append("\n");
            }
            intent3.putExtra("content", content.toString());
            startActivity(intent3);
            break;
        case R.id.action_add:
            List<String> titles = new ArrayList<>();
            List<Music> addMusicList = SongLoader.getSongsForDB(getContext());
            for (Music music : addMusicList) {
                titles.add(music.getTitle() + "-" + music.getArtist());
            }
            new MaterialDialog.Builder(getActivity()).title("新增歌曲").iconRes(R.drawable.ic_playlist_add).content("快速添加歌曲,更加方便地添加所需要的歌曲到当前目录").positiveText("确定").items(titles).itemsCallbackMultiChoice(null, (dialog, which, text) -> false).onPositive((dialog, which) -> {
                dialog.dismiss();
                int sum = dialog.getSelectedIndices().length, num = 0;
                for (int i = 0; i < sum; i++) {
                    int index = dialog.getSelectedIndices()[i];
                    boolean success = PlaylistLoader.addToPlaylist(getContext(), mPlaylist.getId(), addMusicList.get(index).getId());
                    if (success) {
                        num++;
                    }
                }
                mPresenter.loadPlaylistSongs(mPlaylist.getId());
                mPresenter.loadPlaylistArt(mPlaylist.getId());
                ToastUtils.show(getContext(), num + "首添加成功," + (sum - num) + "首已存在此歌单添加失败");
                RxBus.getInstance().post(new Playlist());
            }).show();
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Bundle(android.os.Bundle) R(com.cyl.musiclake.R) EditActivity(com.cyl.musiclake.ui.zone.EditActivity) Playlist(com.cyl.musiclake.bean.Playlist) ImageView(android.widget.ImageView) Intent(android.content.Intent) Drawable(android.graphics.drawable.Drawable) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) SongLoader(com.cyl.musiclake.data.source.SongLoader) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) SuppressLint(android.annotation.SuppressLint) BaseFragment(com.cyl.musiclake.base.BaseFragment) ToastUtils(com.cyl.musiclake.utils.ToastUtils) MenuInflater(android.view.MenuInflater) PopupMenu(android.widget.PopupMenu) PlaylistLoader(com.cyl.musiclake.data.source.PlaylistLoader) Menu(android.view.Menu) SongAdapter(com.cyl.musiclake.ui.music.local.adapter.SongAdapter) Build(android.os.Build) Log(android.util.Log) PlayManager(com.cyl.musiclake.service.PlayManager) Extras(com.cyl.musiclake.common.Extras) Music(com.cyl.musiclake.bean.Music) FloatingActionButton(android.support.design.widget.FloatingActionButton) PlaylistDetailContract(com.cyl.musiclake.ui.music.local.contract.PlaylistDetailContract) AddPlaylistDialog(com.cyl.musiclake.ui.music.local.dialog.AddPlaylistDialog) InputType(android.text.InputType) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AppCompatActivity(android.support.v7.app.AppCompatActivity) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) Toolbar(android.support.v7.widget.Toolbar) Bitmap(android.graphics.Bitmap) ShowDetailDialog(com.cyl.musiclake.ui.music.local.dialog.ShowDetailDialog) PlaylistDetailPresenter(com.cyl.musiclake.ui.music.local.presenter.PlaylistDetailPresenter) RxBus(com.cyl.musiclake.RxBus) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Playlist(com.cyl.musiclake.bean.Playlist) Music(com.cyl.musiclake.bean.Music) ArrayList(java.util.ArrayList) Intent(android.content.Intent) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 4 with Playlist

use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.

the class PlaylistFragment method updateView.

/**
 * 异步刷新数据
 */
public void updateView(final long id) {
    final List<Playlist> playlists = PlaylistLoader.getPlaylist(getActivity());
    mAdapter.notifyDataSetChanged();
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < playlists.size(); i++) {
                long playlistid = Long.parseLong(playlists.get(i).getId());
                if (playlistid == id) {
                    mMultiViewPager.setCurrentItem(i);
                    break;
                }
            }
        }
    }, 200);
}
Also used : Playlist(com.cyl.musiclake.bean.Playlist) Handler(android.os.Handler)

Example 5 with Playlist

use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.

the class SearchActivity method showAddPlaylistDialog.

@Override
public void showAddPlaylistDialog(List<Playlist> playlists, Music music) {
    if (playlists == null) {
        new MaterialDialog.Builder(this).title("增加到歌单").content("暂无歌单").build().show();
        return;
    }
    new MaterialDialog.Builder(this).title("增加到歌单").items(playlists).itemsCallback((dialog, itemView, which, text) -> {
        Playlist playlist = playlists.get(which);
        Log.d("addDialog", which + "----" + playlists.get(which).getId() + "------" + music.getId());
        mPresenter.collectMusic(playlist.getId(), music);
    }).build().show();
}
Also used : Playlist(com.cyl.musiclake.bean.Playlist) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog)

Aggregations

Playlist (com.cyl.musiclake.bean.Playlist)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Bundle (android.os.Bundle)2 Log (android.util.Log)2 RxBus (com.cyl.musiclake.RxBus)2 Music (com.cyl.musiclake.bean.Music)2 PlaylistLoader (com.cyl.musiclake.data.source.PlaylistLoader)2 ToastUtils (com.cyl.musiclake.utils.ToastUtils)2 List (java.util.List)2 SuppressLint (android.annotation.SuppressLint)1 Dialog (android.app.Dialog)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 Build (android.os.Build)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 DialogFragment (android.support.v4.app.DialogFragment)1