Exemplo n.º 1
0
    /**
     * 描述:TODO
     *
     * @see java.lang.Runnable#run()
     * @author: zhaoqp
     * @date:2013-11-28 上午11:14:35
     * @version v1.0
     */
    public void run() {
      if (CarouselView.this.getChildCount() == 0) {
        endFling(true);
        return;
      }

      mShouldStopFling = false;

      final Rotator rotator;
      final float angle;
      boolean more;
      synchronized (this) {
        rotator = mRotator;
        more = rotator.computeAngleOffset();
        angle = rotator.getCurrAngle();
      }

      // Flip sign to convert finger direction to list items direction
      // (e.g. finger moving down means list is moving towards the top)
      float delta = mLastFlingAngle - angle;

      //////// Shoud be reworked
      trackMotionScroll(delta);

      if (more && !mShouldStopFling) {
        mLastFlingAngle = angle;
        post(this);
      } else {
        mLastFlingAngle = 0.0f;
        endFling(true);
      }
    }
Exemplo n.º 2
0
    /**
     * Start using distance.
     *
     * @param deltaAngle the delta angle
     */
    public void startUsingDistance(float deltaAngle) {
      if (deltaAngle == 0) return;

      startCommon();

      mLastFlingAngle = 0;
      synchronized (this) {
        mRotator.startRotate(0.0f, -deltaAngle, mAnimationDuration);
      }
      post(this);
    }
Exemplo n.º 3
0
    /**
     * End fling.
     *
     * @param scrollIntoSlots the scroll into slots
     */
    private void endFling(boolean scrollIntoSlots) {
      /*
       * Force the scroller's status to finished (without setting its
       * position to the end)
       */
      synchronized (this) {
        mRotator.forceFinished(true);
      }

      if (scrollIntoSlots) scrollIntoSlots();
    }
Exemplo n.º 4
0
    /**
     * Start using velocity.
     *
     * @param initialVelocity the initial velocity
     */
    public void startUsingVelocity(float initialVelocity) {
      if (initialVelocity == 0) return;

      startCommon();

      mLastFlingAngle = 0.0f;

      mRotator.fling(initialVelocity);

      post(this);
    }