/** 开启打开动画 */
  private void startAnim() {
    ObjectAnimator tranAnimY = ObjectAnimator.ofFloat(mMenuViewSmall, "translationY", 0, -20);
    ObjectAnimator tranAnimPointX =
        ObjectAnimator.ofFloat(mMenuViewSmall, "translationX", 0, viewMoveX);
    ObjectAnimator tranAnimPointY =
        ObjectAnimator.ofFloat(mMenuViewSmall, "translationY", -20, viewMoveY);
    ObjectAnimator scaleAnimX =
        ObjectAnimator.ofFloat(mMenuViewSmall, "scaleX", 1.0f, (toValueX + 1.0f));
    ObjectAnimator scaleAnimY =
        ObjectAnimator.ofFloat(mMenuViewSmall, "scaleY", 1.0f, (toValueY + 1.0f));
    AnimatorSet set = new AnimatorSet();
    set.setDuration(500);
    set.play(tranAnimY)
        .before(tranAnimPointX)
        .before(tranAnimPointY)
        .before(scaleAnimX)
        .before(scaleAnimY);

    scaleAnimX.addUpdateListener(
        new AnimatorUpdateListener() {

          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            //				mMenuViewSmall.setScaleX(value);
            mContentView.setAlpha((float) (1 - ((value - 1) / toValueX) * 0.5));
            mContentView.setScaleX((float) (1 - ((value - 1) / toValueX) * 0.2));
            mContentView.setScaleY((float) (1 - ((value - 1) / toValueX) * 0.2));
          }
        });

    set.addListener(this);
    set.start();
  }
Пример #2
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();
  }
Пример #3
0
  /** 下落 */
  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();
  }
  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();
  }
Пример #5
0
  public void showFullToolbar(int duration) {
    mIsToolbarShown = true;

    final AnimatorSet animatorSet =
        buildAnimationSet(
            duration,
            buildAnimation(mToolbarView, -mToolbarHeight, 0),
            buildAnimation(mTitle, -mToolbarHeight, 0));

    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animator) {
            updateFlexibleSpaceText(mScrollY); // dirty update fling-fix
          }

          @Override
          public void onAnimationEnd(Animator animator) {
            updateFlexibleSpaceText(mScrollY); // dirty update fling-fix
          }

          @Override
          public void onAnimationCancel(Animator animator) {}

          @Override
          public void onAnimationRepeat(Animator animator) {}
        });

    animatorSet.start();
  }
 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();
 }
Пример #7
0
  private void startAnimation(View img, final Intent intent) {
    // ObjectAnimator oaTranslationX = ObjectAnimator.ofFloat(img,
    // "translationX", 0, mScreenWidth / 2);
    // ObjectAnimator oaTranslationY = ObjectAnimator.ofFloat(img,
    // "translationY", 0, mScreenHeight / 2);
    ObjectAnimator oaScaleX = ObjectAnimator.ofFloat(img, "scaleX", 0.5f, 1.2f, 1f);
    ObjectAnimator oaScaleY = ObjectAnimator.ofFloat(img, "scaleY", 0.5f, 1.2f, 1f);

    // oaTranslationX.setDuration(1000);
    // oaTranslationY.setDuration(1000);
    // oaScaleX.setDuration(1000);
    // oaScaleY.setDuration(1000);
    AnimatorSet set = new AnimatorSet();
    set.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            isLocked = true;
            super.onAnimationStart(animation);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            Log.e("", "动画完成");
            isLocked = false;

            startActivity(intent);
          }
        });
    set.play(oaScaleX).with(oaScaleY);
    set.setDuration(500);
    if (!isLocked) {
      set.start();
    }
  }
  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 animateFadeOutFadeIn(final View src, final View dst) {
    if (dst.getVisibility() != View.VISIBLE || dst.getAlpha() != 1f) {
      AnimatorSet set = new AnimatorSet();
      set.playSequentially(
          ObjectAnimator.ofFloat(src, "alpha", 0f), ObjectAnimator.ofFloat(dst, "alpha", 1f));
      set.setInterpolator(new LinearInterpolator());
      set.addListener(
          new AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
              src.setAlpha(1f);
              dst.setAlpha(0f);
              src.setVisibility(View.VISIBLE);
              dst.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              src.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {}
          });
      set.setDuration(250);
      set.start();
    } else {
      src.setAlpha(1f);
      src.setVisibility(View.GONE);
    }
  }
