Exemple #1
0
  public void verticalRun() {

    ViewPropertyAnimator animator1 =
        mRecyclerView.animate().scaleX(0.95f).scaleY(0.95f).setDuration(200);
    // 可以不用start
    animator1.start();
  }
Exemple #2
0
  /** Continue dynamically after a fling gesture, possibly off the screen. */
  public void fling(final View photo, float dx, float dy, int duration, boolean spin) {
    if (photo == getFocus()) {
      if (moveFocus(photo, 0f) == null) {
        moveFocus(photo, 180f);
      }
    }
    moveToForeground(photo);
    ViewPropertyAnimator animator =
        photo
            .animate()
            .withLayer()
            .xBy(dx)
            .yBy(dy)
            .setDuration(duration)
            .setInterpolator(new DecelerateInterpolator(2f));

    if (spin) {
      animator.rotation(mThrowRotation);
    }

    if (photoOffTable(photo, (int) dx, (int) dy)) {
      log("fling away");
      animator.withEndAction(
          new Runnable() {
            @Override
            public void run() {
              fadeAway(photo, true);
            }
          });
    }
  }
  private void hide(final View view) {
    ViewPropertyAnimator animator =
        view.animate()
            .translationY(view.getHeight())
            .setInterpolator(INTERPOLATOR)
            .setDuration(200);
    animator.setListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animator) {}

          @Override
          public void onAnimationEnd(Animator animator) {
            view.setVisibility(View.GONE);
          }

          @Override
          public void onAnimationCancel(Animator animator) {
            show(view);
          }

          @Override
          public void onAnimationRepeat(Animator animator) {}
        });
    animator.start();
  }
  @Override
  public void hideOverlay(final boolean closeShortcutWindow) {
    ViewPropertyAnimator animator =
        mOverlay
            .animate()
            .setDuration(AppConstant.Anim.ANIM_DURATION_NORMAL)
            .translationX(mInitialOverlayTranslationX)
            .setInterpolator(new AccelerateInterpolator());
    animator.setListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            mGestureOverLay.setVisibility(GONE);
            EventBus.getDefault().post(new EventToKnob(EventToKnob.END_STATE_RIGHT));
            if (closeShortcutWindow) {
              startCloseAnim();
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

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

    for (int i = 0; i < rowContainer.getChildCount(); i++) {

      View rowView = rowContainer.getChildAt(i);
      ViewPropertyAnimator propertyAnimator =
          rowView.animate().setStartDelay(i * SCALE_DELAY).scaleX(0).scaleY(0);

      propertyAnimator.setListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {}

            @Override
            public void onAnimationEnd(Animator animator) {

              finishAfterTransition();
            }

            @Override
            public void onAnimationCancel(Animator animator) {}

            @Override
            public void onAnimationRepeat(Animator animator) {}
          });
    }
  }
  @Override
  public void showOverlay() {
    if (mCurrentOverlayMode == OverlayMoveMode.BY_GESTURE) {
      mGestureOverLay.setVisibility(VISIBLE);
      ViewPropertyAnimator animator =
          mOverlay
              .animate()
              .setDuration(AppConstant.Anim.ANIM_DURATION_NORMAL)
              .translationX(mTargetOverlayTranslationX)
              .setInterpolator(new DecelerateInterpolator())
              .setListener(
                  new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                      mGestureOverLay.setVisibility(VISIBLE);
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                      EventBus.getDefault().post(new EventToKnob(EventToKnob.END_STATE_LEFT));
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {}

                    @Override
                    public void onAnimationRepeat(Animator animation) {}
                  });
      animator.start();
    }
  }
 @Override
 private void start(View view, long l, float f, float f2, float f3, float f4, float f5, float f6) {
   view.setScaleX(f);
   view.setScaleY(f);
   view.setTranslationX(f3);
   view.setTranslationY(f4);
   ViewPropertyAnimator viewPropertyAnimator =
       view.animate().translationX(f5).translationY(f6).scaleX(f2).scaleY(f2).setDuration(l);
   viewPropertyAnimator.start();
 }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
 public static ViewPropertyAnimator fadeIn(View to, int duration) {
   if (to.getVisibility() != View.VISIBLE) {
     to.setAlpha(0f);
     to.setVisibility(View.VISIBLE);
   }
   to.clearAnimation();
   final ViewPropertyAnimator animator = to.animate();
   animator.alpha(1f).setDuration(duration).setListener(null);
   return animator;
 }
Exemple #9
0
  public void showMtsUI(View v) {
    hasShow = true;
    v.setAlpha(1f);
    float x = getResources().getInteger(R.integer.showmts_ui_x);
    float y = getResources().getInteger(R.integer.showmts_ui_y);
    v.setX(getResources().getInteger(R.integer.showmts_ui_setX));
    v.setY(getResources().getInteger(R.integer.showmts_ui_setY));

    ViewPropertyAnimator vpa = v.animate().x(x).y(y);

    vpa.setDuration(1500);
    vpa.setInterpolator(new BounceInterpolator());
  }
