use of org.wordpress.android.ui.reader.adapters.ReaderMenuAdapter in project WordPress-Android by wordpress-mobile.
the class ReaderPostListFragment method onShowPostPopup.
/*
* called when user taps "..." icon next to a post
*/
@Override
public void onShowPostPopup(View view, final ReaderPost post) {
if (view == null || post == null || !isAdded())
return;
Context context = view.getContext();
final ListPopupWindow listPopup = new ListPopupWindow(context);
listPopup.setAnchorView(view);
listPopup.setWidth(context.getResources().getDimensionPixelSize(R.dimen.menu_item_width));
listPopup.setModal(true);
List<Integer> menuItems = new ArrayList<>();
boolean isFollowed = ReaderPostTable.isPostFollowed(post);
if (isFollowed) {
menuItems.add(ReaderMenuAdapter.ITEM_UNFOLLOW);
} else {
menuItems.add(ReaderMenuAdapter.ITEM_FOLLOW);
}
if (getPostListType() == ReaderPostListType.TAG_FOLLOWED) {
menuItems.add(ReaderMenuAdapter.ITEM_BLOCK);
}
listPopup.setAdapter(new ReaderMenuAdapter(context, menuItems));
listPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!isAdded())
return;
listPopup.dismiss();
switch((int) id) {
case ReaderMenuAdapter.ITEM_FOLLOW:
case ReaderMenuAdapter.ITEM_UNFOLLOW:
toggleFollowStatusForPost(post);
break;
case ReaderMenuAdapter.ITEM_BLOCK:
blockBlogForPost(post);
break;
}
}
});
listPopup.show();
}
Aggregations