Example usage for android.widget PopupWindow isShowing

List of usage examples for android.widget PopupWindow isShowing

Introduction

In this page you can find the example usage for android.widget PopupWindow isShowing.

Prototype

public boolean isShowing() 

Source Link

Document

Indicate whether this popup window is showing on screen.

Usage

From source file:Main.java

public static boolean tryToClosePopupWindow(PopupWindow popupWindow) {
    if (popupWindow != null && popupWindow.isShowing()) {
        popupWindow.dismiss();/*  w w w. j a  v  a2 s.  c  o  m*/
        return true;
    }
    return false;
}

From source file:Main.java

public static void toggle(PopupWindow window, View view) {
    if (null != window) {
        if (window.isShowing())
            window.dismiss();//from   w  ww.  j a  va  2 s  . co m
        else
            window.showAsDropDown(view);
    }
}

From source file:com.tfc.webviewer.presenter.WebViewPresenterImpl.java

@Override
public void onBackPressed(PopupWindow menu, WebView webView) {
    if (menu.isShowing()) {
        mView.closeMenu();//from   www.j a  va2  s. co m
    } else if (webView.canGoBack()) {
        mView.goBack();
    } else {
        mView.close();
    }
}

From source file:com.tfc.webviewer.presenter.WebViewPresenterImpl.java

public void onClick(int resId, String url, PopupWindow popupWindow) {
    mView.closeMenu();/* ww  w. j av  a2  s .c  om*/

    if (R.id.toolbar_btn_close == resId) {
        mView.close();
    } else if (R.id.toolbar_btn_more == resId) {
        if (popupWindow.isShowing()) {
            mView.closeMenu();
        } else {
            mView.openMenu();
        }
    } else if (R.id.popup_menu_btn_back == resId) {
        mView.goBack();
    } else if (R.id.popup_menu_btn_forward == resId) {
        mView.goFoward();
    } else if (R.id.popup_menu_btn_refresh == resId) {
        mView.onRefresh();
    } else if (R.id.popup_menu_btn_copy_link == resId) {
        mView.copyLink(url);
        mView.showToast(makeToast(mContext.getString(R.string.message_copy_to_clipboard)));
    } else if (R.id.popup_menu_btn_open_with_other_browser == resId) {
        mView.openBrowser(Uri.parse(url));
    } else if (R.id.popup_menu_btn_share == resId) {
        mView.openShare(url);
    }
}

From source file:com.android.talkbacktests.testsession.PopupViewTest.java

/**
 * Shows a PopupWindow at the anchor view with given window height and list size.
 *///from  w ww.j a v a 2  s. co m
private void showPopupWindow(View button, int height, int listSize, boolean useDefaultInflater) {
    final Context context = button.getContext();
    final ListView listView = new ListView(context);
    final BaseAdapter adapter;
    if (useDefaultInflater) {
        adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, android.R.id.text1,
                createSampleArray(listSize));
    } else {
        adapter = new MyAdapter(button.getContext(), createSampleArray(listSize));
    }
    listView.setAdapter(adapter);

    listView.setVerticalScrollBarEnabled(true);
    listView.setBackgroundColor(0xFFFFFF);
    final PopupWindow window = new PopupWindow(listView, ViewGroup.LayoutParams.WRAP_CONTENT, height, true);
    window.setBackgroundDrawable(context.getResources().getDrawable(android.R.drawable.editbox_background));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (window.isShowing()) {
                window.dismiss();
            }
        }
    });
    PopupWindowCompat.showAsDropDown(window, button, 0, 0, Gravity.NO_GRAVITY);
}

