From a45036d4003974f8e78eb819a932895291d677d6 Mon Sep 17 00:00:00 2001 From: 陈奇 <1650699704@qq.com> Date: Tue, 27 Nov 2018 17:14:41 +0800 Subject: [PATCH] [*] --- app/src/main/java/com/moral/yunfushao/ui/PanelView.java | 38 +++++++++++++++----------------------- 1 files changed, 15 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/moral/yunfushao/ui/PanelView.java b/app/src/main/java/com/moral/yunfushao/ui/PanelView.java index 5929488..e1a9218 100644 --- a/app/src/main/java/com/moral/yunfushao/ui/PanelView.java +++ b/app/src/main/java/com/moral/yunfushao/ui/PanelView.java @@ -76,7 +76,7 @@ private Bitmap mBitmap; private float percent = 0;//��������������� - private float percent2 = (float) 0.27;//��������������� + private float percent2 = 0;//��������������� private String statusStr = "���������"; @@ -88,14 +88,8 @@ } public void setPercent(float percent) { - this.percent = percent; -// this.percent2 = percent; - postInvalidate(); -// if (anim.isStarted() || anim.isRunning()) { -// anim.end(); -// anim.cancel(); -// } -// anim.start(); + this.percent2 = percent; + startAnimation(); } public PanelView(Context context) { @@ -160,7 +154,6 @@ mBitPaint.setFilterBitmap(true); mBitPaint.setDither(true); mBitmap = ((BitmapDrawable) mContext.getResources().getDrawable(R.mipmap.zhizhen)).getBitmap(); -// startAnimation(); } @Override @@ -184,19 +177,18 @@ setMeasuredDimension(mmWidth, mmHeight); } -// private void startAnimation() { -// anim = ValueAnimator.ofObject(new CustomPointEvaluator(),(float)0, percent2); -// anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { -// @Override -// public void onAnimationUpdate(ValueAnimator animation) { -// percent = (float) animation.getAnimatedValue(); -// System.out.println("chenqi rotato " + percent + " all -> " + percent2 * 300); -//// invalidate(); -// } -// }); -// anim.setDuration(3000L); -// anim.setRepeatCount(Animation.INFINITE); -// } + private void startAnimation() { + anim = ValueAnimator.ofFloat((float) percent, percent2); + anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + percent = (float) animation.getAnimatedValue(); + postInvalidate(); + } + }); + anim.setDuration(500L); + anim.start(); + } // // private class CustomPointEvaluator implements TypeEvaluator<Float> { // @Override -- Gitblit v1.8.0