android.view.animation.DecelerateInterpolator源码实例Demo

类android.view.animation.DecelerateInterpolator源码实例Demo

下面列出了android.view.animation.DecelerateInterpolator 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tok-Android   文件: SlidePanelView.java
public void onStart() {
    updateTimeRunnable = new UpdateTimeRunnable();
    setVisibility(View.VISIBLE);
    setTranslationX(getMeasuredWidth());
    AnimatorSet animSet = new AnimatorSet();
    animSet.setInterpolator(new DecelerateInterpolator());
    animSet.setDuration(200);
    animSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (blinkingDrawable != null) {
                blinkingDrawable.blinking();
            }
            postDelayed(updateTimeRunnable, 200);
        }
    });
    animSet.playTogether(ObjectAnimator.ofFloat(this, "translationX", 0f),
        ObjectAnimator.ofFloat(this, "alpha", 1f));
    animSet.start();
}
 
static AnimatorSet create(int insecurePercent,
                          @Nullable final UpdateListener progressUpdateListener,
                          @Nullable final UpdateListener detailsUpdateListener,
                          @Nullable final UpdateListener percentSecureListener,
                          @Nullable final UpdateListener lottieListener)
{
  final int             securePercent = 100 - insecurePercent;
  final AnimatorSet     animatorSet   = new AnimatorSet();
  final ValueAnimator[] animators     = Stream.of(createProgressAnimator(securePercent, progressUpdateListener),
                                                  createDetailsAnimator(detailsUpdateListener),
                                                  createPercentSecureAnimator(percentSecureListener),
                                                  createLottieAnimator(lottieListener))
                                              .filter(a -> a != null)
                                              .toArray(ValueAnimator[]::new);

  animatorSet.setInterpolator(new DecelerateInterpolator());
  animatorSet.playTogether(animators);

  return animatorSet;
}
 
源代码3 项目: mollyim-android   文件: MicrophoneRecorderView.java
void hide() {
  recordButtonFab.setTranslationX(0);
  recordButtonFab.setTranslationY(0);
  if (recordButtonFab.getVisibility() != VISIBLE) return;

  AnimationSet animation = new AnimationSet(false);
  Animation scaleAnimation = new ScaleAnimation(1, 0.5f, 1, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f,
                                                Animation.RELATIVE_TO_SELF, 0.5f);

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, lastOffsetX,
                                                        Animation.ABSOLUTE, 0,
                                                        Animation.ABSOLUTE, lastOffsetY,
                                                        Animation.ABSOLUTE, 0);

  scaleAnimation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));
  translateAnimation.setInterpolator(new DecelerateInterpolator());
  animation.addAnimation(scaleAnimation);
  animation.addAnimation(translateAnimation);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new AnticipateOvershootInterpolator(1.5f));

  recordButtonFab.setVisibility(View.GONE);
  recordButtonFab.clearAnimation();
  recordButtonFab.startAnimation(animation);
}
 
private void runEnterAnimation(View view, int position) {
    if (animationsLocked) return;
    if (position > lastAnimatedPosition) {
        lastAnimatedPosition = position;
        view.setTranslationY(DensityUtil.dip2px(view.getContext(), 100));//(position+1)*50f
        view.setAlpha(0.f);
        view.animate()
                .translationY(0).alpha(1.f)
                .setStartDelay(delayEnterAnimation ? 20 * (position) : 0)
                .setInterpolator(new DecelerateInterpolator(2.f))
                .setDuration(500)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        animationsLocked = true;
                    }
                }).start();
    }
}
 
源代码5 项目: star-zone-android   文件: CommentContentsLayout.java
private void animateExpand(int target) {
    if (animator != null) {
        animator.cancel();
        animator = null;
    }

    animator = ValueAnimator.ofFloat(curExpandValue, target);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.setDuration(300);

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setExpandValue((float) valueAnimator.getAnimatedValue());
        }
    });

    animator.addListener(new ExpansionListener(target));

    animator.start();
}
 
源代码6 项目: protrip   文件: Utils.java
private void staggerContent(View[] animatedViews) {

        Interpolator interpolator = new DecelerateInterpolator();
        for (int i = 0; i < animatedViews.length; ++i) {
            View v = animatedViews[i];
           /* v.setLayerType(View.LAYER_TYPE_HARDWARE, null);*/
            v.setAlpha(0f);
            v.setTranslationY(75);
            v.animate()
                    .setInterpolator(interpolator)
                    .alpha(1.0f)
                    .translationY(0)
                    .setStartDelay(100 + 75 * i)
                    .start();
        }
    }
 
