Java Code Examples for android.widget.PopupWindow#setTouchInterceptor()

The following examples show how to use android.widget.PopupWindow#setTouchInterceptor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomPopupWindow.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
private void apply(PopupWindow mPopupWindow) {
    mPopupWindow.setClippingEnabled(this.mClippEnable);
    if(this.mIgnoreCheekPress) {
        mPopupWindow.setIgnoreCheekPress();
    }

    if(this.mInputMode != -1) {
        mPopupWindow.setInputMethodMode(this.mInputMode);
    }

    if(this.mSoftInputMode != -1) {
        mPopupWindow.setSoftInputMode(this.mSoftInputMode);
    }

    if(this.mOnDismissListener != null) {
        mPopupWindow.setOnDismissListener(this.mOnDismissListener);
    }

    if(this.mOnTouchListener != null) {
        mPopupWindow.setTouchInterceptor(this.mOnTouchListener);
    }

    mPopupWindow.setTouchable(this.mTouchable);
}
 
Example 2
Source File: CustomPopWindow.java    From LLApp with Apache License 2.0 6 votes vote down vote up
/**
 * 添加一些属性设置
 * @param popupWindow
 */
private void apply(PopupWindow popupWindow){
    popupWindow.setClippingEnabled(mClippEnable);
    if(mIgnoreCheekPress){
        popupWindow.setIgnoreCheekPress();
    }
    if(mInputMode!=-1){
        popupWindow.setInputMethodMode(mInputMode);
    }
    if(mSoftInputMode!=-1){
        popupWindow.setSoftInputMode(mSoftInputMode);
    }
    if(mOnDismissListener!=null){
        popupWindow.setOnDismissListener(mOnDismissListener);
    }
    if(mOnTouchListener!=null){
        popupWindow.setTouchInterceptor(mOnTouchListener);
    }
    popupWindow.setTouchable(mTouchable);



}
 
Example 3
Source File: TextBubble.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a {@link TextBubble} instance.
 * @param context  Context to draw resources from.
 * @param rootView The {@link View} to use for size calculations and for display.
 * @param stringId The id of the string resource for the text that should be shown.
 * @param accessibilityStringId The id of the string resource of the accessibility text.
 */
public TextBubble(Context context, View rootView, @StringRes int stringId,
        @StringRes int accessibilityStringId) {
    mContext = context;
    mRootView = rootView.getRootView();
    mStringId = stringId;
    mAccessibilityStringId = accessibilityStringId;
    mPopupWindow = new PopupWindow(mContext);
    mDrawable = new ArrowBubbleDrawable(context);
    mHandler = new Handler();

    mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setBackgroundDrawable(mDrawable);
    mPopupWindow.setAnimationStyle(R.style.TextBubbleAnimation);

    mPopupWindow.setTouchInterceptor(this);
    mPopupWindow.setOnDismissListener(mDismissListener);

    mMarginPx = context.getResources().getDimensionPixelSize(R.dimen.text_bubble_margin);

    // Set predefined styles for the TextBubble.
    mDrawable.setBubbleColor(
            ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.google_blue_500));
}
 
Example 4
Source File: PopupWindows.java    From fanfouapp-opensource with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 * 
 * @param context
 *            Context
 */
public PopupWindows(final Context context) {
    mContext = context;
    mWindow = new PopupWindow(context);

    mWindow.setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(final View v, final MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                mWindow.dismiss();

                return true;
            }

            return false;
        }
    });

    mWindowManager = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
}
 
Example 5
Source File: PopupWindowManager.java    From PlayTogether with Apache License 2.0 5 votes vote down vote up
public static PopupWindow getPopupWindow(View contentView, int width, int height, final View
				dimView, final onCloseListener listener)
{
	final PopupWindow mPopupWindow = new PopupWindow(contentView, width, height, true);
	mPopupWindow.setTouchable(true);
	mPopupWindow.setAnimationStyle(R.style.selectPopupWindowAnim);
	mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
	mPopupWindow.setTouchInterceptor(new View.OnTouchListener()
	{
		@Override
		public boolean onTouch(View v, MotionEvent event)
		{
			if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
			{
				mPopupWindow.dismiss();
				return true;
			}
			return false;
		}
	});
	mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener()
	{
		@Override
		public void onDismiss()
		{
			if (dimView != null)
				toggleLight(false, dimView);
			if (listener != null)
				listener.onClose();
		}
	});
	return mPopupWindow;
}
 
Example 6
Source File: BasePop.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
private void initPop()
{
    mPopupWindow = new PopupWindow(mContext);
    mPopupWindow.setFocusable(setFocusable());
    boolean outsideTouchacle = setOutsideTouchable();
    mPopupWindow.setOutsideTouchable(outsideTouchacle);
    mPopupWindow.setBackgroundDrawable(new ShapeDrawable());
    mPopupWindow.setWidth(setLayoutWidthParams());
    mPopupWindow.setHeight(setLayoutHeightParams());
    int animStyle = setAnimStyle();
    if (animStyle != 0)
        mPopupWindow.setAnimationStyle(animStyle);
    //设置内容布局
    mContentView = mContext.getLayoutInflater().inflate(setContentViewId()
            , (ViewGroup) mContext.findViewById(android.R.id.content), false);
    mContentView.measure(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setContentView(mContentView);
    //设置点击外部关闭pop
    if (outsideTouchacle)
        mPopupWindow.setTouchInterceptor(new View.OnTouchListener()
        {
            @Override
            public boolean onTouch(View v, MotionEvent event)
            {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
                {
                    mPopupWindow.dismiss();
                    return true;
                }
                return false;
            }
        });
}
 
Example 7
Source File: IntroController.java    From geoar-app with Apache License 2.0 5 votes vote down vote up
private static void initPopupShow() {
	introViewer = new IntroViewer(activity, activity.getResources()
			.getString(R.string.intro_start_title), activity.getResources()
			.getString(R.string.intro_start_desc));

	graph = new TaskGraph();

	popup = new PopupWindow(introViewer, LayoutParams.MATCH_PARENT,
			LayoutParams.MATCH_PARENT);
	popup.setTouchable(false);
	popup.setFocusable(true);
	popup.setOutsideTouchable(true);
	popup.setTouchInterceptor(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			return false;
		}

	});

	activity.getWindow().getDecorView().post(new Runnable() {
		@Override
		public void run() {
			if(popup!=null)
			popup.showAtLocation(activity.getWindow().getDecorView()
					.getRootView(), Gravity.TOP, 0, 0);
		}
	});
}