From source file:net.quduo.pixel.interfaces.android.fragment.ChatFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater;
    View v = inflater.inflate(R.layout.fragment_chat, container, false);

    mChatListView = (ListView) v.findViewById(R.id.chat_list_view);

    // TODO: ?/*from   www  . ja v  a2s.  c om*/
    mSourceDataList = new ArrayList<ChatListDataModel>();
    ChatListDataModel sourceData = new ChatListDataModel();
    sourceData.setChatAvatar(R.drawable.default_contact_action_01);
    sourceData.setChatTitle("?");
    sourceData.setChatSummary(":?, ...");
    mSourceDataList.add(sourceData);

    ChatListDataModel sourceData1 = new ChatListDataModel();
    sourceData1.setChatAvatar(R.drawable.default_contact_action_04);
    sourceData1.setChatTitle("");
    sourceData1.setChatSummary("?");
    mSourceDataList.add(sourceData1);

    ChatListDataModel sourceData2 = new ChatListDataModel();
    sourceData2.setChatAvatar(R.drawable.default_contact_action_03);
    sourceData2.setChatTitle("");
    sourceData2.setChatSummary("?...");
    mSourceDataList.add(sourceData2);

    ChatListDataModel sourceData3 = new ChatListDataModel();
    sourceData3.setChatAvatar(R.drawable.default_contact_action_02);
    sourceData3.setChatTitle("");
    sourceData3.setChatSummary("?");
    mSourceDataList.add(sourceData3);

    // TODO ContextMenu
    final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map1 = new HashMap<String, Object>();
    // map1.put("item_image", R.drawable.icon_message);
    map1.put("item_icon", R.string.icon_chat_add_group);
    // map1.put("item_text", "" + i + "");
    map1.put("item_title", "??");
    mPopupWindowListItem.add(map1);
    HashMap<String, Object> map2 = new HashMap<String, Object>();
    // map2.put("item_image", R.drawable.icon_message);
    map2.put("item_icon", R.string.icon_chat_add_group);
    // map2.put("item_text", "" + i + "");
    map2.put("item_title", "");
    mPopupWindowListItem.add(map2);

    mChatListAdapter = new ChatListAdapter(this.getActivity(), mSourceDataList);
    mChatListView.setAdapter(mChatListAdapter);
    mChatListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            Intent intent = new Intent(getActivity(), ChatFormActivity.class);
            getActivity().startActivity(intent);
            getActivity().finish();
            // ?
            getActivity().overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_close_exit);

        }
    });
    mChatListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            // ??
            View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null);
            // PopupWindow
            final PopupWindow popupWindow = new PopupWindow(contextMenuView,
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false);
            // ???
            // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background)
            popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000));
            // ??
            // popupWindow.setOutsideTouchable(true);
            // ??
            popupWindow.setFocusable(true);
            // ?
            // popupWindow.setAnimationStyle(R.style.PopupAnimation);
            // ?
            // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){});
            /*
            // PopupWindow,PopupWindow
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popupWindow.dismiss();
                    return true;
                }
                return false;
            }
            });
            */
            popupWindow.getContentView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            if (popupWindow.isShowing()) {
                // ???????????
                popupWindow.dismiss();
            } else {
                // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title});

                BaseAdapter mSimpleAdapter = new BaseAdapter() {

                    @Override
                    public int getCount() {
                        return mPopupWindowListItem.size();
                    }

                    @Override
                    public Object getItem(int i) {
                        return null;
                    }

                    @Override
                    public long getItemId(int i) {
                        return 0;
                    }

                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {

                        if (convertView == null) {
                            LayoutInflater inflater = LayoutInflater.from(getActivity());
                            convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent,
                                    false);
                        }
                        // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon);
                        // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon"));
                        // popupMenuItemIcon.setTypeface(typeface);
                        // if (popupMenuItemIcon.getTypeface() != typeface) {
                        //    popupMenuItemIcon.setTypeface(typeface);
                        // }
                        // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString()));

                        TextView popupMenuItemTitle = (TextView) convertView
                                .findViewById(R.id.context_menu_action_text_view);
                        popupMenuItemTitle
                                .setText(mPopupWindowListItem.get(position).get("item_title").toString());

                        return convertView;
                    }
                };

                TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title);
                contextMenuTitle.setText(mSourceDataList.get(i).getChatTitle());

                ListView mPopupMenuListView = (ListView) contextMenuView
                        .findViewById(R.id.context_menu_list_view);
                mPopupMenuListView.setAdapter(mSimpleAdapter);

                // ?
                // PopupWindow??View?x,y?????
                // popupWindow.showAsDropDown(v, -460, 0);
                // ?View?,?parent????-90
                // Gravity.TOP|Gravity.LEFT, 0, 150
                popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
                popupWindow.update();
            }
            return true;
        }
    });
    // mChatListView.setOnItemSelectedListener();

    // #ContextMenu
    // this.unregisterForContextMenu(mChatListView);
    // mChatListView.setOnCreateContextMenuListener(null);
    // this.registerForContextMenu(mChatListView);
    return v;
}

