예제 #1
0
 public int getPosition() {
   /// M: [FEATURE.ADD] fancy layout @{
   if (mScrollMax != -1 && mScrollMin != -1 && mScroller.isOverScrolled()) {
     return Utils.clamp(mScroller.getCurrX(), mScrollMin, mScrollMax);
   }
   /// @}
   return mScroller.getCurrX();
 }
예제 #2
0
  public void setPosition(int position) {
    mScroller.startScroll(
        position, 0, // startX, startY
        0, 0, 0); // dx, dy, duration

    // This forces the scroller to reach the final position.
    mScroller.abortAnimation();
  }
예제 #3
0
 public void fling(int velocity, int min, int max) {
   /// M: [FEATURE.ADD] fancy layout @{
   mScrollMax = max;
   mScrollMin = min;
   mScroller.setMaxScrollLength(max);
   mScroller.setMinScrollLength(min);
   /// @}
   int currX = getPosition();
   mScroller.fling(
       currX,
       0, // startX, startY
       velocity,
       0, // velocityX, velocityY
       min,
       max, // minX, maxX
       0,
       0, // minY, maxY
       mOverflingEnabled ? mOverflingDistance : 0,
       0);
 }
예제 #4
0
 // Returns the distance that over the scroll limit.
 public int startScroll(int distance, int min, int max) {
   /// M: [FEATURE.ADD] fancy layout @{
   mScrollMax = max;
   mScrollMin = min;
   mScroller.setMaxScrollLength(max);
   mScroller.setMinScrollLength(min);
   /// @}
   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, // startX, startY
         newPosition - currPosition,
         0,
         0); // dx, dy, duration
   }
   return finalPosition + distance - newPosition;
 }
예제 #5
0
 public float getCurrVelocity() {
   return mScroller.getCurrVelocity();
 }
예제 #6
0
 public void forceFinished() {
   mScroller.forceFinished(true);
 }
예제 #7
0
 public boolean isFinished() {
   return mScroller.isFinished();
 }
예제 #8
0
 /**
  * Call this when you want to know the new location. The position will be updated and can be
  * obtained by getPosition(). Returns true if the animation is not yet finished.
  */
 public boolean advanceAnimation(long currentTimeMillis) {
   return mScroller.computeScrollOffset();
 }