@Override
  public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
      // This is called at drawing time by ViewGroup.  We don't want to
      // re-show the scrollbars at this point, which scrollTo will do,
      // so we replicate most of scrollTo here.
      //
      //         It's a little odd to call onScrollChanged from inside the drawing.
      //
      //         It is, except when you remember that computeScroll() is used to
      //         animate scrolling. So unless we want to defer the onScrollChanged()
      //         until the end of the animated scrolling, we don't really have a
      //         choice here.
      //
      //         I agree.  The alternative, which I think would be worse, is to post
      //         something and tell the subclasses later.  This is bad because there
      //         will be a window where mScrollX/Y is different from what the app
      //         thinks it is.
      //
      int oldX = getScrollX(); // mScrollX;
      int oldY = getScrollY(); // mScrollY;
      int x = mScroller.getCurrX();
      int y = mScroller.getCurrY();

      CFUtil.Log("sx=" + x + ", sy=" + y);

      if (oldX != x || oldY != y) {
        final int rangeY = getScrollRangeY();
        // final int overscrollMode = getOverScrollMode();
        // final boolean canOverscroll = overscrollMode == OVER_SCROLL_ALWAYS ||
        //        (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && range > 0);

        //                overScrollBy(x - oldX, y - oldY, oldX, oldY, 0, range,
        //                        0, mOverflingDistance, false);
        scrollTo(x, y);
        onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);

        //                if (canOverscroll) {
        //                    if (y < 0 && oldY >= 0) {
        //                        mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
        //                    } else if (y > range && oldY <= range) {
        //                        mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
        //                    }
        //                }
      }

      postInvalidate();
      //            if (!awakenScrollBars()) {
      //                // Keep on drawing until the animation has finished.
      //                postInvalidateOnAnimation();
      //            }

    }
    //        else {
    //            if (mFlingStrictSpan != null) {
    //                mFlingStrictSpan.finish();
    //                mFlingStrictSpan = null;
    //            }
    //        }
  }
Ejemplo n.º 2
1
 // Returns the distance that over the scroll limit.
 public int startScroll(int distance, int min, int max) {
   int currPosition = mScroller.getCurrX();
   int finalPosition = mScroller.isFinished() ? currPosition : mScroller.getFinalX();
   int newPosition = Utils.clamp(finalPosition + distance, min, max);
   if (newPosition != currPosition) {
     mScroller.startScroll(currPosition, 0, newPosition - currPosition, 0, 0);
   }
   return finalPosition + distance - newPosition;
 }
  @Override
  public void computeScroll() {
    super.computeScroll();

    if (mScroller.computeScrollOffset()) {
      mRect.offsetTo(mScroller.getCurrX(), mScroller.getCurrY());

      ViewCompat.postInvalidateOnAnimation(this);
    }
  }
Ejemplo n.º 4
0
 public int getCurrX() {
   if (isPreGingerbread) {
     return scroller.getCurrX();
   } else {
     return overScroller.getCurrX();
   }
 }
  @Override
  public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
      // This is called at drawing time by ViewGroup. We don't want to
      // re-show the scrollbars at this point, which scrollTo will do,
      // so we replicate most of scrollTo here.
      //
      // It's a little odd to call onScrollChanged from inside the drawing.
      //
      // It is, except when you remember that computeScroll() is used to
      // animate scrolling. So unless we want to defer the onScrollChanged()
      // until the end of the animated scrolling, we don't really have a
      // choice here.
      //
      // I agree. The alternative, which I think would be worse, is to post
      // something and tell the subclasses later. This is bad because there
      // will be a window where mScrollX/Y is different from what the app
      // thinks it is.
      //
      int oldX = getScrollX();
      int oldY = getScrollY();
      int x = mScroller.getCurrX();
      int y = mScroller.getCurrY();

      if (oldX != x || oldY != y) {
        final int range = getScrollRange();
        final int overscrollMode = getOverScrollMode();
        final boolean canOverscroll =
            overscrollMode == OVER_SCROLL_ALWAYS
                || (overscrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && range > 0);

        overScrollBy(x - oldX, y - oldY, oldX, oldY, range, 0, mOverflingDistance, 0, false);
        onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
      }

      if (!awakenScrollBars()) {
        postInvalidateOnAnimation();
      }
    } else {
      int scrollX = getScrollX();
      int finalX = getScrollXFromFinalX(scrollX);

      if (!mIsBeingDragged && scrollX != finalX) {
        if (mScroller.springBack(getScrollX(), getScrollY(), finalX, finalX, 0, 0)) {
          postInvalidateOnAnimation();
        }
      }
    }
  }
Ejemplo n.º 6
0
  // Called immediately before the draw to update the scroll offset.
  public void computeScrollAndAbsorbGlow(OverScrollGlow overScrollGlow) {
    final boolean stillAnimating = mScroller.computeScrollOffset();
    if (!stillAnimating) return;

    final int oldX = mDelegate.getContainerViewScrollX();
    final int oldY = mDelegate.getContainerViewScrollY();
    int x = mScroller.getCurrX();
    int y = mScroller.getCurrY();

    int rangeX = computeMaximumHorizontalScrollOffset();
    int rangeY = computeMaximumVerticalScrollOffset();

    if (overScrollGlow != null) {
      overScrollGlow.absorbGlow(x, y, oldX, oldY, rangeX, rangeY, mScroller.getCurrVelocity());
    }

    // The mScroller is configured not to go outside of the scrollable range, so this call
    // should never result in attempting to scroll outside of the scrollable region.
    scrollBy(x - oldX, y - oldY);

    mDelegate.invalidate();
  }
Ejemplo n.º 7
0
 @Override
 public int getCurrX() {
   return mScroller.getCurrX();
 }
Ejemplo n.º 8
0
 public int getPosition() {
   return mScroller.getCurrX();
 }
 @Override
 protected int getCurrX() {
   return mScroller.getCurrX();
 }