From source file:net.quduo.pixel.interfaces.android.fragment.ContactFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_contact, container, false);

    // TODO ContextMenu
    final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map1 = new HashMap<String, Object>();
    // map1.put("item_image", R.drawable.icon_message);
    map1.put("item_icon", R.string.icon_chat_add_group);
    // map1.put("item_text", "" + i + "");
    map1.put("item_title", "??");
    mPopupWindowListItem.add(map1);/*  ww  w .  j  a  va  2 s  . c o  m*/
    HashMap<String, Object> map2 = new HashMap<String, Object>();
    // map2.put("item_image", R.drawable.icon_message);
    map2.put("item_icon", R.string.icon_chat_add_group);
    // map2.put("item_text", "" + i + "");
    map2.put("item_title", "");
    mPopupWindowListItem.add(map2);

    // Set the adapter
    mContactListAdapter = new ContactListAdapter(this.getActivity(), mSourceDataList);
    mListView = (ListView) view.findViewById(R.id.contact_list_view);
    mListView.setAdapter(mContactListAdapter);

    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (null != mListener) {
                // Notify the active callbacks interface (the activity, if the
                // fragment is attached to one) that an item has been selected.
                // mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id);
            }
        }
    });
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            // Log.e(TAG, DummyContent.ITEMS.get(i).content);
            Log.e(TAG, mSourceDataList.get(i).getContactName());

            // ??
            View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null);
            // PopupWindow
            final PopupWindow popupWindow = new PopupWindow(contextMenuView,
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false);
            // ???
            // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background)
            popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000));
            // ??
            // popupWindow.setOutsideTouchable(true);
            // ??
            popupWindow.setFocusable(true);
            // ?
            // popupWindow.setAnimationStyle(R.style.PopupAnimation);
            // ?
            // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){});
            /*
            // PopupWindow,PopupWindow
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popupWindow.dismiss();
                    return true;
                }
                return false;
            }
            });
            */
            popupWindow.getContentView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            if (popupWindow.isShowing()) {
                // ???????????
                popupWindow.dismiss();
            } else {
                // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title});

                BaseAdapter mSimpleAdapter = new BaseAdapter() {

                    @Override
                    public int getCount() {
                        return mPopupWindowListItem.size();
                    }

                    @Override
                    public Object getItem(int i) {
                        return null;
                    }

                    @Override
                    public long getItemId(int i) {
                        return 0;
                    }

                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {

                        if (convertView == null) {
                            LayoutInflater inflater = LayoutInflater.from(getActivity());
                            convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent,
                                    false);
                        }
                        // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon);
                        // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon"));
                        // popupMenuItemIcon.setTypeface(typeface);
                        // if (popupMenuItemIcon.getTypeface() != typeface) {
                        //    popupMenuItemIcon.setTypeface(typeface);
                        // }
                        // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString()));

                        TextView popupMenuItemTitle = (TextView) convertView
                                .findViewById(R.id.context_menu_action_text_view);
                        popupMenuItemTitle
                                .setText(mPopupWindowListItem.get(position).get("item_title").toString());

                        return convertView;
                    }
                };

                TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title);
                contextMenuTitle.setText(mSourceDataList.get(i).getContactName());

                ListView mPopupMenuListView = (ListView) contextMenuView
                        .findViewById(R.id.context_menu_list_view);
                mPopupMenuListView.setAdapter(mSimpleAdapter);

                // ?
                // PopupWindow??View?x,y?????
                // popupWindow.showAsDropDown(v, -460, 0);
                // ?View?,?parent????-90
                // Gravity.TOP|Gravity.LEFT, 0, 150
                popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
                popupWindow.update();
            }

            return true;
        }
    });

    mLetterQueryView = (LetterQueryView) view.findViewById(R.id.letter_query_view);
    mLetterTextDialog = (TextView) view.findViewById(R.id.letter_text_dialog);
    mLetterQueryView.setTextView(mLetterTextDialog);

    // ??
    mLetterQueryView.setOnTouchingLetterChangedListener(new LetterQueryView.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            // ??
            int position = mContactListAdapter.getPositionForSection(s.charAt(0));
            if (position != -1) {
                mListView.setSelection(position);
            }

        }
    });

    return view;
}

