@Override
 public Animation onCreateAnimation(int transit, final boolean enter, int nextAnim) {
   Animation animation;
   if (enter) {
     animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_up);
     animation.setInterpolator(new OvershootInterpolator(0.5f));
     animation.setDuration(350);
     presenter.onOpenAnimation(animation.getDuration());
   } else {
     animation = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_down);
     animation.setInterpolator(new LinearInterpolator());
     animation.setDuration(200);
     presenter.onExitAnimation(animation.getDuration());
   }
   return animation;
 }
Esempio n. 2
0
  public void show(boolean useAnimation) {
    handler.removeCallbacks(runPushPad);
    handler.removeCallbacks(runHidePad);

    setVisibility(View.VISIBLE);
    lastControlPadShowTime =
        System.currentTimeMillis() + (useAnimation ? pullPad.getDuration() : 0);
    if (useAnimation) controlPad.startAnimation(pullPad);
    setTitle(null);
    controlPad.setVisibility(View.VISIBLE);

    runTimedHide = new RunTimedHide(useAnimation);
    handler.postDelayed(runTimedHide, CONTROL_BAR_SHOW_TIME);
  }
  public boolean stepAnimationLocked(long now) {
    if (!hasAnimations()) {
      if (DEBUG_STATE) Slog.v(TAG, "Step: no animations running");
      mFinishAnimReady = false;
      return false;
    }

    if (!mAnimRunning) {
      if (DEBUG_STATE) Slog.v(TAG, "Step: starting start, finish, rotate");
      if (TWO_PHASE_ANIMATION) {
        if (mStartEnterAnimation != null) {
          mStartEnterAnimation.setStartTime(now);
        }
        if (mStartExitAnimation != null) {
          mStartExitAnimation.setStartTime(now);
        }
        if (mFinishEnterAnimation != null) {
          mFinishEnterAnimation.setStartTime(0);
        }
        if (mFinishExitAnimation != null) {
          mFinishExitAnimation.setStartTime(0);
        }
      }
      if (USE_CUSTOM_BLACK_FRAME) {
        if (mStartFrameAnimation != null) {
          mStartFrameAnimation.setStartTime(now);
        }
        if (mFinishFrameAnimation != null) {
          mFinishFrameAnimation.setStartTime(0);
        }
        if (mRotateFrameAnimation != null) {
          mRotateFrameAnimation.setStartTime(now);
        }
      }
      if (mRotateEnterAnimation != null) {
        mRotateEnterAnimation.setStartTime(now);
      }
      if (mRotateExitAnimation != null) {
        mRotateExitAnimation.setStartTime(now);
      }
      mAnimRunning = true;
      mHalfwayPoint = now + mRotateEnterAnimation.getDuration() / 2;
    }

    return stepAnimation(now);
  }
Esempio n. 4
0
 @Override
 public void run() {
   // Abort if start time has been messed with, as this simulation is only designed to handle
   // standard situations.
   if ((animation.getStartTime() == startTime && animation.getStartOffset() == startOffset)
       && animation.getTransformation(
           startTime == Animation.START_ON_FIRST_FRAME
               ? SystemClock.uptimeMillis()
               : (startTime + startOffset + elapsedTime),
           new Transformation())
       &&
       // We can't handle infinitely repeating animations in the current scheduling model,
       // so abort after one iteration.
       !(animation.getRepeatCount() == Animation.INFINITE
           && elapsedTime >= animation.getDuration())) {
     // Update startTime if it had a value of Animation.START_ON_FIRST_FRAME
     startTime = animation.getStartTime();
     elapsedTime += ShadowChoreographer.getFrameInterval() / TimeUtils.NANOS_PER_MS;
     ShadowChoreographer.getInstance()
         .postCallback(Choreographer.CALLBACK_ANIMATION, this, null);
   } else {
     animationRunner = null;
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent callingIntent = getIntent();
    mAnimationType = callingIntent.getIntExtra("animation", KYLE_DEATH);

    if (mAnimationType == KYLE_DEATH) {
      setContentView(R.layout.animation_player);

      ImageView canvasImage = (ImageView) findViewById(R.id.animation_canvas);
      canvasImage.setImageResource(R.anim.kyle_fall);
      mAnimation = (AnimationDrawable) canvasImage.getDrawable();
    } else {
      if (mAnimationType == WANDA_ENDING || mAnimationType == KABOCHA_ENDING) {
        float startX = 0.0f;
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        if (mAnimationType == WANDA_ENDING) {
          setContentView(R.layout.good_ending_animation);
          startX = 200 * metrics.density;
        } else {
          setContentView(R.layout.kabocha_ending_animation);
          startX = -200 * metrics.density;
        }

        // HACK
        // The TranslateAnimation system doesn't support device independent
        // pixels. So for the Wanda ending and Kabocha endings, in which the
        // game over text scrolls in horizontally, compute the size based on
        // the actual density of the display and just generate the anim in
        // code.  The Rokudou animation can be safely loaded from a file.
        Animation gameOverAnim = new TranslateAnimation(startX, 0, 0, 0);
        gameOverAnim.setDuration(6000);
        gameOverAnim.setFillAfter(true);
        gameOverAnim.setFillEnabled(true);
        gameOverAnim.setStartOffset(8000);

        View background = findViewById(R.id.animation_background);
        View foreground = findViewById(R.id.animation_foreground);
        View gameOver = findViewById(R.id.game_over);

        Animation foregroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer2_slide);
        Animation backgroundAnim =
            AnimationUtils.loadAnimation(this, R.anim.horizontal_layer1_slide);

        background.startAnimation(backgroundAnim);
        foreground.startAnimation(foregroundAnim);
        gameOver.startAnimation(gameOverAnim);

        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else if (mAnimationType == ROKUDOU_ENDING) {
        setContentView(R.layout.rokudou_ending_animation);
        View background = findViewById(R.id.animation_background);
        View sphere = findViewById(R.id.animation_sphere);
        View cliffs = findViewById(R.id.animation_cliffs);
        View rokudou = findViewById(R.id.animation_rokudou);
        View gameOver = findViewById(R.id.game_over);

        Animation backgroundAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_bg);
        Animation sphereAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_sphere);
        Animation cliffsAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_cliffs);
        Animation rokudouAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_slide_rokudou);
        Animation gameOverAnim = AnimationUtils.loadAnimation(this, R.anim.rokudou_game_over);

        background.startAnimation(backgroundAnim);
        sphere.startAnimation(sphereAnim);
        cliffs.startAnimation(cliffsAnim);
        rokudou.startAnimation(rokudouAnim);
        gameOver.startAnimation(gameOverAnim);
        mAnimationEndTime = gameOverAnim.getDuration() + System.currentTimeMillis();
      } else {
        assert false;
      }
    }
    // Pass the calling intent back so that we can figure out which animation just played.
    setResult(RESULT_OK, callingIntent);
  }
 private long getNavBarExitDuration() {
   Animation exit = AnimationUtils.loadAnimation(this.mContext, 17432599);
   return exit != null ? exit.getDuration() : 0;
 }