Search in sources :

Example 1 with AddToPlayListDialogFragment

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();
}
Also used : AddToPlayListDialogFragment(io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment) PlayList(io.github.ryanhoo.music.data.model.PlayList) Folder(io.github.ryanhoo.music.data.model.Folder) EditPlayListDialogFragment(io.github.ryanhoo.music.ui.playlist.EditPlayListDialogFragment) PopupMenu(android.support.v7.widget.PopupMenu)

Example 2 with AddToPlayListDialogFragment

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();
}
Also used : AddToPlayListDialogFragment(io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment) PlayList(io.github.ryanhoo.music.data.model.PlayList) Song(io.github.ryanhoo.music.data.model.Song) MenuItem(android.view.MenuItem) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)2 PlayList (io.github.ryanhoo.music.data.model.PlayList)2 AddToPlayListDialogFragment (io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment)2 MenuItem (android.view.MenuItem)1 Folder (io.github.ryanhoo.music.data.model.Folder)1 Song (io.github.ryanhoo.music.data.model.Song)1 EditPlayListDialogFragment (io.github.ryanhoo.music.ui.playlist.EditPlayListDialogFragment)1