public void setPressed(boolean pressed) {
   if (mGlowBG != null) {
     if (pressed != isPressed()) {
       if (mPressedAnim != null && mPressedAnim.isRunning()) {
         mPressedAnim.cancel();
       }
       final AnimatorSet as = mPressedAnim = new AnimatorSet();
       if (pressed) {
         if (mGlowScale < GLOW_MAX_SCALE_FACTOR) mGlowScale = GLOW_MAX_SCALE_FACTOR;
         if (mGlowAlpha < mQuiescentAlpha) mGlowAlpha = mQuiescentAlpha;
         setDrawingAlpha(1f);
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
             ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
         as.setDuration(50);
       } else {
         mAnimateToQuiescent.cancel();
         mAnimateToQuiescent = animateToQuiescent();
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 0f),
             ObjectAnimator.ofFloat(this, "glowScale", 1f),
             mAnimateToQuiescent);
         as.setDuration(500);
       }
       as.start();
     }
   }
   super.setPressed(pressed);
 }
 public void setPressed(boolean pressed) {
   if (mGlowBG != null) {
     if (pressed != isPressed()) {
       if (mPressedAnim != null && mPressedAnim.isRunning()) {
         mPressedAnim.cancel();
       }
       final AnimatorSet as = mPressedAnim = new AnimatorSet();
       if (pressed) {
         if (mGlowScale < GLOW_MAX_SCALE_FACTOR) mGlowScale = GLOW_MAX_SCALE_FACTOR;
         if (mGlowAlpha < BUTTON_QUIESCENT_ALPHA) mGlowAlpha = BUTTON_QUIESCENT_ALPHA;
         setDrawingAlpha(1f);
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
             ObjectAnimator.ofFloat(this, "glowScale", GLOW_MAX_SCALE_FACTOR));
         as.setDuration(50);
       } else {
         as.playTogether(
             ObjectAnimator.ofFloat(this, "glowAlpha", 0f),
             ObjectAnimator.ofFloat(this, "glowScale", 1f),
             ObjectAnimator.ofFloat(this, "drawingAlpha", BUTTON_QUIESCENT_ALPHA));
         as.setDuration(500);
       }
       as.start();
     }
   }
   super.setPressed(pressed);
 }
  private AnimatorSet createAnimationSet() {
    List<Animator> animators = new ArrayList<>();
    view.setLayerType(View.LAYER_TYPE_HARDWARE, null);

    if (!objectAnimations.isEmpty())
      for (AnimationParams customAnimation : objectAnimations) {
        animators.add(createAnimation(view, customAnimation));
      }

    if (this.animators != null)
      for (Animator animator : this.animators) {
        animators.add(animator);
      }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animators);
    if (interpolator != null) {
      animatorSet.setInterpolator(interpolator);
    }
    animatorSet.setDuration(duration);
    animatorSet.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            view.setLayerType(View.LAYER_TYPE_NONE, null);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setLayerType(View.LAYER_TYPE_NONE, null);
          }
        });
    return animatorSet;
  }
 private void applyMode(int mode, boolean animate) {
   if (mLeftSide == null) return; // pre-init
   float newAlpha = getNonBatteryClockAlphaFor(mode);
   float newAlphaBC = getBatteryClockAlpha(mode);
   if (mCurrentAnimation != null) {
     mCurrentAnimation.cancel();
   }
   if (animate) {
     AnimatorSet anims = new AnimatorSet();
     anims.playTogether(
         animateTransitionTo(mLeftSide, newAlpha),
         animateTransitionTo(mStatusIcons, newAlpha),
         animateTransitionTo(mSignalCluster, newAlpha),
         animateTransitionTo(mNetworkTraffic, newAlpha),
         animateTransitionTo(mBattery, newAlphaBC),
         animateTransitionTo(mClock, newAlphaBC));
     if (isLightsOut(mode)) {
       anims.setDuration(LIGHTS_OUT_DURATION);
     }
     anims.start();
     mCurrentAnimation = anims;
   } else {
     mLeftSide.setAlpha(newAlpha);
     mStatusIcons.setAlpha(newAlpha);
     mSignalCluster.setAlpha(newAlpha);
     mNetworkTraffic.setAlpha(newAlpha);
     mBattery.setAlpha(newAlphaBC);
     mClock.setAlpha(newAlphaBC);
   }
 }
 private void performSwitch() {
   ObjectAnimator animator1 =
       ObjectAnimator.ofFloat(
           mFirstView, "translationY", mFirstView.getTranslationY() - mBannerHeight);
   ObjectAnimator animator2 =
       ObjectAnimator.ofFloat(
           mSecondView, "translationY", mSecondView.getTranslationY() - mBannerHeight);
   AnimatorSet set = new AnimatorSet();
   set.playTogether(animator1, animator2);
   set.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           mFirstView.setTranslationY(0);
           mSecondView.setTranslationY(0);
           View removedView = getChildAt(0);
           mPosition++;
           mAdapter.setItem(removedView, mAdapter.getItem(mPosition % mAdapter.getCount()));
           removeView(removedView);
           addView(removedView, 1);
         }
       });
   set.setDuration(mAnimDuration);
   set.start();
 }