Пример #10
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) {}
        });
  }
Пример #11
0
 /**
  * Set a listener before the start of the animation.
  *
  * @param listenerStart an interface called before the animation
  * @return AnimatorSetBuilder.
  */
 public AnimatorSetBuilder listenerStart(final AnimatorBuilder.ListenerStart listenerStart) {
   this.listenerStart = listenerStart;
   if (pathViewAnimatorListener == null) {
     pathViewAnimatorListener = new PathViewAnimatorListener();
     animatorSet.addListener(pathViewAnimatorListener);
   }
   return this;
 }
Пример #12
0
 /**
  * Set a listener after of the animation.
  *
  * @param animationEnd an interface called after the animation
  * @return AnimatorSetBuilder.
  */
 public AnimatorSetBuilder listenerEnd(final AnimatorBuilder.ListenerEnd animationEnd) {
   this.animationEnd = animationEnd;
   if (pathViewAnimatorListener == null) {
     pathViewAnimatorListener = new PathViewAnimatorListener();
     animatorSet.addListener(pathViewAnimatorListener);
   }
   return this;
 }
  @Override
  public void animate() {
    final ViewGroup parentView = (ViewGroup) view.getParent();
    final FrameLayout slideOutFrame = new FrameLayout(view.getContext());
    final int positionView = parentView.indexOfChild(view);
    slideOutFrame.setLayoutParams(view.getLayoutParams());
    slideOutFrame.setClipChildren(true);
    parentView.removeView(view);
    slideOutFrame.addView(view);
    parentView.addView(slideOutFrame, positionView);

    switch (direction) {
      case DIRECTION_LEFT:
        slideAnim =
            ObjectAnimator.ofFloat(
                view, View.TRANSLATION_X, view.getTranslationX() - view.getWidth());
        break;
      case DIRECTION_RIGHT:
        slideAnim =
            ObjectAnimator.ofFloat(
                view, View.TRANSLATION_X, view.getTranslationX() + view.getWidth());
        break;
      case DIRECTION_UP:
        slideAnim =
            ObjectAnimator.ofFloat(
                view, View.TRANSLATION_Y, view.getTranslationY() - view.getHeight());
        break;
      case DIRECTION_DOWN:
        slideAnim =
            ObjectAnimator.ofFloat(
                view, View.TRANSLATION_Y, view.getTranslationY() + view.getHeight());
        break;
      default:
        break;
    }

    AnimatorSet slideSet = new AnimatorSet();
    slideSet.play(slideAnim);
    slideSet.setInterpolator(interpolator);
    slideSet.setDuration(duration);
    slideSet.addListener(
        new AnimatorListenerAdapter() {

          @Override
          public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.INVISIBLE);
            slideAnim.reverse();
            slideOutFrame.removeAllViews();
            parentView.removeView(slideOutFrame);
            parentView.addView(view, positionView);
            if (getListener() != null) {
              getListener().onAnimationEnd(SlideOutUnderneathAnimation.this);
            }
          }
        });
    slideSet.start();
  }