源代码7 项目: TvWidget   文件: BorderEffect.java
@Override
public void onFocusChanged(View oldFocus, View newFocus) {
    try {
        if (newFocus instanceof AbsListView) {
            return;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new DecelerateInterpolator(1));
        animatorSet.setDuration(mDurationTraslate);
        animatorSet.playTogether(mAnimatorList);
        for (Animator.AnimatorListener listener : mAnimatorListener) {
            animatorSet.addListener(listener);
        }
        mAnimatorSet = animatorSet;
        if (oldFocus == null) {
            animatorSet.setDuration(0);
            mTarget.setVisibility(View.VISIBLE);
        }
        animatorSet.start();
    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
源代码8 项目: Android-Application-ZJB   文件: SwipeRefresh.java
/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context
 */
public SwipeRefresh(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
    mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}
 
源代码9 项目: moviedb-android   文件: CastDetails.java
/**
 * Instant shows our toolbar. Used when click on movie details from movies list and toolbar is hidden.
 */
public void showInstantToolbar() {
    if (activity != null) {
        View toolbarView = activity.findViewById(R.id.toolbar);

        if (toolbarView != null) {
            toolbarView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).setDuration(0).start();
            mSlidingTabLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).setDuration(0).start();


            upDyKey = true;
            downDyKey = false;
            downDy = 9999999;

        }
    }
}
 
源代码10 项目: LivePlayback   文件: MetroViewBorderHandler.java
@Override
public void onFocusChanged(View oldFocus, View newFocus) {
    try {
        if (newFocus instanceof AbsListView) {//如果新的view是AbsListView的实例,直接return
            return;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new DecelerateInterpolator(1));//设置插值器
        animatorSet.setDuration(mDurationTraslate);//设置动画时间
        animatorSet.playTogether(mAnimatorList);//表示两个动画同进执行
        for (Animator.AnimatorListener listener : mAnimatorListener) {
            animatorSet.addListener(listener);
        }
        mAnimatorSet = animatorSet;
        if (oldFocus == null) {//之前view为null,表示首次状态时
            animatorSet.setDuration(0);//无动画时长
            mTarget.setVisibility(View.VISIBLE);
        }
        animatorSet.start();//开启动画
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
源代码11 项目: Telegram   文件: DrawerLayoutContainer.java
public void closeDrawer(boolean fast) {
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(this, "drawerPosition", 0)
    );
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(false);
        }
    });
    animatorSet.start();
}
 
源代码12 项目: Telegram-FOSS   文件: PhotoEditToolCell.java
@Override
public void run() {
    valueTextView.setTag(null);
    valueAnimation = new AnimatorSet();
    valueAnimation.playTogether(
            ObjectAnimator.ofFloat(valueTextView, "alpha", 0.0f),
            ObjectAnimator.ofFloat(nameTextView, "alpha", 1.0f));
    valueAnimation.setDuration(180);
    valueAnimation.setInterpolator(new DecelerateInterpolator());
    valueAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (animation.equals(valueAnimation)) {
                valueAnimation = null;
            }
        }
    });
    valueAnimation.start();
}
 
源代码13 项目: freemp   文件: AdpArtists.java
public AdpArtists(Activity activity, ArrayList<ClsTrack> data) {
    this.data = data;
    this.activity = activity;

    listAq = new AQuery(activity);

    int iDisplayWidth = Math.max(320, PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()).getInt("screenWidth", 800));
    int numColumns = (int) (iDisplayWidth / 310);
    if (numColumns == 0) numColumns = 1;
    width = (iDisplayWidth / numColumns);
    layoutParams = new AbsListView.LayoutParams(width, width);

    fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setDuration(300);
    fadeIn.setInterpolator(new DecelerateInterpolator());
}
 
源代码14 项目: Android-utils   文件: AnimUtils.java
/**
 * <p>对 View 做透明度变化的进场动画。</p>
 * <p>相关方法 {@link #fadeOut(View, int, Animation.AnimationListener, boolean)}</p>
 *
 * @param view            做动画的 View
 * @param duration        动画时长(毫秒)
 * @param listener        动画回调
 * @param isNeedAnimation 是否需要动画
 */
public static AlphaAnimation fadeIn(View view, int duration, Animation.AnimationListener listener, boolean isNeedAnimation) {
    if (view == null) {
        return null;
    }
    if (isNeedAnimation) {
        view.setVisibility(View.VISIBLE);
        AlphaAnimation alpha = new AlphaAnimation(0, 1);
        alpha.setInterpolator(new DecelerateInterpolator());
        alpha.setDuration(duration);
        alpha.setFillAfter(true);
        if (listener != null) {
            alpha.setAnimationListener(listener);
        }
        view.startAnimation(alpha);
        return alpha;
    } else {
        view.setAlpha(1);
        view.setVisibility(View.VISIBLE);
        return null;
    }
}
 