Esempio n. 6
0
  private void stopAnimator() {
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1, 0);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 1, 0);
    scaleXAnimator.setDuration(300);
    scaleXAnimator.setInterpolator(new LinearInterpolator());
    scaleYAnimator.setDuration(300);
    scaleYAnimator.setInterpolator(new LinearInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            isStart = false;
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
  private void animateHide() {
    bubbleHideAnimator = new AnimatorSet();
    this.setPivotX(this.getWidth());
    this.setPivotY(this.getHeight());
    Animator shrinkerX =
        ObjectAnimator.ofFloat(this, SCALE_X, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    Animator shrinkerY =
        ObjectAnimator.ofFloat(this, SCALE_Y, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    Animator alpha =
        ObjectAnimator.ofFloat(this, ALPHA, 1f, 0f).setDuration(BUBBLE_ANIMATION_DURATION);
    bubbleHideAnimator.setInterpolator(new AccelerateInterpolator());
    bubbleHideAnimator.playTogether(shrinkerX, shrinkerY, alpha);
    bubbleHideAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            FastScrollBubble.this.setVisibility(INVISIBLE);
            bubbleHideAnimator = null;
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            FastScrollBubble.this.setVisibility(INVISIBLE);
            bubbleHideAnimator = null;
          }
        });
    bubbleHideAnimator.start();
  }