Пример #14
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);
            }
          });
    }
  }
  @Override
  public void showFabs() {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(hideTextContainer());
    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            animatedTextContainer = true;
          }

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

            ViewGroup.MarginLayoutParams lp =
                (ViewGroup.MarginLayoutParams) viewHolder.rvChat.getLayoutParams();
            Log.d(
                "height = ",
                String.valueOf(
                    ((ViewGroup.LayoutParams) viewHolder.textContainer.getLayoutParams()).height));
            lp.setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, 0);

            viewHolder.rvChat.requestLayout();
            viewHolder.rvChat.scrollToPosition(0);

            viewHolder.fabAdd.setImageResource(R.drawable.add);
            AnimatorSet newAnimatorSet = new AnimatorSet();
            viewHolder.fabAdd.setAlpha(0.64f);
            newAnimatorSet.playTogether(createExpandAnimator(viewHolder.fabAdd, offset));
            newAnimatorSet.addListener(
                new Animator.AnimatorListener() {
                  @Override
                  public void onAnimationStart(Animator animation) {}

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

                  @Override
                  public void onAnimationCancel(Animator animation) {}

                  @Override
                  public void onAnimationRepeat(Animator animation) {}
                });
            newAnimatorSet.start();
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
 /**
  * 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;
 }
Пример #17
0
 public void animateToVisibility(int visibility) {
   if (mVisibilityAnim != null) {
     mVisibilityAnim.cancel();
   }
   if (visibility == VISIBLE) {
     if (getVisibility() != VISIBLE) {
       setAlpha(0);
       if (mSplitView != null && mMenuView != null) {
         mMenuView.setAlpha(0);
       }
     }
     ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 1);
     anim.setDuration(FADE_DURATION);
     anim.setInterpolator(sAlphaInterpolator);
     if (mSplitView != null && mMenuView != null) {
       AnimatorSet set = new AnimatorSet();
       ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 1);
       splitAnim.setDuration(FADE_DURATION);
       set.addListener(mVisAnimListener.withFinalVisibility(visibility));
       set.play(anim).with(splitAnim);
       set.start();
     } else {
       anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
       anim.start();
     }
   } else {
     ObjectAnimator anim = ObjectAnimator.ofFloat(this, "alpha", 0);
     anim.setDuration(FADE_DURATION);
     anim.setInterpolator(sAlphaInterpolator);
     if (mSplitView != null && mMenuView != null) {
       AnimatorSet set = new AnimatorSet();
       ObjectAnimator splitAnim = ObjectAnimator.ofFloat(mMenuView, "alpha", 0);
       splitAnim.setDuration(FADE_DURATION);
       set.addListener(mVisAnimListener.withFinalVisibility(visibility));
       set.play(anim).with(splitAnim);
       set.start();
     } else {
       anim.addListener(mVisAnimListener.withFinalVisibility(visibility));
       anim.start();
     }
   }
 }
Пример #18
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);
  }
Пример #19
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();
    }
  }
Пример #20
0
  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();
    }
  }
Пример #21
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();
      }
    }
  }
Пример #22
0
  @Override
  public AnimatorSet createAnimatorSet() {
    ViewHelper.setClipChildren(targetView, false);

    AnimatorSet rotationSet = new AnimatorSet();
    rotationSet.play(
        ObjectAnimator.ofFloat(targetView, View.ROTATION, targetView.getRotation() + degrees));
    rotationSet.setInterpolator(interpolator);
    rotationSet.setDuration(duration);
    if (listener != null) {
      rotationSet.addListener(listener);
    }

    return rotationSet;
  }
 @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();
 }
Пример #24
0
  public void dismiss(boolean animated) {
    setFocusable(false);
    if (animationEnabled && animated) {
      if (windowAnimatorSet != null) {
        windowAnimatorSet.cancel();
      }
      ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
      windowAnimatorSet = new AnimatorSet();
      windowAnimatorSet.playTogether(
          ObjectAnimator.ofFloat(
              content, "translationY", AndroidUtilities.dp(content.showedFromBotton ? 5 : -5)),
          ObjectAnimator.ofFloat(content, "alpha", 0.0f));
      windowAnimatorSet.setDuration(150);
      windowAnimatorSet.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              windowAnimatorSet = null;
              setFocusable(false);
              try {
                ActionBarPopupWindow.super.dismiss();
              } catch (Exception e) {
                // don't promt
              }
              unregisterListener();
            }

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

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
      windowAnimatorSet.start();
    } else {
      try {
        super.dismiss();
      } catch (Exception e) {
        // don't promt
      }
      unregisterListener();
    }
  }
Пример #25
0
  /** 上抛 */
  public void upThrow() {

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

    ObjectAnimator objectAnimator1 = null;
    switch (shapeLoadingView.getShape()) {
      case SHAPE_RECT:
        objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, -120);

        break;
      case SHAPE_CIRCLE:
        objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, 180);

        break;
      case SHAPE_TRIANGLE:
        objectAnimator1 = ObjectAnimator.ofFloat(shapeLoadingView, "rotation", 0, 180);

        break;
    }

    objectAnimator.setDuration(ANIMATION_DURATION);
    objectAnimator1.setDuration(ANIMATION_DURATION);
    objectAnimator.setInterpolator(new DecelerateInterpolator());
    objectAnimator1.setInterpolator(new DecelerateInterpolator());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(ANIMATION_DURATION);
    animatorSet.playTogether(objectAnimator, objectAnimator1, scaleIndication);

    animatorSet.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

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

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    animatorSet.start();
  }
