Beispiel #1
0
 public void toggle() {
   if (isOpened()) {
     animateOpen();
   } else {
     animateClose();
   }
 }
Beispiel #2
0
 @Override
 public boolean onInterceptTouchEvent(final ViewGroup view, final MotionEvent event) {
   mShouldDisableScroll =
       !(isTouchEventHandled(view, event)
           || mContext instanceof DualPaneActivity
               && ((DualPaneActivity) mContext).isRightPaneUsed());
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       {
         mFirstDownHandled = !mShouldDisableScroll;
         mTempDeltaX = 0;
         mTotalMoveX = 0;
         mTotalMoveY = 0;
         mActualMoveX = 0;
         mIsVerticalScrolling = false;
         if (mFirstDownHandled) {
           mParent.animateOpen();
         }
         break;
       }
     case MotionEvent.ACTION_MOVE:
       {
         final int hist_size = event.getHistorySize();
         if (hist_size == 0) {
           break;
         }
         mTempDeltaX = event.getX() - event.getHistoricalX(0);
         mTotalMoveX += mTempDeltaX;
         final float deltaY = event.getY() - event.getHistoricalY(0);
         mTotalMoveY += deltaY;
         if (Math.abs(mTempDeltaX) > Math.abs(deltaY)
             && !mIsVerticalScrolling
             && Math.abs(mTotalMoveX) >= mScaledTouchSlop) return true;
         if (Math.abs(mTempDeltaX) < Math.abs(deltaY)
             && Math.abs(mTotalMoveY) >= mScaledTouchSlop) {
           mIsVerticalScrolling = true;
           return false;
         }
         break;
       }
   }
   return false;
 }