From source file:org.zywx.wbpalmstar.plugin.uexPopoverMenu.EUExPopoverMenu.java

private void showPopoverMenu(double x, double y, int direction, String bgColorStr, String dividerColor,
        String textColor, int textSize, JSONArray data) {
    LinearLayout rootView = (LinearLayout) LayoutInflater.from(mContext)
            .inflate(finder.getLayoutId("plugin_uex_popovermenu"), null);

    final PopupWindow popupWindow = new PopupWindow(rootView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, true);

    popupWindow.setContentView(rootView);
    ///*from w  w  w.  j  a v  a 2s.  c  om*/
    rootView.setBackgroundColor(Color.parseColor(bgColorStr));
    popupWindow.setContentView(rootView);
    //popupWindow?
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setOutsideTouchable(true);

    int length = data.length();
    List<ItemData> itemDataList = new ArrayList<ItemData>();
    try {
        for (int i = 0; i < length; i++) {
            ItemData item = new ItemData();
            String icon = data.getJSONObject(i).optString("icon", "");
            if (!hasIcon && !TextUtils.isEmpty(icon)) {
                hasIcon = true;
            }
            if (hasIcon) {
                item.setIcon(data.getJSONObject(i).getString("icon"));
            }
            item.setText(data.getJSONObject(i).getString("text"));
            itemDataList.add(item);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < length; i++) {
        LinearLayout linearLayout = new LinearLayout(mContext);
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        if (hasIcon) {
            ImageView imageView = new ImageView(mContext);
            imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            String imagePath = itemDataList.get(i).getIcon();
            imageView.setImageBitmap(getBitmapFromPath(imagePath));
            imageView.setPadding(DensityUtil.dip2px(mContext, 5), 0, 0, 0);
            linearLayout.addView(imageView);
        }
        TextView tvText = new TextView(mContext);
        LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        tvLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        tvText.setLayoutParams(tvLayoutParams);

        tvText.setPadding(DensityUtil.dip2px(mContext, 5), 0, DensityUtil.dip2px(mContext, 8), 0);
        tvText.setText(itemDataList.get(i).getText());
        tvText.setTextColor(Color.parseColor(textColor));
        tvText.setTextSize(textSize);
        linearLayout.addView(tvText);
        linearLayout.setTag(i);
        linearLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                callBackPluginJs(CALLBACK_ITEM_SELECTED, String.valueOf(v.getTag()));
                if (popupWindow != null && popupWindow.isShowing()) {
                    popupWindow.dismiss();
                }
            }
        });
        rootView.addView(linearLayout);

        //
        View dividerLine = new View(mContext);
        dividerLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                DensityUtil.dip2px(mContext, 1)));
        dividerLine.setBackgroundColor(Color.parseColor(dividerColor));
        rootView.addView(dividerLine);
    }
    int gravityParam;
    switch (direction) {
    case 0:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    case 1:
        gravityParam = Gravity.RIGHT | Gravity.TOP;
        break;
    case 2:
        gravityParam = Gravity.LEFT | Gravity.BOTTOM;
        break;
    case 3:
        gravityParam = Gravity.RIGHT | Gravity.BOTTOM;
        break;
    default:
        gravityParam = Gravity.LEFT | Gravity.TOP;
        break;
    }
    popupWindow.showAtLocation(mBrwView.getRootView(), gravityParam, (int) x, (int) y);
}