Exemple #10
0
  protected void show() {
    hasShow = true;
    mOSDLayout.setAlpha(1f);
    float x = mContext.getResources().getInteger(R.integer.ChannelInfo_details_animator_x);
    float y = mContext.getResources().getInteger(R.integer.ChannelInfo_details_animator_y);
    mOSDLayout.setX(mContext.getResources().getInteger(R.integer.ChannelInfo_details_animator_x));
    mOSDLayout.setY(
        mContext.getResources().getInteger(R.integer.ChannelInfo_details_animator_height));

    ViewPropertyAnimator vpa = mOSDLayout.animate().x(x).y(y);

    vpa.setDuration(1500);
    vpa.setInterpolator(new BounceInterpolator());

    mAdView.setVisibility(View.VISIBLE);
  }
  public void flip(float sgn) {
    mPanel[0].animate().cancel();
    mPanel[1].animate().cancel();

    float frontY = mPanel[0].getRotationY();
    float backY = mPanel[1].getRotationY();
    float frontA = mPanel[0].getAlpha();
    float backA = mPanel[1].getAlpha();

    frontY = wrap360(frontY);
    backY = wrap360(backY);

    mPanel[0].setRotationY(frontY);
    mPanel[1].setRotationY(backY);

    frontY = lockTo180(frontY + sgn * 180f);
    backY = lockTo180(backY + sgn * 180f);
    frontA = 1f - frontA;
    backA = 1f - backA;

    // Don't rotate
    frontY = backY = 0f;

    ViewPropertyAnimator frontAnim =
        mPanel[0].animate().rotationY(frontY).alpha(frontA).setDuration(mFlipDuration);
    ViewPropertyAnimator backAnim =
        mPanel[1]
            .animate()
            .rotationY(backY)
            .alpha(backA)
            .setDuration(mFlipDuration)
            .withEndAction(
                new Runnable() {
                  @Override
                  public void run() {
                    maybeLoadMore();
                  }
                });

    frontAnim.start();
    backAnim.start();
  }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
 public static ViewPropertyAnimator fadeOut(final View from, int duration) {
   if (from.getVisibility() == View.VISIBLE) {
     from.clearAnimation();
     final ViewPropertyAnimator animator = from.animate();
     animator
         .alpha(0f)
         .setDuration(duration)
         .setListener(
             new AnimatorListenerAdapter() {
               @Override
               public void onAnimationEnd(Animator animation) {
                 from.setVisibility(View.INVISIBLE);
                 from.setAlpha(1f);
               }
             });
     return animator;
   }
   return null;
 }
Exemple #13
0
 public void fadeIn() {
   // The selector starts with a height of 0. In order to scale up
   // from
   // 0 we first need the set the height to 1 and scale form there.
   int selectorHeight = mSelectorView.getHeight();
   if (selectorHeight == 0) {
     LayoutParams lp = mSelectorView.getLayoutParams();
     lp.height =
         selectorHeight =
             mSelectorView
                 .getContext()
                 .getResources()
                 .getDimensionPixelSize(R.dimen.lb_action_fragment_selector_min_height);
     mSelectorView.setLayoutParams(lp);
   }
   View focusedChild = mParentView.getFocusedChild();
   if (focusedChild != null) {
     float scaleY = (float) focusedChild.getHeight() / selectorHeight;
     ViewPropertyAnimator animation =
         mSelectorView
             .animate()
             .alpha(1f)
             .setListener(new Listener(false))
             .setDuration(mAnimationDuration)
             .setInterpolator(new DecelerateInterpolator(2f));
     if (mFadedOut) {
       // selector is completely faded out, so we can just
       // scale
       // before fading in.
       mSelectorView.setScaleY(scaleY);
     } else {
       // selector is not faded out, so we must animate the
       // scale
       // as we fade in.
       animation.scaleY(scaleY);
     }
     animation.start();
   }
 }
Exemple #14
0
 private void start(
     View view,
     long duration,
     float fromScale,
     float toScale,
     float fromTranslationX,
     float fromTranslationY,
     float toTranslationX,
     float toTranslationY) {
   view.setScaleX(fromScale);
   view.setScaleY(fromScale);
   view.setTranslationX(fromTranslationX);
   view.setTranslationY(fromTranslationY);
   ViewPropertyAnimator propertyAnimator =
       view.animate()
           .translationX(toTranslationX)
           .translationY(toTranslationY)
           .scaleX(toScale)
           .scaleY(toScale)
           .setDuration(duration);
   propertyAnimator.start();
   DebugUtils.log("KenBurnsView: starting Ken Burns animation " + propertyAnimator);
 }
Exemple #15
0
 public void gverticalRun() {
   ViewPropertyAnimator animator1 =
       mRecyclerView.animate().scaleX(1.0f).scaleY(1.0f).setDuration(200);
   animator1.start();
 }
 public FirstFrameAnimatorHelper(ViewPropertyAnimator vpa, View target) {
   mTarget = target;
   vpa.setListener(this);
 }
Exemple #17
0
 @Override
 public void setupAnimation(
     View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
   animator.rotationYBy(-INITIAL_ROTATION_ANGLE);
 }