@Override
 public boolean onInterceptTouchEvent(MotionEvent ev) {
   return parentActionBarLayout.checkTransitionAnimation() || onTouchEvent(ev);
 }
 public boolean onTouchEvent(MotionEvent ev) {
   if (!parentActionBarLayout.checkTransitionAnimation()) {
     if (drawerOpened && ev != null && ev.getX() > drawerPosition && !startedTracking) {
       if (ev.getAction() == MotionEvent.ACTION_UP) {
         closeDrawer(false);
       }
       return true;
     }
     if (allowOpenDrawer && parentActionBarLayout.fragmentsStack.size() == 1) {
       if (ev != null
           && (ev.getAction() == MotionEvent.ACTION_DOWN
               || ev.getAction() == MotionEvent.ACTION_MOVE)
           && !startedTracking
           && !maybeStartTracking) {
         startedTrackingPointerId = ev.getPointerId(0);
         maybeStartTracking = true;
         startedTrackingX = (int) ev.getX();
         startedTrackingY = (int) ev.getY();
         cancelCurrentAnimation();
         if (velocityTracker != null) {
           velocityTracker.clear();
         }
       } else if (ev != null
           && ev.getAction() == MotionEvent.ACTION_MOVE
           && ev.getPointerId(0) == startedTrackingPointerId) {
         if (velocityTracker == null) {
           velocityTracker = VelocityTracker.obtain();
         }
         float dx = (int) (ev.getX() - startedTrackingX);
         float dy = Math.abs((int) ev.getY() - startedTrackingY);
         velocityTracker.addMovement(ev);
         if (maybeStartTracking
             && !startedTracking
             && (dx > 0
                     && dx / 3.0f > Math.abs(dy)
                     && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true)
                 || dx < 0
                     && Math.abs(dx) >= Math.abs(dy)
                     && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.4f, true))) {
           prepareForDrawerOpen(ev);
           startedTrackingX = (int) ev.getX();
           requestDisallowInterceptTouchEvent(true);
         } else if (startedTracking) {
           if (!beginTrackingSent) {
             if (((Activity) getContext()).getCurrentFocus() != null) {
               AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
             }
             beginTrackingSent = true;
           }
           moveDrawerByX(dx);
           startedTrackingX = (int) ev.getX();
         }
       } else if (ev == null
           || ev != null
               && ev.getPointerId(0) == startedTrackingPointerId
               && (ev.getAction() == MotionEvent.ACTION_CANCEL
                   || ev.getAction() == MotionEvent.ACTION_UP
                   || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
         if (velocityTracker == null) {
           velocityTracker = VelocityTracker.obtain();
         }
         velocityTracker.computeCurrentVelocity(1000);
         /*if (!startedTracking) {
             float velX = velocityTracker.getXVelocity();
             float velY = velocityTracker.getYVelocity();
             if (Math.abs(velX) >= 3500 && Math.abs(velX) > Math.abs(velY)) {
                 prepareForDrawerOpen(ev);
                 if (!beginTrackingSent) {
                     if (((Activity)getContext()).getCurrentFocus() != null) {
                         AndroidUtilities.hideKeyboard(((Activity)getContext()).getCurrentFocus());
                     }
                     beginTrackingSent = true;
                 }
             }
         }*/
         if (startedTracking
             || drawerPosition != 0 && drawerPosition != drawerLayout.getMeasuredWidth()) {
           float velX = velocityTracker.getXVelocity();
           float velY = velocityTracker.getYVelocity();
           boolean backAnimation =
               drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f
                       && (velX < 3500 || Math.abs(velX) < Math.abs(velY))
                   || velX < 0 && Math.abs(velX) >= 3500;
           if (!backAnimation) {
             openDrawer(!drawerOpened && Math.abs(velX) >= 3500);
           } else {
             closeDrawer(drawerOpened && Math.abs(velX) >= 3500);
           }
           startedTracking = false;
         } else {
           maybeStartTracking = false;
           startedTracking = false;
         }
         if (velocityTracker != null) {
           velocityTracker.recycle();
           velocityTracker = null;
         }
       }
     }
     return startedTracking;
   }
   return false;
 }