/**
   * Constructs an animator for the specified property on a group of views. See {@link
   * ObjectAnimator#ofFloat(Object, String, float...)} for implementation details.
   *
   * @param property The property being animated.
   * @param value The value to which that property should animate.
   * @param views The target views to animate.
   * @return An animator for all the specified views.
   */
  private static Animator groupAnimatorOfFloat(
      Property<View, Float> property, float value, View... views) {
    AnimatorSet animSet = new AnimatorSet();
    AnimatorSet.Builder builder = null;

    for (int i = views.length - 1; i >= 0; i--) {
      final Animator anim = ObjectAnimator.ofFloat(views[i], property, value);
      if (builder == null) {
        builder = animSet.play(anim);
      } else {
        builder.with(anim);
      }
    }

    return animSet;
  }
Example #2
0
  private void runMenuItemEnterAnimations() {
    mMenuItemEnterAnimator = new AnimatorSet();
    AnimatorSet.Builder builder = null;

    ViewGroup list = mPopup.getListView();
    for (int i = 0; i < list.getChildCount(); i++) {
      View view = list.getChildAt(i);
      Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id);
      if (animatorObject != null) {
        if (builder == null) {
          builder = mMenuItemEnterAnimator.play((Animator) animatorObject);
        } else {
          builder.with((Animator) animatorObject);
        }
      }
    }

    mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder);
    mMenuItemEnterAnimator.start();
  }