Example usage for android.widget PopupWindow setOutsideTouchable

List of usage examples for android.widget PopupWindow setOutsideTouchable

Introduction

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

Prototype

public void setOutsideTouchable(boolean touchable) 

Source Link

Document

Controls whether the pop-up will be informed of touch events outside of its window.

Usage

From source file:ab.util.AbDialogUtil.java

/**
 * /*w  w w. j  ava  2 s . c o  m*/
 */
public static MyPop showDatePopWindowHour(Context context, View contentView, View targetView) {
    // 
    hourArrayString = getHMArray(24);
    // ??
    c = Calendar.getInstance();
    PopupWindow popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);

    hourWV = (WheelView) contentView.findViewById(R.id.time_hour);
    // ?
    hourWV.setVisibleItems(5);
    // 
    hourWV.setLabel(":00");
    hourWV.setCyclic(true);
    setHourData();
    return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV);
}

From source file:ab.util.AbDialogUtil.java

/**
 * popupwindow/*from  w  w w  .j  a  va 2 s.  c  o  m*/
 */
public static PopupWindow showPopWindow(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAsDropDown(targetView);
    return popupWindow;
}

From source file:ab.util.AbDialogUtil.java

/**
 * popupwindow/*from www  .ja  v a  2s . com*/
 */
public static PopupWindow showPopWindow2(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);
    return popupWindow;
}

From source file:ab.util.AbDialogUtil.java

/**
 * popupwindow// ww w .  j  a  va 2 s  .com
 */
public static PopupWindow showPopWindow3(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    return popupWindow;
}

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

/**
 * ????/*from  ww  w .  ja v a2s. c  o m*/
 *
 * @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);
            }
        }
    });
}

From source file:ab.util.AbDialogUtil.java

public static MyPop showDatePopWindow(Context context, View contentView, View targetView) {
    // //from   ww  w  . j  a v  a  2 s.  com
    yearArrayString = getYEARArray(2016, 30);
    monthArrayString = getDayArray(12);
    hourArrayString = getHMArray(24);
    minuteArrayString = getHMArray(60);
    // ??
    c = Calendar.getInstance();
    PopupWindow popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);
    yearWV = (WheelView) contentView.findViewById(R.id.time_year);
    monthWV = (WheelView) contentView.findViewById(R.id.time_month);
    dayWV = (WheelView) contentView.findViewById(R.id.time_day);
    hourWV = (WheelView) contentView.findViewById(R.id.time_hour);
    minuteWV = (WheelView) contentView.findViewById(R.id.time_minute);

    // ?
    yearWV.setVisibleItems(5);
    monthWV.setVisibleItems(5);
    dayWV.setVisibleItems(5);
    hourWV.setVisibleItems(5);
    minuteWV.setVisibleItems(5);

    // 
    yearWV.setLabel("");
    monthWV.setLabel("");
    dayWV.setLabel("");
    hourWV.setLabel("");
    minuteWV.setLabel("");
    yearWV.setCyclic(true);
    monthWV.setCyclic(true);
    dayWV.setCyclic(true);
    hourWV.setCyclic(true);
    minuteWV.setCyclic(true);
    setData();
    return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV);
}

From source file:ab.util.AbDialogUtil.java

/**
 * /* w  w w. j  a va 2s.c  o  m*/
 */
public static MyPop showDatePopWindowDate(Context context, View contentView, View targetView) {
    // 
    yearArrayString = getYEARArray(2016, 36);
    monthArrayString = getDayArray(12);
    hourArrayString = getHMArray(24);
    minuteArrayString = getHMArray(60);
    // ??
    c = Calendar.getInstance();
    PopupWindow popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);
    yearWV = (WheelView) contentView.findViewById(R.id.time_year);
    monthWV = (WheelView) contentView.findViewById(R.id.time_month);
    dayWV = (WheelView) contentView.findViewById(R.id.time_day);
    hourWV = (WheelView) contentView.findViewById(R.id.time_hour);
    minuteWV = (WheelView) contentView.findViewById(R.id.time_minute);
    hourWV.setVisibility(View.GONE);
    minuteWV.setVisibility(View.GONE);
    // ?
    yearWV.setVisibleItems(5);
    monthWV.setVisibleItems(5);
    dayWV.setVisibleItems(5);
    hourWV.setVisibleItems(5);
    minuteWV.setVisibleItems(5);

    // 
    yearWV.setLabel("");
    monthWV.setLabel("");
    dayWV.setLabel("");
    hourWV.setLabel("");
    minuteWV.setLabel("");
    yearWV.setCyclic(true);
    monthWV.setCyclic(true);
    dayWV.setCyclic(true);
    hourWV.setCyclic(true);
    minuteWV.setCyclic(true);
    setData();
    return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV);
}