源代码15 项目: MediaGallery   文件: ViewPagerAdapter.java
private void onTap() {
    mPhotoViewAttacher = new PhotoViewAttacher(imageView);

    mPhotoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (isShowing) {
                isShowing = false;
                toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
                imagesHorizontalList.animate().translationY(imagesHorizontalList.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
            } else {
                isShowing = true;
                toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
                imagesHorizontalList.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
            }
        }

        @Override
        public void onOutsidePhotoTap() {

        }
    });
}
 
源代码16 项目: android-open-project-demo   文件: Utils.java
public static Animation createScaleAnimation(View view, int parentWidth, int parentHeight,
        int toX, int toY) {
    // Difference in X and Y
    final int diffX = toX - view.getLeft();
    final int diffY = toY - view.getTop();

    // Calculate actual distance using pythagors
    float diffDistance = FloatMath.sqrt((toX * toX) + (toY * toY));
    float parentDistance = FloatMath
            .sqrt((parentWidth * parentWidth) + (parentHeight * parentHeight));

    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.ABSOLUTE,
            diffX,
            Animation.ABSOLUTE, diffY);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(Math.round(diffDistance / parentDistance
            * Constants.SCALE_ANIMATION_DURATION_FULL_DISTANCE));

    return scaleAnimation;
}
 
源代码17 项目: Telegram-FOSS   文件: DrawerLayoutContainer.java
public void openDrawer(boolean fast) {
    if (!allowOpenDrawer) {
        return;
    }
    if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) {
        AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus());
    }
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth()));
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(true);
        }
    });
    animatorSet.start();
    currentAnimation = animatorSet;
}
 
private void emitFirework(int width, int height) {

        float fireworkWidth = width / mMaxFireworksCount;
        float fireworkHeight = height / mMaxFireworksCount;

        float x = RND.nextInt((int) (width - fireworkWidth)) + fireworkWidth / 2f;
        float y = RND.nextInt((int) (height - fireworkHeight)) + fireworkHeight;

        for(int i=0; i< mMaxFireworksCount; i++) {
            ParticleSystem particleSystem = new ParticleSystem(
                    (Activity) mParentView.getContext(),     //activity
                    20,                         //max particles
                    R.drawable.ptr_star_white,  //icon
                    800L,                       //time to live
                    mParentView);      //parent view
            particleSystem.setScaleRange(0.7f, 1.3f);
            particleSystem.setSpeedRange(0.03f, 0.07f);
            particleSystem.setRotationSpeedRange(90, 180);
            particleSystem.setFadeOut(500, new DecelerateInterpolator());
            particleSystem.setTintColor(getRandomBubbleColor());

            mParticleSystems.add(particleSystem);
            particleSystem.emit((int) x, (int) y, 70, 500);
        }
    }
 
源代码19 项目: Taurus   文件: PullToRefreshView.java
public PullToRefreshView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    float density = context.getResources().getDisplayMetrics().density;
    mTotalDragDistance = Math.round((float) DRAG_MAX_DISTANCE * density);

    mRefreshImageView = new ImageView(context);
    mRefreshView = new RefreshView(getContext(), this);
    mRefreshImageView.setImageDrawable(mRefreshView);

    addView(mRefreshImageView);
    setWillNotDraw(false);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}
 
源代码20 项目: MaterialWpp   文件: DetailActivity.java
private void hideOrShowToolbar() {
    appBarLayout.animate()
            .translationY(ishide ? 0 : -appBarLayout.getHeight())
            .setInterpolator(new DecelerateInterpolator())
            .start();
    floatingActionButton.animate()
            .scaleX(ishide?1.0F:0.0F)
            .scaleY(ishide?1.0F:0.0F)
            .alpha(ishide?0.8F:0.0F)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setDuration(500)
            .start();
    linearLayout.animate()
            .translationY(ishide?0:-(appBarLayout.getHeight()+linearLayout.getHeight()))
            .setInterpolator(new DecelerateInterpolator())
            .setDuration(1000)
            .start();
    ishide = !ishide;

}
 
源代码21 项目: moviedb-android   文件: TVSlideTab.java
/**
 * Instant shows our toolbar. Used when click on movie details from movies list and toolbar is hidden.
 */
public void showInstantToolbar() {
    if (activity != null) {
        View toolbarView = activity.findViewById(R.id.toolbar);

        if (toolbarView != null) {
            toolbarView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).setDuration(0).start();
            mSlidingTabLayout.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).setDuration(0).start();


            upDyKey = true;
            downDyKey = false;
            downDy = 9999999;

        }
    }
}
 