Пример #26
0
 public void callBackNewTabAnim() {
   // mApplication.setmThumbnailPosition(mBuilder.mCurrentConfigPosition);
   int endPosition = mBuilder.getList().size() - 1;
   Browser application = (Browser) mActivity.getApplication();
   int startPosition = application.getmThumbnailPosition();
   if (startPosition < 0 || startPosition >= mBuilder.getList().size()) startPosition = 0;
   AnimatorSet moveAnim = null;
   int width = getWidth();
   int animTime = getResources().getInteger(R.integer.config_shortAnimTime);
   if (endPosition == startPosition) {
     mUi.openNewTab();
   } else {
     ObjectAnimator oTran;
     ArrayList<Animator> animList = new ArrayList<Animator>();
     for (int i = startPosition; i <= endPosition; i++) {
       if (i != endPosition) {
         oTran =
             ObjectAnimator.ofFloat(
                 mBuilder.getList().get(i), "translationX", 0, -(i - startPosition + 1) * width);
         oTran.setStartDelay(DELAYTIME * (i - startPosition));
         oTran.setDuration(animTime * (i - startPosition + 1));
       } else {
         oTran =
             ObjectAnimator.ofFloat(
                 mBuilder.getList().get(i),
                 "translationX",
                 0,
                 -(endPosition - startPosition) * width);
         oTran.setStartDelay(DELAYTIME * (endPosition - startPosition));
         oTran.setDuration(animTime * (endPosition - startPosition));
       }
       animList.add(oTran);
     }
     moveAnim = new AnimatorSet();
     moveAnim.playTogether(animList);
     moveAnim.addListener(
         new AnimatorListenerAdapter() {
           @Override
           public void onAnimationEnd(Animator animation) {
             mUi.openNewTab();
             reverse(animation, 0);
             super.onAnimationEnd(animation);
           }
         });
     moveAnim.start();
   }
 }
Пример #27
0
  @SuppressLint("NewApi")
  private void onDialogDismiss() {
    if (animatorSetForDialogDismiss.isRunning()) {
      return;
    }
    if (animatorSetForDialogDismiss != null
        && objectAnimatorsForDialogDismiss != null
        && objectAnimatorsForDialogDismiss.size() > 0) {
      animatorSetForDialogDismiss.playTogether(objectAnimatorsForDialogDismiss);
      animatorSetForDialogDismiss.start();
      animatorSetForDialogDismiss.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {}

            @Override
            public void onAnimationEnd(Animator animation) {
              // 这里有可能会有bug,当Dialog所依赖的Activity关闭的时候,如果这个时候,用户关闭对话框,由于对话框的动画关闭需要时间,当动画执行完毕后,对话框所依赖的Activity已经被销毁了,执行dismiss()就会报错
              if (context != null && context instanceof Activity) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                  if (!((Activity) context).isDestroyed()) {
                    dialog.dismiss();
                  }
                } else {
                  try {
                    dialog.dismiss();
                  } catch (final IllegalArgumentException e) {

                  } catch (final Exception e) {

                  } finally {
                    dialog = null;
                  }
                }
              }
            }

            @Override
            public void onAnimationCancel(Animator animation) {}

            @Override
            public void onAnimationRepeat(Animator animation) {}
          });
    } else {
      dialog.dismiss();
    }
  }