Esempio n. 8
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @SuppressLint("NewApi")
  private void init() {
    mXAnimator = ObjectAnimator.ofFloat(this, "x", 0);
    mYAnimator = ObjectAnimator.ofFloat(this, "y", 0);
    mWAnimator = ObjectAnimator.ofInt(this, "wid", 0);
    mHAnimator = ObjectAnimator.ofInt(this, "hei", 0);
    mAnimatorSet = new AnimatorSet();
    mAnimatorSet.setDuration(AnimationDuration);
    mAnimatorSet.playTogether(mWAnimator, mHAnimator, mXAnimator, mYAnimator);
    mAnimatorSet.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            if (getVisibility() != View.VISIBLE) {
              setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}
        });
  }
  /** 下落 */
  public void freeFall() {

    ObjectAnimator objectAnimator =
        ObjectAnimator.ofFloat(shapeLoadingView, "translationY", 0, mDistance);
    ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(indicationIm, "scaleX", 1, 0.2f);

    objectAnimator.setDuration(ANIMATION_DURATION);
    objectAnimator.setInterpolator(new AccelerateInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(ANIMATION_DURATION);
    animatorSet.playTogether(objectAnimator, scaleIndication);
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {

            shapeLoadingView.changeShape();
            upThrow();
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
  @Override
  public void onTextSizeChanged(final TextView textView, float oldSize) {
    if (mCurrentState != CalculatorState.INPUT) { // TODO dont animate when showing graph
      // Only animate text changes that occur from user input.
      return;
    }

    // Calculate the values needed to perform the scale and translation animations,
    // maintaining the same apparent baseline for the displayed text.
    final float textScale = oldSize / textView.getTextSize();
    final float translationX;
    if (android.os.Build.VERSION.SDK_INT >= 17) {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd());
    } else {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingRight());
    }
    final float translationY =
        (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom());
    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
        ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.start();
  }
Esempio n. 11
0
 /**
  * 创建移动动画
  *
  * @param view
  * @param startX
  * @param endX
  * @param startY
  * @param endY
  * @return
  */
 private AnimatorSet createTranslationAnimations(
     View view, float startX, float endX, float startY, float endY) {
   ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
   ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY", startY, endY);
   AnimatorSet animSetXY = new AnimatorSet();
   animSetXY.playTogether(animX, animY);
   return animSetXY;
 }
 public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
   AnimatorSet set = new AnimatorSet();
   ObjectAnimator scaleXAnimator =
       ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
   ObjectAnimator scaleYAnimator =
       ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
   set.playTogether(scaleXAnimator, scaleYAnimator);
   return set;
 }
Esempio n. 13
0
  public void compatSetOrAnimatePlusCheckIcon(
      final ImageView imageView, boolean isCheck, boolean allowAnimate) {

    final int imageResId =
        isCheck
            ? R.drawable.add_schedule_button_icon_checked
            : R.drawable.add_schedule_button_icon_unchecked;

    if (imageView.getTag() != null) {
      if (imageView.getTag() instanceof Animator) {
        Animator anim = (Animator) imageView.getTag();
        anim.end();
        imageView.setAlpha(1f);
      }
    }

    if (allowAnimate && isCheck) {
      int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime);

      Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f);
      outAnimator.setDuration(duration / 2);
      outAnimator.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              imageView.setImageResource(imageResId);
            }
          });

      AnimatorSet inAnimator = new AnimatorSet();
      outAnimator.setDuration(duration);
      inAnimator.playTogether(
          ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f),
          ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f),
          ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f));

      AnimatorSet set = new AnimatorSet();
      set.playSequentially(outAnimator, inAnimator);
      set.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              imageView.setTag(null);
            }
          });
      imageView.setTag(set);
      set.start();
    } else {
      mHandler.post(
          new Runnable() {
            @Override
            public void run() {
              imageView.setImageResource(imageResId);
            }
          });
    }
  }
 /**
  * Creates a "grow and fade in from the bottom" animation for the specified view.
  *
  * @param view The view to animate
  */
 private static AnimatorSet createGrowFadeInFromBottom(View view) {
   AnimatorSet growFadeInFromBottomAnimation = new AnimatorSet();
   growFadeInFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(75));
   growFadeInFromBottomAnimation.setStartDelay(50);
   return growFadeInFromBottomAnimation;
 }
 /**
  * Creates a "shrink and fade out from bottom" animation for the specified view.
  *
  * @param view The view to animate
  * @param listener The animation listener
  */
 private static AnimatorSet createShrinkFadeOutFromBottomAnimation(
     View view, Animator.AnimatorListener listener) {
   AnimatorSet shrinkFadeOutFromBottomAnimation = new AnimatorSet();
   shrinkFadeOutFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 1, 0.5f).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0).setDuration(75));
   shrinkFadeOutFromBottomAnimation.setStartDelay(150);
   shrinkFadeOutFromBottomAnimation.addListener(listener);
   return shrinkFadeOutFromBottomAnimation;
 }
