コード例 #1
0
  private final void smoothScrollTo(
      int newScrollValue,
      long duration,
      long delayMillis,
      OnSmoothScrollFinishedListener listener) {
    if (null != mCurrentSmoothScrollRunnable) {
      mCurrentSmoothScrollRunnable.stop();
    }

    final int oldScrollValue;
    switch (getPullToRefreshScrollDirection()) {
      case HORIZONTAL:
        oldScrollValue = getScrollX();
        break;
      case VERTICAL:
      default:
        oldScrollValue = getScrollY();
        break;
    }

    if (oldScrollValue != newScrollValue) {
      if (null == mScrollAnimationInterpolator) {
        // Default interpolator is a Decelerate Interpolator
        mScrollAnimationInterpolator = new DecelerateInterpolator();
      }
      mCurrentSmoothScrollRunnable =
          new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration, listener);

      if (delayMillis > 0) {
        postDelayed(mCurrentSmoothScrollRunnable, delayMillis);
      } else {
        post(mCurrentSmoothScrollRunnable);
      }
    }
  }
コード例 #2
0
ファイル: PullToRefreshBase.java プロジェクト: chfly/android
  /**
   * 平滑滚动
   *
   * @param newScrollValue 滚动的值
   * @param duration 滚动时候
   * @param delayMillis 延迟时间,0代表不延迟
   */
  private void smoothScrollTo(int newScrollValue, long duration, long delayMillis) {
    if (null != mSmoothScrollRunnable) {
      System.out.println("!!!!!!!!!!!!!");
      mSmoothScrollRunnable.stop();
    }

    int oldScrollValue = this.getScrollYValue();
    boolean post = (oldScrollValue != newScrollValue);
    if (post) {
      System.out.println(
          "oldScrollValue=="
              + oldScrollValue
              + "||newScrollValue=="
              + newScrollValue
              + "||duration=="
              + duration);
      mSmoothScrollRunnable = new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration);
    }

    if (post) {
      if (delayMillis > 0) {
        postDelayed(mSmoothScrollRunnable, delayMillis);
      } else {
        post(mSmoothScrollRunnable);
      }
    }
  }
コード例 #3
0
  protected final void smoothScrollTo(int y) {
    if (null != mCurrentSmoothScrollRunnable) {
      mCurrentSmoothScrollRunnable.stop();
    }

    if (getScrollY() != y) {
      mCurrentSmoothScrollRunnable = new SmoothScrollRunnable(getScrollY(), y);
      post(mCurrentSmoothScrollRunnable);
    }
  }
  /**
   * Smooth Scroll to Y position using the specific duration
   *
   * @param y - Y position to scroll to
   * @param duration - Duration of animation in milliseconds
   */
  protected final void smoothScrollTo(int y, long duration) {
    if (null != mCurrentSmoothScrollRunnable) {
      mCurrentSmoothScrollRunnable.stop();
    }

    if (getScrollY() != y) {
      if (null == mScrollAnimationInterpolator) {
        // Default interpolator is a Decelerate Interpolator
        mScrollAnimationInterpolator = new DecelerateInterpolator();
      }
      mCurrentSmoothScrollRunnable = new SmoothScrollRunnable(getScrollY(), y, duration);
      post(mCurrentSmoothScrollRunnable);
    }
  }
コード例 #5
0
  /**
   * 平滑滚动
   *
   * @param newScrollValue 滚动的值
   * @param duration 滚动时候
   * @param delayMillis 延迟时间,0代表不延迟
   */
  private void smoothScrollTo(int newScrollValue, long duration, long delayMillis) {
    if (null != mSmoothScrollRunnable) {
      mSmoothScrollRunnable.stop();
    }

    int oldScrollValue = this.getScrollYValue();
    boolean post = (oldScrollValue != newScrollValue);
    if (post) {
      mSmoothScrollRunnable = new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration);
    }

    if (post) {
      if (delayMillis > 0) {
        postDelayed(mSmoothScrollRunnable, delayMillis);
      } else {
        post(mSmoothScrollRunnable);
      }
    }
  }