コード例 #1
0
  public boolean stepAnimation(long now) {
    if (mEnterAnimation == null && mExitAnimation == null) {
      return false;
    }

    if (!mStarted) {
      if (mEnterAnimation != null) {
        mEnterAnimation.setStartTime(now);
      }
      if (mExitAnimation != null) {
        mExitAnimation.setStartTime(now);
      }
      mStarted = true;
    }

    mExitTransformation.clear();
    boolean moreExit = false;
    if (mExitAnimation != null) {
      moreExit = mExitAnimation.getTransformation(now, mExitTransformation);
      if (DEBUG) Slog.v(TAG, "Stepped exit: " + mExitTransformation);
      if (!moreExit) {
        if (DEBUG) Slog.v(TAG, "Exit animation done!");
        mExitAnimation.cancel();
        mExitAnimation = null;
        mExitTransformation.clear();
        if (mSurface != null) {
          mSurface.hide();
        }
      }
    }

    mEnterTransformation.clear();
    boolean moreEnter = false;
    if (mEnterAnimation != null) {
      moreEnter = mEnterAnimation.getTransformation(now, mEnterTransformation);
      if (!moreEnter) {
        mEnterAnimation.cancel();
        mEnterAnimation = null;
        mEnterTransformation.clear();
        if (mBlackFrame != null) {
          mBlackFrame.hide();
        }
      } else {
        if (mBlackFrame != null) {
          mBlackFrame.setMatrix(mEnterTransformation.getMatrix());
        }
      }
    }

    mSnapshotFinalMatrix.setConcat(mExitTransformation.getMatrix(), mSnapshotInitialMatrix);
    setSnapshotTransform(mSnapshotFinalMatrix, mExitTransformation.getAlpha());

    return moreEnter || moreExit;
  }
コード例 #2
0
  // Must be called while in a transaction.
  public void setRotation(int rotation) {
    mCurRotation = rotation;

    // Compute the transformation matrix that must be applied
    // to the snapshot to make it stay in the same original position
    // with the current screen rotation.
    int delta = deltaRotation(rotation, mSnapshotRotation);
    createRotationMatrix(delta, mWidth, mHeight, mSnapshotInitialMatrix);

    if (DEBUG) Slog.v(TAG, "**** ROTATION: " + delta);
    setSnapshotTransform(mSnapshotInitialMatrix, 1.0f);
  }