Пример #28
0
  /**
   * item的交换动画效果
   *
   * @param oldPosition
   * @param newPosition
   */
  private void animateReorder(final int oldPosition, final int newPosition) {
    boolean isForward = newPosition > oldPosition;
    List<Animator> resultList = new LinkedList<Animator>();
    if (isForward) {
      for (int pos = oldPosition; pos < newPosition; pos++) {
        View view = getChildAt(pos - getFirstVisiblePosition());
        System.out.println(pos);

        if ((pos + 1) % getNumColumns() == 0) {
          resultList.add(
              createTranslationAnimations(
                  view, -view.getWidth() * (getNumColumns() - 1), 0, view.getHeight(), 0));
        } else {
          resultList.add(createTranslationAnimations(view, view.getWidth(), 0, 0, 0));
        }
      }
    } else {
      for (int pos = oldPosition; pos > newPosition; pos--) {
        View view = getChildAt(pos - getFirstVisiblePosition());
        if ((pos + getNumColumns()) % getNumColumns() == 0) {
          resultList.add(
              createTranslationAnimations(
                  view, view.getWidth() * (getNumColumns() - 1), 0, -view.getHeight(), 0));
        } else {
          resultList.add(createTranslationAnimations(view, -view.getWidth(), 0, 0, 0));
        }
      }
    }

    AnimatorSet resultSet = new AnimatorSet();
    resultSet.playTogether(resultList);
    resultSet.setDuration(300);
    resultSet.setInterpolator(new AccelerateDecelerateInterpolator());
    resultSet.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            mAnimationEnd = false;
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            mAnimationEnd = true;
          }
        });
    resultSet.start();
  }
Пример #29
0
  private void updateHeartButton(final CellFeedViewHolder holder, boolean animated) {
    if (animated) {
      if (!likeAnimations.containsKey(holder)) {
        AnimatorSet animatorSet = new AnimatorSet();
        likeAnimations.put(holder, animatorSet);

        ObjectAnimator rotationAnim = ObjectAnimator.ofFloat(holder.btnLike, "rotation", 0f, 360f);
        rotationAnim.setDuration(300);
        rotationAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

        ObjectAnimator bounceAnimX = ObjectAnimator.ofFloat(holder.btnLike, "scaleX", 0.2f, 1f);
        bounceAnimX.setDuration(300);
        bounceAnimX.setInterpolator(OVERSHOOT_INTERPOLATOR);

        ObjectAnimator bounceAnimY = ObjectAnimator.ofFloat(holder.btnLike, "scaleY", 0.2f, 1f);
        bounceAnimY.setDuration(300);
        bounceAnimY.setInterpolator(OVERSHOOT_INTERPOLATOR);
        bounceAnimY.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationStart(Animator animation) {
                holder.btnLike.setImageResource(R.drawable.ic_heart_red);
              }
            });

        animatorSet.play(rotationAnim);
        animatorSet.play(bounceAnimX).with(bounceAnimY).after(rotationAnim);

        animatorSet.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                resetLikeAnimationState(holder);
              }
            });

        animatorSet.start();
      }
    } else {
      if (likedPositions.contains(holder.getPosition())) {
        holder.btnLike.setImageResource(R.drawable.ic_heart_red);
      } else {
        holder.btnLike.setImageResource(R.drawable.ic_heart_outline_grey);
      }
    }
  }
Пример #30
0
 @Override
 public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
   if (enter) {
     AnimatorSet up =
         (AnimatorSet) AnimatorInflater.loadAnimator(getActivity(), R.animator.slide_up);
     up.addListener(
         new AnimatorListenerAdapter() {
           @Override
           public void onAnimationEnd(Animator animation) {
             setOnRiseListener();
           }
         });
     return up;
   } else {
     return AnimatorInflater.loadAnimator(getActivity(), R.animator.slide_down);
   }
 }