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