Esempio n. 16
0
  @Override
  public void startAnimation(
      final ViewHolder holder, long duration, final BaseItemAnimator animator) {

    System.out.println("startAnimation");

    float x =
        (holder.itemView.getWidth()
                    - holder.itemView.getPaddingLeft()
                    - holder.itemView.getPaddingRight())
                / 2
            + holder.itemView.getPaddingLeft();
    float y = holder.itemView.getHeight() - holder.itemView.getPaddingBottom();

    AnimatorSet set = new AnimatorSet();

    set.playTogether(
        ObjectAnimator.ofFloat(holder.itemView, "pivotX", x, x, x, x, x),
        ObjectAnimator.ofFloat(holder.itemView, "pivotY", y, y, y, y, y),
        ObjectAnimator.ofFloat(holder.itemView, "rotationX", 90, 55, -30, 15, -15, 0));
    set.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animator animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            // TODO Auto-generated method stub

          }
        });
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();

    animator.mAddAnimations.add(holder);
  }
Esempio n. 17
0
  private AnimatorSet buildAnimationSet(int duration, ObjectAnimator... objectAnimators) {

    AnimatorSet a = new AnimatorSet();
    a.playTogether(objectAnimators);
    a.setInterpolator(
        AnimationUtils.loadInterpolator(
            EventActivity.this, android.R.interpolator.accelerate_decelerate));
    a.setDuration(duration);

    return a;
  }
Esempio n. 18
0
 private void startAnimator() {
   ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.0f, 1);
   ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 0.0f, 1);
   scaleXAnimator.setDuration(300);
   scaleXAnimator.setInterpolator(new LinearInterpolator());
   scaleYAnimator.setDuration(300);
   scaleYAnimator.setInterpolator(new LinearInterpolator());
   AnimatorSet animatorSet = new AnimatorSet();
   animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
   animatorSet.start();
 }
  @SuppressWarnings("ConstantConditions")
  private void animateIn() {
    text.setX(xText);
    image.setX(xImage);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(
        ObjectAnimator.ofFloat(text, "translationX", 0),
        ObjectAnimator.ofFloat(image, "translationX", 0));
    set.start();
  }
Esempio n. 20
0
  private void animatePhotoLike(final CellFeedViewHolder holder) {
    if (!likeAnimations.containsKey(holder)) {
      holder.vBgLike.setVisibility(View.VISIBLE);
      holder.ivLike.setVisibility(View.VISIBLE);

      holder.vBgLike.setScaleY(0.1f);
      holder.vBgLike.setScaleX(0.1f);
      holder.vBgLike.setAlpha(1f);
      holder.ivLike.setScaleY(0.1f);
      holder.ivLike.setScaleX(0.1f);

      AnimatorSet animatorSet = new AnimatorSet();
      likeAnimations.put(holder, animatorSet);

      ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleY", 0.1f, 1f);
      bgScaleYAnim.setDuration(200);
      bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
      ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(holder.vBgLike, "scaleX", 0.1f, 1f);
      bgScaleXAnim.setDuration(200);
      bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
      ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(holder.vBgLike, "alpha", 1f, 0f);
      bgAlphaAnim.setDuration(200);
      bgAlphaAnim.setStartDelay(150);
      bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

      ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 0.1f, 1f);
      imgScaleUpYAnim.setDuration(300);
      imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
      ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 0.1f, 1f);
      imgScaleUpXAnim.setDuration(300);
      imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

      ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleY", 1f, 0f);
      imgScaleDownYAnim.setDuration(300);
      imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
      ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(holder.ivLike, "scaleX", 1f, 0f);
      imgScaleDownXAnim.setDuration(300);
      imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

      animatorSet.playTogether(
          bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
      animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

      animatorSet.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              resetLikeAnimationState(holder);
            }
          });
      animatorSet.start();
    }
  }
  public void startAnimation() {
    if (animationEnabled) {
      if (windowAnimatorSet != null) {
        return;
      }
      ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
      content.setTranslationY(0);
      content.setAlpha(1.0f);
      content.setPivotX(content.getMeasuredWidth());
      content.setPivotY(0);
      int count = content.getItemsCount();
      content.positions.clear();
      int visibleCount = 0;
      for (int a = 0; a < count; a++) {
        View child = content.getItemAt(a);
        if (child.getVisibility() != View.VISIBLE) {
          continue;
        }
        content.positions.put(child, visibleCount);
        child.setAlpha(0.0f);
        visibleCount++;
      }
      if (content.showedFromBotton) {
        content.lastStartedChild = count - 1;
      } else {
        content.lastStartedChild = 0;
      }
      windowAnimatorSet = new AnimatorSet();
      windowAnimatorSet.playTogether(
          ObjectAnimator.ofFloat(content, "backScaleY", 0.0f, 1.0f),
          ObjectAnimator.ofInt(content, "backAlpha", 0, 255));
      windowAnimatorSet.setDuration(150 + 16 * visibleCount);
      windowAnimatorSet.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              windowAnimatorSet = null;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
              onAnimationEnd(animation);
            }

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
      windowAnimatorSet.start();
    }
  }
 private void startChildAnimation(View child) {
   if (animationEnabled) {
     AnimatorSet animatorSet = new AnimatorSet();
     animatorSet.playTogether(
         ObjectAnimator.ofFloat(child, "alpha", 0.0f, 1.0f),
         ObjectAnimator.ofFloat(
             child, "translationY", AndroidUtilities.dp(showedFromBotton ? 6 : -6), 0));
     animatorSet.setDuration(180);
     animatorSet.setInterpolator(decelerateInterpolator);
     animatorSet.start();
   }
 }