源代码22 项目: imsdk-android   文件: PuzzlePiece.java
PuzzlePiece(Drawable drawable, Area area, Matrix matrix) {
  this.drawable = drawable;
  this.area = area;
  this.matrix = matrix;
  this.previousMatrix = new Matrix();
  this.drawableBounds = new Rect(0, 0, getWidth(), getHeight());
  this.drawablePoints = new float[] {
      0f, 0f, getWidth(), 0f, getWidth(), getHeight(), 0f, getHeight()
  };
  this.mappedDrawablePoints = new float[8];

  this.mappedBounds = new RectF();
  this.centerPoint = new PointF(area.centerX(), area.centerY());
  this.mappedCenterPoint = new PointF();

  this.animator = ValueAnimator.ofFloat(0f, 1f);
  this.animator.setInterpolator(new DecelerateInterpolator());

  this.tempMatrix = new Matrix();
}
 
private void init(Context context) {
    mScreenDensity = context.getResources().getDisplayMetrics().density;
    mLoadingMorePullDistanceThreshold = (int)(mScreenDensity * 50);

    mScroller = new Scroller(context, new DecelerateInterpolator(1.3f));

    // on Android 2.3.3, disabling overscroll makes ListView behave weirdly
    if (Build.VERSION.SDK_INT > 10) {
        // disable the glow effect at the edges when overscrolling.
        setOverScrollMode(OVER_SCROLL_NEVER);
    }

    final ViewConfiguration configuration = ViewConfiguration.get(getContext());

    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

    mVelocityTracker = VelocityTracker.obtain();
}
 
源代码24 项目: letv   文件: BottomRedPointView.java
private void init(Context context, View target) {
    this.context = context;
    this.target = target;
    fadeIn = new AlphaAnimation(0.0f, 1.0f);
    fadeIn.setInterpolator(new DecelerateInterpolator());
    fadeIn.setDuration(200);
    fadeOut = new AlphaAnimation(1.0f, 0.0f);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(200);
    this.isShown = false;
    if (this.target != null) {
        applyTo(this.target);
    } else {
        show();
    }
}
 
源代码25 项目: android-player   文件: MainActivity.java
private void animateSampleThree(View activityMainProfileName, View activityMainMobileNumberLayout, View activityMainPinkFab, View activityMainheaderLayout, View activityMainMessageIcon) {
    final PropertyAction propertyAction = PropertyAction.newPropertyAction(activityMainheaderLayout).translationX(-200).duration(1500).interpolator(new AccelerateDecelerateInterpolator()).alpha(0.4f).build();
    final PropertyAction headerPropertyAction = PropertyAction.newPropertyAction(activityMainProfileName).interpolator(new DecelerateInterpolator()).translationY(-200).duration(3750).delay(1233).alpha(0.4f).build();
    final PropertyAction viewSecondAction = PropertyAction.newPropertyAction(activityMainPinkFab).translationY(200).duration(750).alpha(0f).build();
    final PropertyAction bottomPropertyAction = PropertyAction.newPropertyAction(activityMainMobileNumberLayout).rotation(-180).scaleX(0.1f).scaleY(0.1f).translationX(-200).duration(750).build();
    Player.init().
            setPlayerStartListener(playerStartListener).
            setPlayerEndListener(playerEndListener).
            animate(propertyAction).
            animate(headerPropertyAction).
            then().
            animate(viewSecondAction).
            then().
            animate(bottomPropertyAction).
            play();
}
 
源代码26 项目: android-apps   文件: ActionBarContextView.java
private Animator makeInAnimation() {
    mClose.setTranslationX(-mClose.getWidth() -
            ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0);
    buttonAnimator.setDuration(200);
    buttonAnimator.addListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());

    AnimatorSet set = new AnimatorSet();
    AnimatorSet.Builder b = set.play(buttonAnimator);

    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = count - 1, j = 0; i >= 0; i--, j++) {
                AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i));
                child.setScaleY(0);
                ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1);
                a.setDuration(100);
                a.setStartDelay(j * 70);
                b.with(a);
            }
        }
    }

    return set;
}
 
源代码27 项目: AndroidChromium   文件: SnackbarView.java
void show() {
    addToParent();
    mView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mView.removeOnLayoutChangeListener(this);
            mView.setTranslationY(mView.getHeight() + getLayoutParams().bottomMargin);
            Animator animator = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y, 0);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.setDuration(mAnimationDuration);
            startAnimatorOnSurfaceView(animator);
        }
    });
}
 
@Override
protected void show() {
    playPauseFab.animate()
            .scaleX(1f)
            .scaleY(1f)
            .rotation(360f)
            .setInterpolator(new DecelerateInterpolator())
            .start();
}
 
源代码29 项目: fingerpoetry-android   文件: RippleLayout.java
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
private static ObjectAnimator getDownAnimation(View target) {
  ObjectAnimator animator = ObjectAnimator.ofFloat(target, "translationY", 0);
  animator.setInterpolator(new DecelerateInterpolator());
  animator.setDuration(DOWN_TIME);

  return animator;
}