Search in sources :

Example 1 with Music

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

the class LoveFragment method listener.

@Override
protected void listener() {
    mAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (view.getId() != R.id.iv_more) {
            PlayManager.setPlayList(musicInfos);
            PlayManager.play(position);
        }
    });
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
        PopupMenu popupMenu = new PopupMenu(getContext(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            switch(item.getItemId()) {
                case R.id.popup_song_play:
                    PlayManager.setPlayList(musicInfos);
                    PlayManager.play(position);
                    break;
                case R.id.popup_song_detail:
                    ShowDetailDialog.newInstance((Music) adapter.getItem(position)).show(getChildFragmentManager(), getTag());
                    break;
                case R.id.popup_song_addto_queue:
                    AddPlaylistDialog.newInstance(musicInfos.get(position)).show(getChildFragmentManager(), "ADD_PLAYLIST");
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_album);
        popupMenu.show();
    });
}
Also used : Music(com.cyl.musiclake.bean.Music) PopupMenu(android.support.v7.widget.PopupMenu)

Example 2 with Music

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

the class PlaylistDetailFragment method listener.

@Override
protected void listener() {
    mAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (view.getId() != R.id.iv_more) {
            PlayManager.setPlayList(musicList);
            PlayManager.play(position);
        }
    });
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
        PopupMenu popupMenu = new PopupMenu(getContext(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            switch(item.getItemId()) {
                case R.id.popup_song_play:
                    PlayManager.setPlayList(musicList);
                    PlayManager.play(position);
                    break;
                case R.id.popup_song_detail:
                    ShowDetailDialog.newInstance((Music) adapter.getItem(position)).show(getChildFragmentManager(), getTag());
                    break;
                case R.id.popup_song_addto_queue:
                    AddPlaylistDialog.newInstance(musicList.get(position)).show(getChildFragmentManager(), "ADD_PLAYLIST");
                    break;
                case R.id.popup_song_delete:
                    new MaterialDialog.Builder(getContext()).title("提示").content("是否移除这首歌曲?").onPositive((dialog, which) -> {
                        mPresenter.uncollectMusic(mPlaylist.getId(), position, musicList.get(position));
                    // PlaylistLoader.removeSong(getActivity(), mPlaylist.getId(), musicList.get(position).getId());
                    // mAdapter.notifyItemChanged(position);
                    }).positiveText("确定").negativeText("取消").show();
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_playlist);
        popupMenu.show();
    });
}
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) Music(com.cyl.musiclake.bean.Music) PopupMenu(android.widget.PopupMenu)

Example 3 with Music

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

the class RecentlyFragment method listener.

@Override
protected void listener() {
    mAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (view.getId() != R.id.iv_more) {
            PlayManager.setPlayList(musicInfos);
            PlayManager.play(position);
        }
    });
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
        PopupMenu popupMenu = new PopupMenu(getContext(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            switch(item.getItemId()) {
                case R.id.popup_song_play:
                    PlayManager.setPlayList(musicInfos);
                    PlayManager.play(position);
                    break;
                case R.id.popup_song_detail:
                    ShowDetailDialog.newInstance((Music) adapter.getItem(position)).show(getChildFragmentManager(), getTag());
                    break;
                case R.id.popup_song_addto_queue:
                    AddPlaylistDialog.newInstance(musicInfos.get(position)).show(getChildFragmentManager(), "ADD_PLAYLIST");
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_album);
        popupMenu.show();
    });
}
Also used : Music(com.cyl.musiclake.bean.Music) PopupMenu(android.support.v7.widget.PopupMenu)

Example 4 with Music

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

the class SongsFragment method listener.