Esempio n. 23
0
 private void addAnimation(View view) {
   float[] vaules =
       new float[] {
         0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.25f, 1.2f, 1.15f, 1.1f, 1.0f
       };
   AnimatorSet set = new AnimatorSet();
   set.playTogether(
       ObjectAnimator.ofFloat(view, "scaleX", vaules),
       ObjectAnimator.ofFloat(view, "scaleY", vaules));
   set.setDuration(150);
   set.start();
 }
Esempio n. 24
0
  @SuppressLint("NewApi")
  public void onRevealAnimationProgress(boolean open, float radius, int x, int y) {
    if (!open) {
      return;
    }
    int count = Build.VERSION.SDK_INT <= 19 ? 11 : 8;
    for (int a = 0; a < count; a++) {
      if (views[a].getTag(R.string.AppName) == null) {
        if (distCache[a] == 0) {
          int buttonX = views[a].getLeft() + views[a].getMeasuredWidth() / 2;
          int buttonY = views[a].getTop() + views[a].getMeasuredHeight() / 2;
          distCache[a] =
              (float) Math.sqrt((x - buttonX) * (x - buttonX) + (y - buttonY) * (y - buttonY));
          float vecX = (x - buttonX) / distCache[a];
          float vecY = (y - buttonY) / distCache[a];
          views[a].setPivotX(views[a].getMeasuredWidth() / 2 + vecX * AndroidUtilities.dp(20));
          views[a].setPivotY(views[a].getMeasuredHeight() / 2 + vecY * AndroidUtilities.dp(20));
        }
        if (distCache[a] > radius + AndroidUtilities.dp(27)) {
          continue;
        }

        views[a].setTag(R.string.AppName, 1);
        final ArrayList<Animator> animators = new ArrayList<>();
        final ArrayList<Animator> animators2 = new ArrayList<>();
        if (a < 8) {
          animators.add(ObjectAnimator.ofFloat(views[a], "scaleX", 0.7f, 1.05f));
          animators.add(ObjectAnimator.ofFloat(views[a], "scaleY", 0.7f, 1.05f));
          animators2.add(ObjectAnimator.ofFloat(views[a], "scaleX", 1.0f));
          animators2.add(ObjectAnimator.ofFloat(views[a], "scaleY", 1.0f));
        }
        if (Build.VERSION.SDK_INT <= 19) {
          animators.add(ObjectAnimator.ofFloat(views[a], "alpha", 1.0f));
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        animatorSet.setDuration(150);
        animatorSet.setInterpolator(decelerateInterpolator);
        animatorSet.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(animators2);
                animatorSet.setDuration(100);
                animatorSet.setInterpolator(decelerateInterpolator);
                animatorSet.start();
              }
            });
        animatorSet.start();
      }
    }
  }
 private void runImeAnimations(boolean entering) {
   ArrayList<Animator> animators = new ArrayList<Animator>();
   if (entering) {
     mGuidanceStylist.onImeAppearing(animators);
     mActionsStylist.onImeAppearing(animators);
   } else {
     mGuidanceStylist.onImeDisappearing(animators);
     mActionsStylist.onImeDisappearing(animators);
   }
   AnimatorSet set = new AnimatorSet();
   set.playTogether(animators);
   set.start();
 }
