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();
});
}
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();
});
}
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();
});
}
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();
});
}
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();
});
}
Aggregations