use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.
the class StaticCardView method showOverflowMenu.
private void showOverflowMenu(View anchorView) {
PopupMenu menu = new PopupMenu(anchorView.getContext(), anchorView, Gravity.END);
menu.getMenuInflater().inflate(R.menu.menu_feed_card_header, menu.getMenu());
MenuItem editCardLangItem = menu.getMenu().findItem(R.id.menu_feed_card_edit_card_languages);
editCardLangItem.setVisible(getCard().type().contentType().isPerLanguage());
menu.setOnMenuItemClickListener(new OverflowMenuClickListener());
menu.show();
}
use of android.support.v7.widget.PopupMenu in project apps-android-wikipedia by wikimedia.
the class ReadingListBookmarkMenu method showMenu.
private void showMenu() {
if (!existsInAnyList && isListsContainingPageEmpty()) {
return;
}
Context context = anchorView.getContext();
PopupMenu menu = new PopupMenu(context, anchorView);
menu.getMenuInflater().inflate(menuRes, menu.getMenu());
menu.setOnMenuItemClickListener(new PageSaveMenuClickListener());
if (listsContainingPage.size() == 1) {
MenuItem removeItem = menu.getMenu().findItem(R.id.menu_remove_from_lists);
removeItem.setTitle(context.getString(R.string.reading_list_remove_from_list, listsContainingPage.get(0).title()));
}
if (existsInAnyList) {
menu.setGravity(Gravity.END);
MenuItem addToOtherItem = menu.getMenu().findItem(R.id.menu_add_to_other_list);
addToOtherItem.setVisible(listsContainingPage.size() > 0);
addToOtherItem.setEnabled(listsContainingPage.size() > 0);
MenuItem removeItem = menu.getMenu().findItem(R.id.menu_remove_from_lists);
removeItem.setVisible(listsContainingPage.size() > 0);
removeItem.setEnabled(listsContainingPage.size() > 0);
MenuItem saveItem = menu.getMenu().findItem(R.id.menu_feed_card_item_save);
saveItem.setVisible(listsContainingPage.size() == 0);
saveItem.setEnabled(listsContainingPage.size() == 0);
}
menu.show();
}
use of android.support.v7.widget.PopupMenu in project ZhihuDailyPurify by izzyleung.
the class NewsAdapter method onCreateViewHolder.
@Override
public CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
final Context context = parent.getContext();
View itemView = LayoutInflater.from(context).inflate(R.layout.news_list_item, parent, false);
return new CardViewHolder(itemView, new CardViewHolder.ClickResponseListener() {
@Override
public void onWholeClick(int position) {
browse(context, position);
}
@Override
public void onOverflowClick(View v, int position) {
PopupMenu popup = new PopupMenu(context, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.contextual_news_list, popup.getMenu());
popup.setOnMenuItemClickListener(item -> {
switch(item.getItemId()) {
case R.id.action_share_url:
share(context, position);
break;
}
return true;
});
popup.show();
}
});
}
use of android.support.v7.widget.PopupMenu in project ListenerMusicPlayer by hefuyicoder.
the class FolderAdapter method setOnPopupMenuListener.
private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
int adapterPosition = itemHolder.getAdapterPosition();
final FolderInfo folderInfo = arraylist.get(adapterPosition);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_folder_addto_queue:
getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Folder);
}
});
break;
case R.id.popup_folder_addto_playlist:
getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showAddPlaylistDialog(mContext, ids);
}
});
break;
case R.id.popup_folder_delete:
new MaterialDialog.Builder(mContext).title(mContext.getResources().getString(R.string.delete_folder)).content("删除文件夹下" + folderInfo.songCount + "首歌曲?").positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.deleteTracks(mContext, ids);
RxBus.getInstance().post(new MediaUpdateEvent());
}
});
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
break;
}
return false;
}
});
menu.inflate(R.menu.popup_folder);
menu.show();
}
});
}
use of android.support.v7.widget.PopupMenu in project ListenerMusicPlayer by hefuyicoder.
the class PlaylistAdapter method setOnPopupMenuListener.
private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final Playlist playlist = arraylist.get(itemHolder.getAdapterPosition());
switch(item.getItemId()) {
case R.id.popup_playlist_rename:
new MaterialDialog.Builder(mContext).title(R.string.rename_playlist).positiveText("确定").negativeText(R.string.cancel).input(null, playlist.name, false, new MaterialDialog.InputCallback() {
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
MusicPlayer.renamePlaylist(mContext, playlist.id, input.toString());
itemHolder.title.setText(input.toString());
Toast.makeText(mContext, R.string.rename_playlist_success, Toast.LENGTH_SHORT).show();
}
}).show();
break;
case R.id.popup_playlist_addto_playlist:
getSongListIdByPlaylist(playlist.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showAddPlaylistDialog(mFragment.getActivity(), ids);
}
});
break;
case R.id.popup_playlist_addto_queue:
getSongListIdByPlaylist(playlist.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Playlist);
}
});
break;
case R.id.popup_playlist_delete:
new MaterialDialog.Builder(mContext).title(R.string.delete_playlist).positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
PlaylistLoader.deletePlaylists(mContext, playlist.id);
arraylist.remove(itemHolder.getAdapterPosition());
notifyItemRemoved(itemHolder.getAdapterPosition());
Toast.makeText(mContext, R.string.delete_playlist_success, Toast.LENGTH_SHORT).show();
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
break;
}
return false;
}
});
menu.inflate(R.menu.popup_playlist);
menu.show();
}
});
}
Aggregations