use of io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment in project StylishMusicPlayer by ryanhoo.
the class FolderFragment method onAction.
// Adapter Callbacks
@Override
public void onAction(View actionView, final int position) {
final Folder folder = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(getActivity(), actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.folders_action);
actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_item_add_to_play_list:
new AddToPlayListDialogFragment().setCallback(new AddToPlayListDialogFragment.Callback() {
@Override
public void onPlayListSelected(PlayList playList) {
mPresenter.addFolderToPlayList(folder, playList);
}
}).show(getFragmentManager().beginTransaction(), "AddToPlayList");
break;
case R.id.menu_item_create_play_list:
PlayList playList = PlayList.fromFolder(folder);
EditPlayListDialogFragment.editPlayList(playList).setCallback(new EditPlayListDialogFragment.Callback() {
@Override
public void onCreated(PlayList playList) {
// Empty
}
@Override
public void onEdited(PlayList playList) {
mPresenter.createPlayList(playList);
}
}).show(getFragmentManager().beginTransaction(), "CreatePlayList");
break;
case R.id.menu_item_refresh:
mUpdateIndex = position;
mPresenter.refreshFolder(folder);
break;
case R.id.menu_item_delete:
mDeleteIndex = position;
mPresenter.deleteFolder(folder);
break;
}
return true;
}
});
actionMenu.show();
}
use of io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment in project StylishMusicPlayer by ryanhoo.
the class PlayListDetailsActivity method onAction.
// Adapter Action Callback
@Override
public void onAction(View actionView, final int position) {
final Song song = mAdapter.getItem(position);
PopupMenu actionMenu = new PopupMenu(this, actionView, Gravity.END | Gravity.BOTTOM);
actionMenu.inflate(R.menu.music_action);
actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(!isFolder);
actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.menu_item_add_to_play_list:
new AddToPlayListDialogFragment().setCallback(new AddToPlayListDialogFragment.Callback() {
@Override
public void onPlayListSelected(PlayList playList) {
if (playList.getId() == mPlayList.getId())
return;
mPresenter.addSongToPlayList(song, playList);
}
}).show(getSupportFragmentManager().beginTransaction(), "AddToPlayList");
break;
case R.id.menu_item_delete:
mDeleteIndex = position;
mPresenter.delete(song, mPlayList);
break;
}
return true;
}
});
actionMenu.show();
}
Aggregations