@Override
protected void listener() {
    mAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (view.getId() != R.id.iv_more) {
            mPresenter.playMusic(musicList, position);
        }
    });
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
        Music music = (Music) adapter.getItem(position);
        PopupMenu popupMenu = new PopupMenu(getContext(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            switch(item.getItemId()) {
                case R.id.popup_song_play:
                    mPresenter.playMusic(musicList, position);
                    break;
                case R.id.popup_song_detail:
                    ShowDetailDialog.newInstance((Music) adapter.getItem(position)).show(getChildFragmentManager(), getTag());
                    break;
                case R.id.popup_song_goto_album:
                    Log.e("album", music.toString() + "");
                    NavigateUtil.navigateToAlbum(getActivity(), music.getAlbumId(), music.getAlbum(), null);
                    break;
                case R.id.popup_song_goto_artist:
                    NavigateUtil.navigateToArtist(getActivity(), music.getArtistId(), music.getArtist(), null);
                    break;
                case R.id.popup_song_addto_queue:
                    AddPlaylistDialog.newInstance(music).show(getChildFragmentManager(), "ADD_PLAYLIST");
                    break;
                case R.id.popup_song_delete:
                    new MaterialDialog.Builder(getContext()).title("警告").content("是否删除这首歌曲?").onPositive((dialog, which) -> {
                        FileUtils.delFile(musicList.get(position).getUri());
                        SongLoader.removeSong(getActivity(), musicList.get(position));
                        musicList.remove(position);
                        mAdapter.notifyItemChanged(position);
                    }).positiveText("确定").negativeText("取消").show();
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_song);
        popupMenu.show();
    });
}
Also used : Extras(com.cyl.musiclake.common.Extras) NavigateUtil(com.cyl.musiclake.common.NavigateUtil) Bundle(android.os.Bundle) Music(com.cyl.musiclake.bean.Music) FileUtils(com.cyl.musiclake.utils.FileUtils) R(com.cyl.musiclake.R) AddPlaylistDialog(com.cyl.musiclake.ui.music.local.dialog.AddPlaylistDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SongLoader(com.cyl.musiclake.data.source.SongLoader) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) BaseFragment(com.cyl.musiclake.base.BaseFragment) SongsContract(com.cyl.musiclake.ui.music.local.contract.SongsContract) PopupMenu(android.widget.PopupMenu) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) ShowDetailDialog(com.cyl.musiclake.ui.music.local.dialog.ShowDetailDialog) SongAdapter(com.cyl.musiclake.ui.music.local.adapter.SongAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Log(android.util.Log) SongsPresenter(com.cyl.musiclake.ui.music.local.presenter.SongsPresenter) Music(com.cyl.musiclake.bean.Music) PopupMenu(android.widget.PopupMenu)

Example 5 with Music

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

the class BaiduMusicListActivity method listener.

@Override
protected void listener() {
    mAdapter.setOnItemClickListener((adapter, view, position) -> {
        if (view.getId() != R.id.iv_more) {
            Music music = (Music) adapter.getItem(position);
            mPresenter.playCurrentMusic(music);
        }
    });
    mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
        Music music = (Music) adapter.getItem(position);
        PopupMenu popupMenu = new PopupMenu(getApplicationContext(), view);
        popupMenu.setOnMenuItemClickListener(item -> {
            switch(item.getItemId()) {
                case R.id.popup_song_detail:
                    ShowDetailDialog.newInstance(music).show(getSupportFragmentManager(), getLocalClassName());
                    break;
                case R.id.popup_song_goto_artist:
                    Log.e(TAG, music.toString());
                    Intent intent = new Intent(this, ArtistInfoActivity.class);
                    intent.putExtra(Extras.TING_UID, music);
                    startActivity(intent);
                    break;
                case R.id.popup_add_playlist:
                    ToastUtils.show("暂不支持添加百度音乐");
                    break;
                case R.id.popup_song_download:
                    DownloadDialog.newInstance(music).show(getSupportFragmentManager(), getLocalClassName());
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_song_online);
        popupMenu.show();
    });
    mAdapter.setOnLoadMoreListener(() -> mRecyclerView.postDelayed(() -> {
        if (mCurrentCounter < TOTAL_COUNTER) {
            // 数据全部加载完毕
            mAdapter.loadMoreEnd();
        } else {
            // 成功获取更多数据
            mPresenter.loadOnlineMusicList(type, limit, mOffset);
        }
    }, 1000), mRecyclerView);
}
Also used : Music(com.cyl.musiclake.bean.Music) Intent(android.content.Intent) PopupMenu(android.widget.PopupMenu)

Aggregations

Music (com.cyl.musiclake.bean.Music)45 ArrayList (java.util.ArrayList)15 PopupMenu (android.widget.PopupMenu)10 DBDaoImpl (com.cyl.musiclake.data.source.db.DBDaoImpl)9 List (java.util.List)9 Log (android.util.Log)7 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)7 HashMap (java.util.HashMap)7 Intent (android.content.Intent)6 Cursor (android.database.Cursor)6 Bundle (android.os.Bundle)6 R (com.cyl.musiclake.R)6 PlayManager (com.cyl.musiclake.service.PlayManager)5 FileUtils (com.cyl.musiclake.utils.FileUtils)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 BindView (butterknife.BindView)4 BaseFragment (com.cyl.musiclake.base.BaseFragment)4 SongAdapter (com.cyl.musiclake.ui.music.local.adapter.SongAdapter)4 AddPlaylistDialog (com.cyl.musiclake.ui.music.local.dialog.AddPlaylistDialog)4