Search in sources :

Example 1 with ReaderMenuAdapter

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();
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) SearchView(android.support.v7.widget.SearchView) ReaderSiteHeaderView(org.wordpress.android.ui.reader.views.ReaderSiteHeaderView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) FilteredRecyclerView(org.wordpress.android.ui.FilteredRecyclerView) AutoCompleteTextView(android.widget.AutoCompleteTextView) RecyclerView(android.support.v7.widget.RecyclerView) ReaderMenuAdapter(org.wordpress.android.ui.reader.adapters.ReaderMenuAdapter) ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView)

Aggregations

Context (android.content.Context)1 ListPopupWindow (android.support.v7.widget.ListPopupWindow)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 FilteredRecyclerView (org.wordpress.android.ui.FilteredRecyclerView)1 ReaderMenuAdapter (org.wordpress.android.ui.reader.adapters.ReaderMenuAdapter)1 ReaderSiteHeaderView (org.wordpress.android.ui.reader.views.ReaderSiteHeaderView)1