From source file:bruce.kk.brucetodos.MainActivity.java

/**
 * ? //from  w ww  . j a va  2s . c om
 */
private void showAddPop() {
    final EditText editText = new EditText(MainActivity.this);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editText.setLayoutParams(layoutParams);
    //        editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    editText.setTextColor(getResources().getColor(android.R.color.holo_green_light));
    editText.setHint("?~");
    editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark));
    editText.setBackgroundColor(getResources().getColor(android.R.color.black));
    final PopupWindow popupWindow = new PopupWindow(editText, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ?
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0);

    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            LogDetails.d(": " + editText.getText().toString());
            if (!TextUtils.isEmpty(editText.getText().toString().trim())) {
                ProgressDialogUtils.showProgressDialog();
                UnFinishItem item = new UnFinishItem();
                Date date = new Date();
                item.createDay = date;
                item.content = editText.getText().toString().trim();
                item.modifyDay = date;
                dataList.add(item);
                refreshData(true);
                presenter.addItem(item);
            }
        }
    });
}

From source file:bruce.kk.brucetodos.MainActivity.java

/**
 * ???/*from  w  w w. j  a  v  a2s. c  om*/
 *
 * @param position
 */
private void modifyItem(final int position) {
    final UnFinishItem item = dataList.get(position);
    LogDetails.d(item);
    LinearLayout linearLayout = new LinearLayout(MainActivity.this);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    linearLayout.setLayoutParams(layoutParams);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundColor(getResources().getColor(android.R.color.black));

    final EditText editText = new EditText(MainActivity.this);
    editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    editText.setTextColor(getResources().getColor(android.R.color.holo_green_light));
    editText.setHint(item.content);
    editText.setHintTextColor(getResources().getColor(android.R.color.holo_orange_dark));

    linearLayout.addView(editText);

    Button btnModify = new Button(MainActivity.this);
    btnModify.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    btnModify.setText("");
    btnModify.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    btnModify.setTextColor(getResources().getColor(android.R.color.holo_blue_bright));
    btnModify.setBackgroundColor(getResources().getColor(android.R.color.black));

    linearLayout.addView(btnModify);

    Button btnDeleteItem = new Button(MainActivity.this);
    btnDeleteItem.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    btnDeleteItem.setText("");
    btnDeleteItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    btnDeleteItem.setTextColor(getResources().getColor(android.R.color.holo_blue_bright));
    btnDeleteItem.setBackgroundColor(getResources().getColor(android.R.color.black));

    linearLayout.addView(btnDeleteItem);

    final PopupWindow popupWindow = new PopupWindow(linearLayout, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setBackgroundDrawable(new BitmapDrawable()); // ?
    popupWindow.setTouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(contentMain, Gravity.CENTER, 0, 0);

    btnModify.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            LogDetails.d(": " + editText.getText().toString());
            if (!TextUtils.isEmpty(editText.getText().toString().trim())) {
                Date date = new Date();
                item.content = editText.getText().toString().trim();
                item.modifyDay = date;
                item.finishDay = null;
                ProgressDialogUtils.showProgressDialog();
                presenter.modifyItem(item);
                dataList.set(position, item);
                refreshData(true);
                popupWindow.dismiss();
            } else {
                Toast.makeText(MainActivity.this, "~", Toast.LENGTH_SHORT).show();
            }
        }
    });
    btnDeleteItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dataList.remove(position);
            presenter.deleteItem(item);
            refreshData(false);
            popupWindow.dismiss();
        }
    });
}

From source file:com.bf.zxd.zhuangxudai.my.fragment.FinancialApplyFragment.java

private void ChangeIcon() {
    //PopupWindow----START-----??PopupWindowPopupWindow???
    backgroundAlpha(0.3f);/*from  w w  w. j a v  a 2s  .c  om*/
    View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null);
    final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    popupWindow.setOutsideTouchable(true);
    popupWindow.setFocusable(true);
    //??
    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    popupWindow.setWidth(dm.widthPixels);
    popupWindow.setAnimationStyle(R.style.popuwindow);
    //?
    popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    popupWindow.setOnDismissListener(new poponDismissListener_FinancialApplyFragment());

    //PopupWindow-----END
    //PopupWindow
    Button button = (Button) view.findViewById(R.id.take_photo);//??
    Button button1 = (Button) view.findViewById(R.id.all_photo);//?
    Button button2 = (Button) view.findViewById(R.id.out);//?
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,?
            allPhoto();
        }
    });
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            backgroundAlpha(1f);
            popupWindow.dismiss();
            //,Intent????
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //,??
            File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image");
            //??
            path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg";
            //?IntentIntent?
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path)));
            //?
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
            //?Intent??RoundImageView
            startActivityForResult(intent, REQUEST_CODE);
        }
    });
}