Search in sources :

Example 76 with PopupMenu

use of android.support.v7.widget.PopupMenu 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 77 with PopupMenu

use of android.support.v7.widget.PopupMenu 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 78 with PopupMenu

use of android.support.v7.widget.PopupMenu 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 79 with PopupMenu

use of android.support.v7.widget.PopupMenu 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 80 with PopupMenu

use of android.support.v7.widget.PopupMenu in project MusicLake by caiyonglong.

the class DownloadedFragment 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) -> {
        Music music = (Music) adapter.getItem(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_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));
                        mAdapter.notifyItemChanged(position);
                    }).positiveText("确定").negativeText("取消").show();
                    break;
            }
            return false;
        });
        popupMenu.inflate(R.menu.popup_song);
        popupMenu.show();
    });
}
Also used : DownloadPresenter(com.cyl.musiclake.ui.music.online.presenter.DownloadPresenter) 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) DownloadContract(com.cyl.musiclake.ui.music.online.contract.DownloadContract) PopupMenu(android.widget.PopupMenu) 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) PlayManager(com.cyl.musiclake.service.PlayManager) Music(com.cyl.musiclake.bean.Music) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)142 MenuItem (android.view.MenuItem)116 View (android.view.View)86 TextView (android.widget.TextView)63 RecyclerView (android.support.v7.widget.RecyclerView)54 ImageView (android.widget.ImageView)40 Intent (android.content.Intent)32 PopupMenu (android.widget.PopupMenu)31 List (java.util.List)27 ArrayList (java.util.ArrayList)26 MenuInflater (android.view.MenuInflater)23 Menu (android.view.Menu)22 Bundle (android.os.Bundle)20 LayoutInflater (android.view.LayoutInflater)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 Context (android.content.Context)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 AdapterView (android.widget.AdapterView)17 DialogInterface (android.content.DialogInterface)16 ViewGroup (android.view.ViewGroup)15