PopupWindow setTouchInterceptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PopupWindow setTouchInterceptor method.

This code example shows how to use the following methods:setTouchInterceptor
            assertThat((BitmapDrawable) popupWindow.getBackground()).isSameAs(bitmapDrawable);
        } 
 
        @Test 
        public void testTouchInterceptor() { 
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
                @Override 
                public boolean onTouch(View v, MotionEvent event) {
                    return event.getAction() == ACTION_DOWN;
                } 
            }); 
 
            assertTrue(shadowOf(popupWindow).dispatchTouchEvent(obtain(1, 1, ACTION_DOWN, 1f, 1f, 0)));
        } 
    } 
 
    @RunWith(TestRunners.WithDefaults.class) 
    public static class WithContentView { 
 
        private TestWindowManager windowManager;
7
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
     * @param anchor 
     *            the view that the BetterPopupWindow will be displaying 'from' 
     */ 
    public BetterPopupWindow(View anchor) {
        this.anchor = anchor;
        this.window = new PopupWindow(anchor.getContext());
 
        // when a touch even happens outside of the window 
        // make the window go away 
        this.window.setTouchInterceptor(new OnTouchListener() {
            @Override 
            public boolean onTouch(View v, MotionEvent event) {
                if(event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    BetterPopupWindow.this.window.dismiss();
                    return true; 
                } 
                return false; 
            } 
        }); 
 
7
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
    private Drawable background = null;
    protected final WindowManager mWManager;
 
    public CustomPopup(View anchor) {
        mAnchor = anchor;
        mWindow = new PopupWindow(anchor.getContext());
 
        mWindow.setTouchInterceptor(new OnTouchListener() {
 
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    CustomPopup.this.dismiss();
                    return true; 
                } 
                return false; 
            } 
        }); 
 
        mWManager = (WindowManager) anchor.getContext().getSystemService(
                Context.WINDOW_SERVICE);
7
CodeRank
This code example shows how to use the following methods:setHeight, setOutsideTouchable, setTouchInterceptor, setTouchable, setWidth
        init();      
    } 
 
    private void init() { 
 
        window = new PopupWindow(context);
        window.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        window.setTouchable(true);
        //window.setFocusable(true); 
        window.setOutsideTouchable(true);
 
        // when a touch even happens outside of the window 
        // make the window go away 
        window.setTouchInterceptor(this);
        windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        onCreate(); 
    } 
 
6
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
	 * @param anchor 
	 *            the view that the BetterPopupWindow will be displaying 'from' 
	 */ 
	public BetterPopupWindow(View anchor) {
		this.anchor = anchor;
		this.window = new PopupWindow(anchor.getContext());
 
		// when a touch even happens outside of the window 
		// make the window go away 
		this.window.setTouchInterceptor(new OnTouchListener() {
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					BetterPopupWindow.this.window.dismiss();
					return true; 
				} 
				return false; 
			} 
		}); 
 
7
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
	 *  
	 * @param context Context 
	 */ 
	public PopupWindows(Context context) {
		mContext	= context;
		mWindow 	= new PopupWindow(context);
 
		mWindow.setTouchInterceptor(new OnTouchListener() {
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					mWindow.dismiss();
					 
					return true; 
				} 
				 
				return false; 
			} 
		}); 
 
6
CodeRank
This code example shows how to use the following methods:setInputMethodMode, setTouchInterceptor
	 */ 
	public PopupMenuCompat(Context context, View view) {
		this.context = context;
		res = context.getResources();
		mAnchorView = view;
		mWindow = new PopupWindow(context);
		mWindow.setTouchInterceptor(this);
		mWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
		mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
		mAdapter = new MenuAdapter(context);
		mMenu = new MenuImpl(context, mAdapter);
		setView(); 
 
	} 
 
	/** 
	 * Dismiss the popup window. 
	 */ 
	@Override 
	public void dismiss() { 
6
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
	protected Drawable mBackground = null;
	protected WindowManager mWindowManager;
 
	public PopupToolbar(Context context) {
		mContext = context;
		mWindow = new PopupWindow(context);
 
		mWindow.setTouchInterceptor(new OnTouchListener() {
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					mWindow.dismiss();
 
					return true; 
				} 
 
				return false; 
			} 
		}); 
 
		mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
6
CodeRank
This code example shows how to use the following methods:setTouchInterceptor
	 * @param anchor 
	 *            the view that the QuickAction will be displaying 'from' 
	 */ 
	public CustomPopupWindow(View anchor) {
		this.anchor = anchor;
		this.window = new PopupWindow(anchor.getContext());
 
		// when a touch even happens outside of the window 
		// make the window go away 
		window.setTouchInterceptor(new OnTouchListener() {
			@Override 
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
					CustomPopupWindow.this.window.dismiss();
 
					return true; 
				} 
 
				return false; 
			} 
7
CodeRank
This code example shows how to use the following methods:dismiss, isShowing, setBackgroundDrawable, setOutsideTouchable, setTouchInterceptor
            popupTextView.setBackground(new ColorDrawable(SELECTED_COLOR_BACKGROUND));
            popupTextView.setTextColor(Color.BLACK);
            popupTextView.setText("error");
            popupTextView.setPadding(5, 3, 5, 3);
            popupLayout.addView(popupTextView);
            popupWindow = new PopupWindow( popupLayout, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
            popupWindow.setOutsideTouchable(true);
            popupWindow.setTouchInterceptor(new OnTouchListener() {
                @Override 
                public boolean onTouch(View v, MotionEvent event) {
                    if(event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                        popupWindow.dismiss();
                        return true; 
                    } 
                    return false; 
                } 
            }); 
        } 
        if (popupWindow.isShowing()) {

6
CodeRank

Related PopupWindow setTouchInterceptor Questions & Answers:

setTouchInterceptor Method Overview
Set a callback for all touch events being dispatched to the popup window.
See Code Examples for other Android PopupWindow Methods: