private boolean handleTouchEvent(MotionEvent ev){
  DeviceProfile grid=mLauncher.getDeviceProfile();
  int x=(int)ev.getX();
  int y=(int)ev.getY();
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
    if (!mContentBounds.isEmpty()) {
      Rect tmpRect=new Rect(mContentBounds);
      tmpRect.inset(-grid.allAppsIconSizePx / 2,0);
      if (ev.getX() < tmpRect.left || ev.getX() > tmpRect.right) {
        mBoundsCheckLastTouchDownPos.set(x,y);
        return true;
      }
    }
 else {
      if (ev.getX() < getPaddingLeft() || ev.getX() > (getWidth() - getPaddingRight())) {
        mBoundsCheckLastTouchDownPos.set(x,y);
        return true;
      }
    }
  break;
case MotionEvent.ACTION_UP:
if (mBoundsCheckLastTouchDownPos.x > -1) {
  ViewConfiguration viewConfig=ViewConfiguration.get(getContext());
  float dx=ev.getX() - mBoundsCheckLastTouchDownPos.x;
  float dy=ev.getY() - mBoundsCheckLastTouchDownPos.y;
  float distance=(float)Math.hypot(dx,dy);
  if (distance < viewConfig.getScaledTouchSlop()) {
    Launcher launcher=(Launcher)getContext();
    launcher.showWorkspace(true);
    return true;
  }
}
case MotionEvent.ACTION_CANCEL:
mBoundsCheckLastTouchDownPos.set(-1,-1);
break;
}
return false;
}

private boolean handleTouchEvent ( MotionEvent ev ) { DeviceProfile grid = mLauncher . getDeviceProfile ( ) ; int x = ( int ) ev . getX ( ) ; int y = ( int ) ev . getY ( ) ; switch ( ev . getAction ( ) ) { case MotionEvent . ACTION_DOWN : if ( ! mContentBounds . isEmpty ( ) ) { Rect tmpRect = new Rect ( mContentBounds ) ; tmpRect . inset ( - grid . allAppsIconSizePx / 2 , 0 ) ; if ( ev . getX ( ) < tmpRect . left || ev . getX ( ) > tmpRect . right ) { mBoundsCheckLastTouchDownPos . set ( x , y ) ; return true ; } } else { if ( ev . getX ( ) < getPaddingLeft ( ) || ev . getX ( ) > ( getWidth ( ) - getPaddingRight ( ) ) ) { mBoundsCheckLastTouchDownPos . set ( x , y ) ; return true ; } } break ; case MotionEvent . ACTION_UP : if ( mBoundsCheckLastTouchDownPos . x > - 1 ) { ViewConfiguration viewConfig = ViewConfiguration . get ( getContext ( ) ) ; float dx = ev . getX ( ) - mBoundsCheckLastTouchDownPos . x ; float dy = ev . getY ( ) - mBoundsCheckLastTouchDownPos . y ; float distance = ( float ) Math . hypot ( dx , dy ) ; if ( distance < viewConfig . getScaledTouchSlop ( ) ) { Launcher launcher = ( Launcher ) getContext ( ) ; launcher . showWorkspace ( true ) ; return true ; } } case MotionEvent . ACTION_CANCEL : mBoundsCheckLastTouchDownPos . set ( - 1 , - 1 ) ; break ; } return false ; }
handles the touch events to dismiss all apps when clicking outside the bounds of the recycler view .
