Search in sources :

Example 6 with PopupMenu

use of android.support.v7.widget.PopupMenu in project HumaneApp by Ganesh1010.

the class HomeActivity method onClick.

@Override
public void onClick(View v) {
    int viewId = v.getId();
    switch(viewId) {
        case R.id.menu_imagebutton_donor_home:
            PopupMenu popupMenu = new PopupMenu(HomeActivity.this, menuButton);
            Menu menu = popupMenu.getMenu();
            menu.add(Menu.NONE, MENU_ITEM_ONE, Menu.NONE, "My Profile");
            menu.add(Menu.NONE, MENU_ITEM_TWO, Menu.NONE, "Settings");
            menu.add(Menu.NONE, MENU_ITEM_THREE, Menu.NONE, "About Us");
            if (Connectivity.getAuthToken(HomeActivity.this, Connectivity.Donor_Token) != null)
                menu.add(Menu.NONE, MENU_ITEM_FOUR, Menu.NONE, "Logout");
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                public boolean onMenuItemClick(MenuItem item) {
                    Toast.makeText(HomeActivity.this, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
                    if (item.getTitle().toString().equals("My Profile")) {
                        startActivity(new Intent(HomeActivity.this, UserProfileActivity.class));
                        HomeActivity.this.finish();
                    } else if (item.getTitle().toString().equals("Logout")) {
                        Connectivity.deleteAuthToken(HomeActivity.this, Connectivity.Donor_Token);
                        startActivity(new Intent(HomeActivity.this, LoginPageFragment.class));
                        HomeActivity.this.finish();
                    }
                    return true;
                }
            });
            popupMenu.show();
            break;
        case R.id.current_location_imagebutton_home:
        case R.id.current_location_textview_home:
            Intent intent = new Intent(HomeActivity.this, ChooseLocationActivity.class);
            startActivityForResult(intent, LOCATION_REQUEST);
            HomeActivity.this.finish();
            break;
        case R.id.filter_imagebutton_donor_home:
            intent = new Intent(HomeActivity.this, FilterActivity.class);
            startActivityForResult(intent, FILTER_REQUEST);
            HomeActivity.this.finish();
            break;
        case R.id.new_need_home_page:
            startActivity(new Intent(HomeActivity.this, NewNeedActivity.class));
            HomeActivity.this.finish();
            break;
    }
}
Also used : MenuItem(android.view.MenuItem) Intent(android.content.Intent) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu) PopupMenu(android.support.v7.widget.PopupMenu)

Example 7 with PopupMenu

use of android.support.v7.widget.PopupMenu in project StylishMusicPlayer by ryanhoo.

the class PlayListFragment method onAction.

// Adapter Callbacks
@Override
public void onAction(View actionView, final int position) {
    final PlayList playList = mAdapter.getItem(position);
    PopupMenu actionMenu = new PopupMenu(getActivity(), actionView, Gravity.END | Gravity.BOTTOM);
    actionMenu.inflate(R.menu.play_list_action);
    if (playList.isFavorite()) {
        actionMenu.getMenu().findItem(R.id.menu_item_rename).setVisible(false);
        actionMenu.getMenu().findItem(R.id.menu_item_delete).setVisible(false);
    }
    actionMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.menu_item_play_now) {
                PlayListNowEvent playListNowEvent = new PlayListNowEvent(playList, 0);
                RxBus.getInstance().post(playListNowEvent);
            } else if (item.getItemId() == R.id.menu_item_rename) {
                mEditIndex = position;
                EditPlayListDialogFragment.editPlayList(playList).setCallback(PlayListFragment.this).show(getFragmentManager().beginTransaction(), "EditPlayList");
            } else if (item.getItemId() == R.id.menu_item_delete) {
                mDeleteIndex = position;
                mPresenter.deletePlayList(playList);
            }
            return true;
        }
    });
    actionMenu.show();
}
Also used : PlayList(io.github.ryanhoo.music.data.model.PlayList) PlayListNowEvent(io.github.ryanhoo.music.event.PlayListNowEvent) PopupMenu(android.support.v7.widget.PopupMenu)

Example 8 with PopupMenu

use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.

the class PlaylistFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, int position, Playlist playlist) {
    PopupMenu menu = new PopupMenu(PlaylistFragment.this.getActivity(), v);
    MenuUtils.addPlaylistMenuOptions(menu, playlist);
    MenuUtils.addClickHandler(getContext(), menu, playlist, null, null);
    menu.show();
}
Also used : PopupMenu(android.support.v7.widget.PopupMenu)

Example 9 with PopupMenu

use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.

the class DetailFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, final int position, final Song song) {
    PopupMenu menu = new PopupMenu(getActivity(), v);
    MenuUtils.addSongMenuOptions(getActivity(), menu);
    if (playlist != null && playlist.canEdit) {
        menu.getMenu().add(SONG_FRAGMENT_GROUP_ID, REMOVE, 10, R.string.remove_from_playlist);
    }
    MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, song, item -> {
        switch(item.getItemId()) {
            case BLACKLIST:
                adapter.removeItem(position);
                BlacklistHelper.addToBlacklist(song);
                return true;
            case REMOVE:
                if (playlist != null) {
                    adapter.removeItem(position);
                    Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.id);
                    getActivity().getContentResolver().delete(ContentUris.withAppendedId(uri, song.playlistSongId), null, null);
                }
        }
        return false;
    });
    menu.show();
}
Also used : Uri(android.net.Uri) PopupMenu(android.support.v7.widget.PopupMenu)

Example 10 with PopupMenu

use of android.support.v7.widget.PopupMenu in project Shuttle by timusus.

the class DetailFragment method onOverflowClick.

@Override
public void onOverflowClick(View v, int position, Object item) {
    PopupMenu menu = new PopupMenu(getActivity(), v);
    MenuUtils.addAlbumMenuOptions(getActivity(), menu);
    MenuUtils.addClickHandler((AppCompatActivity) getActivity(), menu, (Album) item);
    menu.show();
}
Also used : PopupMenu(android.support.v7.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