Esempio n. 26
0
  private void animBottom(View v) {
    ObjectAnimator animator_x = ObjectAnimator.ofFloat(v, View.ALPHA, 0f, 1f);
    animator_x.setDuration(ANIMATION_DURATION_BASE * 2);
    int y = v.getTop();
    if (mStart) y += vh.ll_parent.getPaddingTop();
    ObjectAnimator animator_y = ObjectAnimator.ofFloat(v, "y", +1400, y);
    animator_y.setDuration(ANIMATION_DURATION_BASE);

    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(new LinearInterpolator());
    set.playTogether(animator_x, animator_y);
    set.start();
  }
Esempio n. 27
0
 private void onDialogShowing() {
   if (animatorSetForDialogShow != null
       && objectAnimatorsForDialogShow != null
       && objectAnimatorsForDialogShow.size() > 0) {
     animatorSetForDialogShow.playTogether(objectAnimatorsForDialogShow);
     animatorSetForDialogShow.start();
   }
   // TODO 缩放的动画效果不好,不能从控件所在的位置开始缩放
   //        ObjectAnimator.ofFloat(rlOutsideBackground.findViewById(R.id.rlParentForAnimate),
   // "scaleX", 0.3f, 1.0f).setDuration(500).start();
   //        ObjectAnimator.ofFloat(rlOutsideBackground.findViewById(R.id.rlParentForAnimate),
   // "scaleY", 0.3f, 1.0f).setDuration(500).start();
 }
 @SuppressWarnings("ConstantConditions")
 private void animateOut() {
   AnimatorSet set = new AnimatorSet();
   set.playTogether(
       ObjectAnimator.ofFloat(text, "x", xText), ObjectAnimator.ofFloat(image, "x", xImage));
   set.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           ActivityTransitionAnimation2.super.onBackPressed();
           overridePendingTransition(0, 0);
         }
       });
   set.start();
 }
  /** Shows the toast. */
  private void transitionToVisible() {
    if (mDecorAnimation != null) {
      mDecorAnimation.cancel();
    }

    final Animator fadeIn =
        groupAnimatorOfFloat(View.ALPHA, 1f, mPreviewImage, mPrimaryText, mSecondaryText)
            .setDuration(DURATION_FADE_IN);

    mDecorAnimation = new AnimatorSet();
    mDecorAnimation.playTogether(fadeIn);
    mDecorAnimation.start();

    mShowingPreview = true;
  }
  /** Shows nothing. */
  private void transitionToHidden() {
    if (mDecorAnimation != null) {
      mDecorAnimation.cancel();
    }

    final Animator fadeOut =
        groupAnimatorOfFloat(View.ALPHA, 0f, mPreviewImage, mPrimaryText, mSecondaryText)
            .setDuration(DURATION_FADE_OUT);

    mDecorAnimation = new AnimatorSet();
    mDecorAnimation.playTogether(fadeOut);
    mDecorAnimation.start();

    mShowingPreview = false;
  }