Example #1
0
  private void updateBubbles() {
    Iterator<Bubble> iterator = mBubbles.iterator();
    boolean needToDraw = false;
    while (iterator.hasNext()) {
      Bubble bubble = iterator.next();
      if (bubble.curTime <= DURATION) {
        initBezierPointIfNeed(bubble);

        bubble.curTime = bubble.curTime + STEP_PERIOD;
        float factor = mInterpolator.getInterpolation(bubble.curTime / (float) (DURATION));
        bubble.scale = ScaleInit + ScaleRange * factor;
        calculateBezierPoint(
            bubble.position,
            factor,
            bubble.startPoint,
            bubble.ctrlPoint1,
            bubble.ctrlPoint2,
            bubble.endPoint);

        // The last Half of the period make transparency change
        if (bubble.curTime > DURATION / 2) {
          float alphaFactor =
              mAlphaInterpolator.getInterpolation(
                  (bubble.curTime - DURATION / 2) / (float) (DURATION / 2));
          bubble.alpha = AlphaInit + (int) (AlphaRange * alphaFactor);
        }
        needToDraw = true;
      } else {
        iterator.remove();
      }
    }

    if (needToDraw) {
      postInvalidate();
    } else {
      mRunning = false;
      if (mAnimationListener != null) {
        mAnimationListener.onAnimationEnd(this);
      }
    }
  }
Example #2
0
 /**
  * Use interpolator to get t
  *
  * @return
  */
 private float interpolate() {
   long currTime = System.currentTimeMillis();
   float elapsed = (currTime - startTime) / ZOOM_TIME;
   elapsed = Math.min(1f, elapsed);
   return interpolator.getInterpolation(elapsed);
 }