陈奇
2018-11-26 50aacfed3ceb60997c2c9a4cc0f9e6fe6b5ed718
app/src/main/java/com/moral/yunfushao/ui/PanelView.java
@@ -14,6 +14,7 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.animation.Animation;
import com.moral.yunfushao.R;
@@ -60,7 +61,7 @@
    private Paint drawTextPaint;
    private int textColor = Color.GRAY;
    private int textSize = 36;
    private String[] level = {"绝对安全", "建议回避", "及时闪躲", "紧急撤离"};
    private String[] level = {"安全状态", "建议回避", "及时闪躲", "紧急撤离"};
    //内进度圆
    private Paint mCirclePaint;
@@ -76,7 +77,7 @@
    private Bitmap mBitmap;
    private float percent = 0;//百分比数据
    private float percent2 = (float) 0.27;//百分比数据
    private float percent2 = 0;//百分比数据
    private String statusStr = "未连接";
@@ -88,14 +89,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 +155,6 @@
        mBitPaint.setFilterBitmap(true);
        mBitPaint.setDither(true);
        mBitmap = ((BitmapDrawable) mContext.getResources().getDrawable(R.mipmap.zhizhen)).getBitmap();
//        startAnimation();
    }
    @Override
@@ -184,19 +178,19 @@
        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(3000L);
        anim.setRepeatCount(Animation.INFINITE);
        anim.start();
    }
//
//    private class CustomPointEvaluator implements TypeEvaluator<Float> {
//        @Override
@@ -225,8 +219,6 @@
        float bitH = circleR;
        float bitW = bitH * 0.448f;
        canvas.save();
        System.out.println("chenqi percent connect" + percent);
        canvas.rotate(percent * 300 - 150, mWidth / 2, mWidth / 2);
        RectF btmRect = new RectF((float) (cirlcleRect.left + bitH - bitW * 0.535), (float) (cirlcleRect.top + mCircleWidth * 0.68), (float) (cirlcleRect.left + bitH + bitW * 0.465), (float) (cirlcleRect.top + bitH + mCircleWidth * 0.68));
//        Log.d("haijiang","left="+btmRect.left);