Ejemplo n.º 1
0
  private void updateButtonState(SendButtonState buttonState) {
    if (mButtonState != buttonState) {
      mButtonState = buttonState;

      float translation = Units.dpToPx(mContext, 14) / 3;
      float barRotation1 = mButtonBar1.getRotation();
      float barTranslation1 = mButtonBar1.getTranslationY();
      float barRotation2 = mButtonBar2.getRotation();
      float barTranslation2 = mButtonBar2.getTranslationY();
      float barRotationTarget1 = mButtonState == SendButtonState.ATTACH ? 0 : 225;
      float barTranslationTarget1 = mButtonState == SendButtonState.SEND ? -translation : 0;
      float barRotationTarget2 = mButtonState == SendButtonState.ATTACH ? 90 : 135;
      float barTranslationTarget2 = mButtonState == SendButtonState.SEND ? translation : 0;

      ObjectAnimator.ofFloat(mButtonBar1, "rotation", barRotation1, barRotationTarget1)
          .setDuration(ANIMATION_DURATION)
          .start();
      ObjectAnimator.ofFloat(mButtonBar2, "rotation", barRotation2, barRotationTarget2)
          .setDuration(ANIMATION_DURATION)
          .start();
      ObjectAnimator.ofFloat(mButtonBar1, "translationY", barTranslation1, barTranslationTarget1)
          .setDuration(ANIMATION_DURATION)
          .start();
      ObjectAnimator.ofFloat(mButtonBar2, "translationY", barTranslation2, barTranslationTarget2)
          .setDuration(ANIMATION_DURATION)
          .start();
    }
  }
Ejemplo n.º 2
0
 @Override
 public void onAnimationEnd(Animator animation) {
   // TODO Auto-generated method stub
   Log.v(
       "Debug",
       "Animation End: "
           + bird.getY()
           + ".."
           + bird.getTop()
           + ".."
           + bird.getTranslationY());
   if (!isUpAnimationCancelled) {
     // start to drop
     // downAnimation.setFloatValues(deltaY);
     bird.layout(
         bird.getLeft(),
         (int) bird.getY(),
         bird.getRight(),
         (int) bird.getY() + bird.getMeasuredHeight());
     bird.setTranslationY(0);
     downAnimation.setFloatValues(startPosition - bird.getTop());
     downAnimation.start();
   }
 }
Ejemplo n.º 3
0
 @Override
 public void onAnimationCancel(Animator animation) {
   // TODO Auto-generated method stub
   Log.v("Debug", "Animation Cancelled: " + bird.getY() + ".." + bird.getTranslationY());
   isUpAnimationCancelled = true;
 }