public void closeMenu() {
   if (mCloseScroller.computeScrollOffset()) {
     mCloseScroller.abortAnimation();
   }
   if (state == STATE_OPEN) {
     state = STATE_CLOSE;
     swipe(0);
   }
 }
 public void flingHeader(float velocity) {
   if (mTouchDown) {
     mScroller.abortAnimation();
     return;
   }
   mScroller.fling(
       0,
       getHeaderTop(),
       0,
       (int) velocity,
       0,
       0,
       mContainer.getHeaderTopMinimum(),
       mContainer.getHeaderTopMaximum());
   ViewCompat.postInvalidateOnAnimation(this);
 }
 @Override
 public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
   switch (ev.getAction()) {
     case MotionEvent.ACTION_DOWN:
       {
         mScroller.abortAnimation();
         mTouchDown = true;
         mTouchingScrollableContent = isScrollContentCallback(ev.getX(), ev.getY());
         mUsingDragHelper = false;
         break;
       }
     case MotionEvent.ACTION_CANCEL:
     case MotionEvent.ACTION_UP:
       {
         mTouchDown = false;
         mTouchingScrollableContent = false;
         mUsingDragHelper = false;
       }
   }
   mGestureDetector.onTouchEvent(ev);
   return super.dispatchTouchEvent(ev);
 }
 public void stop() {
   removeCallbacks(this);
   mScroller.abortAnimation();
 }
    @Override
    public void run() {
      disableRunOnAnimationRequests();
      // consumePendingUpdateOperations();
      // keep a local reference so that if it is changed during onAnimation method, it won't
      // cause unexpected behaviors
      final ScrollerCompat scroller = mScroller;
      if (scroller.computeScrollOffset()) {

        final int x = scroller.getCurrX();
        final int y = scroller.getCurrY();
        final int dx = x - mLastFlingX;
        final int dy = y - mLastFlingY;
        int hresult = 0;
        int vresult = 0;
        mLastFlingX = x;
        mLastFlingY = y;
        int overscrollX = 0;
        int overscrollY = 0;

        Log.v(
            TAG,
            "scrolling scrolling scrolling: "
                + dy
                + " y: "
                + y
                + " lastY: "
                + mLastFlingY
                + " time:");
        PlaylistContainerWrapper.this.scrollInternal(dy, 0, null, false);
        vresult = dy;

        if (!PlaylistContainerWrapper.this.canScrollDown()) {
          vresult = 0;
          scroller.abortAnimation();
        }

        if (overscrollX != 0 || overscrollY != 0) {
          final int vel = (int) scroller.getCurrVelocity();

          int velX = 0;
          if (overscrollX != x) {
            velX = overscrollX < 0 ? -vel : overscrollX > 0 ? vel : 0;
          }

          int velY = 0;
          if (overscrollY != y) {
            velY = overscrollY < 0 ? -vel : overscrollY > 0 ? vel : 0;
          }

          if ((velX != 0 || overscrollX == x || scroller.getFinalX() == 0)
              && (velY != 0 || overscrollY == y || scroller.getFinalY() == 0)) {
            scroller.abortAnimation();
          }
        }
        if (hresult != 0 || vresult != 0) {
          dispatchOnScrolled(hresult, vresult);
        }

        if (!awakenScrollBars()) {
          invalidate();
        }

        final boolean fullyConsumedVertical = dy != 0 && true && vresult == dy;
        final boolean fullyConsumedHorizontal = dx != 0 && false && hresult == dx;
        final boolean fullyConsumedAny =
            (dx == 0 && dy == 0) || fullyConsumedHorizontal || fullyConsumedVertical;

        if (scroller.isFinished() || !fullyConsumedAny) {
          setScrollState(SCROLL_STATE_IDLE); // setting state to idle will stop this.
        } else {
          postOnAnimation();
        }
      }
      // call this after the onAnimation is complete not to have inconsistent callbacks etc.
      /*
      if (smoothScroller != null) {
          if (smoothScroller.isPendingInitialRun()) {
              smoothScroller.onAnimation(0, 0);
          }
          if (!mReSchedulePostAnimationCallback) {
              smoothScroller.stop(); //stop if it does not trigger any scroll
          }
      }
      */
      enableRunOnAnimationRequests();
    }
Пример #6
0
 public void cancelFling() {
   mScroller.abortAnimation();
 }