Ejemplo n.º 1
0
 @Override
 public void computeScroll() {
   boolean invalidate = mDragHelper.continueSettling(true);
   if (!mTouchDown && mScroller.computeScrollOffset()) {
     if (!invalidate) {
       offsetHeaderBy(mScroller.getCurrY() - getHeaderTop());
     }
     invalidate = true;
   }
   updateViewOffset();
   if (invalidate) {
     ViewCompat.postInvalidateOnAnimation(this);
   }
 }
Ejemplo n.º 2
0
    @Override
    public void run() {
      if (mScroller.isFinished()) {
        return;
      }

      DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

      if (draweeView != null && mScroller.computeScrollOffset()) {
        final int newX = mScroller.getCurrX();
        final int newY = mScroller.getCurrY();
        mMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY);
        draweeView.invalidate();
        mCurrentX = newX;
        mCurrentY = newY;
        postOnAnimation(draweeView, this);
      }
    }
    @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();
    }