From source file:cn.zhangls.android.weibo.ui.weibo.WeiboFrameProvider.java

/**
 * ????/*from w w w .j  a v a  2s . c om*/
 *
 * @param holder
 * @param status
 */
private void setupPopupBar(final FrameHolder holder, final Status status) {
    LayoutInflater layoutInflater = LayoutInflater
            .from(holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext());
    // 
    final View popupView;
    if (status.isFavorited() && status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_save_post,
                holder.binding.flWeiboContainer, false);
    } else if (!status.isFavorited() && status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_follow_unsave_post,
                holder.binding.flWeiboContainer, false);
    } else if (status.isFavorited() && !status.getUser().isFollowing()) {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_save_post,
                holder.binding.flWeiboContainer, false);
    } else {// ??
        popupView = layoutInflater.inflate(R.layout.popup_window_weibo_unfollow_unsave_post,
                holder.binding.flWeiboContainer, false);
    }
    //  PopupWindow
    final PopupWindow popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    // popupWindow 
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            Animation animation = AnimationUtils.loadAnimation(
                    holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(),
                    R.anim.rotate_180_end);
            animation.setDuration(300);
            animation.setFillAfter(true);
            holder.binding.fgHomeWeiboPopupBar.startAnimation(animation);
        }
    });
    popupWindow.setAnimationStyle(R.style.PopupWindowAnimStyle);
    // popupWindow  Item ?
    if (status.isFavorited()) {// ??????
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_save_post)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        FavoritesAPI favoritesAPI = new FavoritesAPI(
                                mBinding.getRoot().getContext().getApplicationContext(),
                                AccessTokenKeeper.readAccessToken(
                                        mBinding.getRoot().getContext().getApplicationContext()));
                        BaseObserver<Favorite> observer = new BaseObserver<Favorite>(
                                mBinding.getRoot().getContext().getApplicationContext()) {
                            @Override
                            public void onNext(Favorite value) {
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                            }

                            @Override
                            public void onComplete() {

                            }
                        };

                        favoritesAPI.destroy(observer, status.getId());

                        popupWindow.dismiss();
                    }
                });
    } else {
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unsave_post)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        FavoritesAPI favoritesAPI = new FavoritesAPI(
                                mBinding.getRoot().getContext().getApplicationContext(),
                                AccessTokenKeeper.readAccessToken(
                                        mBinding.getRoot().getContext().getApplicationContext()));
                        BaseObserver<Favorite> observer = new BaseObserver<Favorite>(
                                mBinding.getRoot().getContext().getApplicationContext()) {
                            @Override
                            public void onNext(Favorite value) {
                            }

                            @Override
                            public void onError(Throwable e) {
                                super.onError(e);
                            }

                            @Override
                            public void onComplete() {

                            }
                        };

                        favoritesAPI.create(observer, status.getId());

                        popupWindow.dismiss();
                    }
                });
    }
    if (status.getUser().isFollowing()) {// ????
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_follow)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popupWindow.dismiss();
                    }
                });
    } else {
        popupWindow.getContentView().findViewById(R.id.menu_item_weibo_more_unfollow)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        popupWindow.dismiss();
                    }
                });
    }

    // ???
    holder.binding.fgHomeWeiboPopupBar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (popupWindow != null && !popupWindow.isShowing()) {
                Animation animation = AnimationUtils.loadAnimation(
                        holder.binding.fgHomeWeiboPopupBar.getContext().getApplicationContext(),
                        R.anim.rotate_180_start);
                animation.setDuration(300);
                animation.setFillAfter(true);
                holder.binding.fgHomeWeiboPopupBar.startAnimation(animation);
                popupWindow.showAsDropDown(holder.binding.fgHomeWeiboPopupBar);
            }
        }
    });
}