DragBadgeView.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:DragBadgeView 作者:
public void reset() {
    final PointF tempDragPoint = new PointF(mDragPoint.x, mDragPoint.y);
    if (tempDragPoint.x == mOriginPoint.x && tempDragPoint.y == mOriginPoint.y) {
        return;
    }
    final FloatEvaluator evaluator = new FloatEvaluator();
    mAnimator = ValueAnimator.ofFloat(1.0f);
    mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator mAnim) {
            float percent = mAnim.getAnimatedFraction();
            updateDragPoint(evaluator.evaluate(percent, tempDragPoint.x, mOriginPoint.x),
                    evaluator.evaluate(percent, tempDragPoint.y, mOriginPoint.y));
        }
    });
    mAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            clearAnimation();//结束时清除动画
            ViewGroup rootView = (ViewGroup) BadgeView.this.getParent();
            if (rootView != null) {
                rootView.removeView(BadgeView.this);
                DragBadgeView.this.setVisibility(VISIBLE);
            }
            recycleCacheBitmap();
        }
    });
    mAnimator.setInterpolator(new OvershootInterpolator());
    mAnimator.setDuration(500);
    mAnimator.start();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号