Esempio n. 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();
 }
Esempio n. 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();
  }
Esempio n. 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);
 }
Esempio n. 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;
 }
Esempio n. 5
0
 public float getCurrVelocity() {
   return mScroller.getCurrVelocity();
 }
Esempio n. 6
0
 public void forceFinished() {
   mScroller.forceFinished(true);
 }
Esempio n. 7
0
 public boolean isFinished() {
   return mScroller.isFinished();
 }
Esempio n. 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();
 }