コード例 #1
0
  /** Show post-send animation */
  public void showPostSend() {
    if (!mAttached) {
      return;
    }

    mSlowSendAnimator.cancel();
    mTextHint.setVisibility(View.GONE);

    float currentScale = mScreenshotView.getScaleX();

    // Modify the fast clone parameters to match the current scale
    PropertyValuesHolder postX =
        PropertyValuesHolder.ofFloat("scaleX", new float[] {currentScale, 0.0f});
    PropertyValuesHolder postY =
        PropertyValuesHolder.ofFloat("scaleY", new float[] {currentScale, 0.0f});
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", new float[] {1.0f, 0.0f});
    mFastCloneAnimator.setValues(postX, postY, alpha);

    // Modify the fadeIn parameters to match the current scale
    PropertyValuesHolder fadeIn = PropertyValuesHolder.ofFloat("alpha", new float[] {0.0f, 1.0f});
    mFadeInAnimator.setValues(fadeIn);

    if (mFireflyRenderThread != null) {
      mFireflyRenderThread.fadeOut();
    }

    mSuccessAnimatorSet.start();
  }
コード例 #2
0
    public static void animateShowing(
        final ViewHolder holder, final ListAdapter adapter, boolean isAnimate) {
      final CheckBox checkBox = holder.checkBox;
      if (checkBox.getVisibility() == View.VISIBLE) {
        return;
      }
      checkBox.setVisibility(View.VISIBLE);
      checkBox.setAlpha(0.0f);
      final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      checkBox.measure(widthSpec, heightSpec);
      ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) checkBox.getLayoutParams();
      final long transValue = checkBox.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;

      if (!isAnimate) {
        checkBox.setAlpha(1.0f);
        holder.contentLayout.setTranslationX(transValue);
        return;
      }

      final ObjectAnimator transBodyAnimator = new ObjectAnimator();
      final PropertyValuesHolder trans =
          PropertyValuesHolder.ofFloat("TranslationX", 0.0f, transValue);
      transBodyAnimator.setTarget(holder.contentLayout);
      transBodyAnimator.setValues(trans);
      transBodyAnimator.setDuration(DURATION);

      ObjectAnimator checkBoxAnim = new ObjectAnimator();
      final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("ScaleX", 0.0f, 1.0f);
      final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("ScaleY", 0.0f, 1.0f);
      final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("Alpha", 0.0f, 1.0f);
      checkBoxAnim.setValues(scaleX, scaleY, alpha);
      checkBoxAnim.setTarget(holder.checkBox);
      checkBoxAnim.setDuration(DURATION);
      checkBoxAnim.setInterpolator(new DecelerateInterpolator());
      checkBoxAnim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              checkBox.setTag("animating");
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              // adapter.setCheckBoxAnimator(false);
              checkBox.setTag("animated");
            }
          });
      if (!(checkBox.getTag() != null && "animating".equals(checkBox.getTag()))) {
        // 若正在播放动画,则不继续播放动画
        transBodyAnimator.start();
        checkBoxAnim.start();
      }
    }
コード例 #3
0
    public static void animateHiding(
        final ViewHolder holder, final ListAdapter adapter, boolean isAnimate) {
      final CheckBox checkBox = holder.checkBox;
      final View tansBody = holder.contentLayout;

      if (checkBox.getVisibility() == View.GONE) {
        return;
      }
      ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) checkBox.getLayoutParams();
      final float transValue = checkBox.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;

      if (!isAnimate) {
        checkBox.setVisibility(View.GONE);
        holder.contentLayout.setTranslationX(0.0f);
        return;
      }
      final ObjectAnimator transBodyAnimator = new ObjectAnimator();
      final PropertyValuesHolder trans =
          PropertyValuesHolder.ofFloat("TranslationX", transValue, 0.0f);
      transBodyAnimator.setTarget(tansBody);
      transBodyAnimator.setValues(trans);
      transBodyAnimator.setDuration(DURATION);

      ObjectAnimator checkBoxAnim = new ObjectAnimator();
      final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("ScaleX", 1.0f, 0.0f);
      final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("ScaleY", 1.0f, 0.0f);
      final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("Alpha", 1.0f, 0.0f);
      checkBoxAnim.setValues(scaleX, scaleY, alpha);
      checkBoxAnim.setTarget(checkBox);
      checkBoxAnim.setDuration(DURATION);
      checkBoxAnim.setInterpolator(new AccelerateInterpolator());
      checkBoxAnim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              checkBox.setTag("animating");
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              // adapter.setCheckBoxAnimator(false);
              checkBox.setScaleX(1.0f);
              checkBox.setScaleY(1.0f);
              checkBox.setAlpha(1.0f);
              checkBox.setVisibility(View.GONE);
              checkBox.setTag("animated");
            }
          });
      if (!(checkBox.getTag() != null && "animating".equals(checkBox.getTag()))) {
        transBodyAnimator.start();
        checkBoxAnim.start();
      }
    }
コード例 #4
0
 public static ObjectAnimator ofPropertyValuesHolder(View target, PropertyValuesHolder... values) {
   ObjectAnimator anim = new ObjectAnimator();
   anim.setTarget(target);
   anim.setValues(values);
   cancelOnDestroyActivity(anim);
   new FirstFrameAnimatorHelper(anim, target);
   return anim;
 }