update progress.
authorTrillGates <williamtrillgates@gmail.com>
Tue, 1 Jun 2021 08:47:48 +0000 (16:47 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Tue, 1 Jun 2021 08:47:48 +0000 (16:47 +0800)
17 files changed:
app/release/release/ICL02Sport_V22_202104151135_release.apk [new file with mode: 0644]
app/release/release/output.json [new file with mode: 0644]
app/src/main/java/com/ic/sport/PedometerActivity.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedMainFragment.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedSetupFragment.java
app/src/main/java/com/ic/sport/util/AndroidUtils.java [new file with mode: 0644]
app/src/main/java/com/ic/sport/widget/ring/Ring.java
app/src/main/java/com/ic/sport/widget/ring/RingProgress.java
app/src/main/res/layout/fragment_ped_main.xml
app/src/main/res/mipmap-mdpi/bg.png [new file with mode: 0644]
app/src/main/res/values-en/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-zh/strings.xml
app/src/main/res/values/attrs.xml
app/src/main/res/values/colors.xml
app/src/main/res/values/strings.xml
app/version_code.properties

diff --git a/app/release/release/ICL02Sport_V22_202104151135_release.apk b/app/release/release/ICL02Sport_V22_202104151135_release.apk
new file mode 100644 (file)
index 0000000..d8eb1de
Binary files /dev/null and b/app/release/release/ICL02Sport_V22_202104151135_release.apk differ
diff --git a/app/release/release/output.json b/app/release/release/output.json
new file mode 100644 (file)
index 0000000..43e089e
--- /dev/null
@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":22,"versionName":"202104151135","enabled":true,"outputFile":"ICL02Sport_V22_202104151135_release.apk","fullName":"release","baseName":"release"},"path":"ICL02Sport_V22_202104151135_release.apk","properties":{}}]
\ No newline at end of file
index fd3a809..6e5181f 100644 (file)
@@ -36,7 +36,6 @@ public class PedometerActivity extends AppCompatActivity
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_pedometer);
-
         initViewPage();
         initIndicator();
         initPedometerModel();
index 18c3c38..a9e679d 100644 (file)
@@ -4,10 +4,13 @@ package com.ic.sport.fragment.pedometer;
 import android.animation.ValueAnimator;
 import android.content.Context;
 import android.graphics.Color;
+import android.graphics.LinearGradient;
+import android.graphics.Shader;
 import android.graphics.Typeface;
 import android.os.Bundle;
 
 import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
 import androidx.fragment.app.Fragment;
 
 import android.view.LayoutInflater;
@@ -16,6 +19,7 @@ import android.view.ViewGroup;
 import android.widget.TextView;
 
 import com.ic.sport.App;
+import com.ic.sport.R;
 import com.ic.sport.databinding.FragmentPedMainBinding;
 import com.ic.sport.util.SPUtils;
 import com.ic.sport.widget.ring.Ring;
@@ -38,7 +42,7 @@ public class PedMainFragment extends Fragment {
 
     private FragmentPedMainBinding pedMainBinding;
 
-    private QueryPedometerCountListener queryListner;
+    private QueryPedometerCountListener queryListener;
 
     public static PedMainFragment newInstance() {
         return new PedMainFragment();
@@ -46,7 +50,7 @@ public class PedMainFragment extends Fragment {
 
     private int targetValue;
 
-    private boolean isFirstLoad=false;
+    private boolean isFirstLoad = false;
 
     @Override
     public void onAttach(@NonNull Context context) {
@@ -54,7 +58,7 @@ public class PedMainFragment extends Fragment {
         this.mContext = context;
 
         try {
-            queryListner = (QueryPedometerCountListener) context;
+            queryListener = (QueryPedometerCountListener) context;
         } catch (ClassCastException e) {
         }
     }
@@ -73,16 +77,17 @@ public class PedMainFragment extends Fragment {
         pedMainBinding = FragmentPedMainBinding.inflate(inflater, container, false);
         updatePedNumber(0);
         targetValue = SPUtils.getPedTargetSP(mApp.getApplicationContext());
-        pedMainBinding.setPedTarget(String.valueOf(targetValue));
+        pedMainBinding.setPedTarget(getResources().getString(R.string.target_text) +
+                targetValue);
         return pedMainBinding.getRoot();
     }
 
     @Override
     public void onResume() {
         super.onResume();
-        if(!isFirstLoad){
-            queryListner.onQueryCount();
-            isFirstLoad=true;
+        if (!isFirstLoad) {
+            queryListener.onQueryCount();
+            isFirstLoad = true;
         }
     }
 
@@ -97,11 +102,7 @@ public class PedMainFragment extends Fragment {
 
     private void setupRingProgress(int number) {
         RingProgress mRingProgress = pedMainBinding.ringProgress;
-
-        Ring r = new Ring(number, "", "", Color.GREEN, Color.YELLOW);
-        List<Ring> mlistRing = new ArrayList<>();
-        mlistRing.add(r);
-        mRingProgress.setData(mlistRing, 500);
+        mRingProgress.setProgress(500);
     }
 
     private void setupRingProgressNumberTv(int number) {
index eeff34c..07ee5e3 100644 (file)
@@ -27,7 +27,7 @@ public class PedSetupFragment extends Fragment{
 
     private Context mContext;
     private RecyclerView mSetupRv;
-    private PedSetupAdapter setupAdapte;
+    private PedSetupAdapter setupAdapter;
 
     public static PedSetupFragment newInstance() {
         return new PedSetupFragment();
@@ -60,10 +60,10 @@ public class PedSetupFragment extends Fragment{
     }
 
     private void initRecyclerView() {
-        setupAdapte = new PedSetupAdapter(mContext,listener);
+        setupAdapter = new PedSetupAdapter(mContext,listener);
         LinearLayoutManager mLayoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
         mSetupRv.setLayoutManager(mLayoutManager);
-        mSetupRv.setAdapter(setupAdapte);
+        mSetupRv.setAdapter(setupAdapter);
     }
 
     private OnPedSetupItemClickListener listener = pos -> {
@@ -76,7 +76,7 @@ public class PedSetupFragment extends Fragment{
     };
 
     public void updateSetuUpValue(int type,int value){
-        setupAdapte.notifyUpdateValue(type,value);
+        setupAdapter.notifyUpdateValue(type,value);
     }
 
 }
diff --git a/app/src/main/java/com/ic/sport/util/AndroidUtils.java b/app/src/main/java/com/ic/sport/util/AndroidUtils.java
new file mode 100644 (file)
index 0000000..6732892
--- /dev/null
@@ -0,0 +1,147 @@
+package com.ic.sport.util;
+
+import java.math.BigDecimal;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AndroidUtils {
+    /**
+     * 对double数据进行取精度.
+     *
+     * @param value        double数据.
+     * @param scale        精度位数(保留的小数位数).
+     * @param roundingMode 精度取值方式.
+     * @return 精度计算后的数据.
+     */
+    public static double round(double value, int scale,
+                               int roundingMode) {
+        BigDecimal bd = new BigDecimal(value);
+        bd = bd.setScale(scale, roundingMode);
+        double d = bd.doubleValue();
+        bd = null;
+        return d;
+    }
+
+    public static double round(double value) {
+        return round(value, 2, BigDecimal.ROUND_HALF_UP);
+    }
+
+    /**
+     * double 相加
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static double jiaFa(double d1, double d2) {
+        BigDecimal bd1 = new BigDecimal(d1);
+        BigDecimal bd2 = new BigDecimal(d2);
+        return round(bd1.add(bd2).doubleValue());
+    }
+
+
+    /**
+     * double 相减
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static double jianFa(double d1, double d2) {
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
+        return round(bd1.subtract(bd2).doubleValue());
+    }
+
+    /**
+     * double 乘法
+     *
+     * @param d1
+     * @param d2
+     * @return
+     */
+    public static double chengFa(double d1, double d2) {
+        BigDecimal bd1 = new BigDecimal(d1);
+        BigDecimal bd2 = new BigDecimal(d2);
+        return round(bd1.multiply(bd2).doubleValue());
+    }
+
+
+    /**
+     * double 除法
+     *
+     * @param d1
+     * @param d2
+     * @param scale 四舍五入 小数点位数
+     * @return
+     */
+    public static double chuFa(double d1, double d2, int scale) {
+        //  当然在此之前,你要判断分母是否为0,
+        //  为0你可以根据实际需求做相应的处理
+        try {
+            if (d2 == 0) {
+                throw new Exception("分母不能为0");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        BigDecimal bd1 = new BigDecimal(Double.toString(d1));
+        BigDecimal bd2 = new BigDecimal(Double.toString(d2));
+        return bd1.divide
+                (bd2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
+    }
+
+    public static double chuFa(double d1, double d2) {
+        return chuFa(d1, d2, 2);
+    }
+
+    /**
+     * 将double类型数据转为字符串
+     *
+     * @param d
+     * @return
+     */
+    public static String double2String(double d) {
+        BigDecimal bg = new BigDecimal(d * 100);
+        double doubleValue = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+        return String.valueOf((int) doubleValue);
+    }
+
+    /**
+     * 验证身份证号是否符合规则
+     *
+     * @param text 身份证号
+     * @return
+     */
+    public static boolean personIdValidation(String text) {
+        String regx = "[0-9]{17}x";
+        String reg1 = "[0-9]{15}";
+        String regex = "[0-9]{18}";
+        return text.matches(regx) || text.matches(reg1) || text.matches(regex);
+    }
+
+    /**
+     * 验证输入身份证号
+     *
+     * @param //待验证的字符串
+     * @return 如果是符合格式的字符串, 返回 <b>true </b>,否则为 <b>false </b>
+     */
+    public static boolean isIDcard(String str) {
+        String regex = "(^\\d{18}$)|(^\\d{15}$)";
+        return match(regex, str);
+    }
+
+    /**
+     * @param regex 正则表达式字符串
+     * @param str   要匹配的字符串
+     * @return 如果str 符合 regex的正则表达式格式,返回true, 否则返回 false;
+     */
+    private static boolean match(String regex, String str) {
+        Pattern pattern = Pattern.compile(regex);
+        Matcher matcher = pattern.matcher(str);
+        return matcher.matches();
+    }
+
+
+}
\ No newline at end of file
index 3dadb6f..d67bd9e 100644 (file)
@@ -11,13 +11,12 @@ public class Ring {
     private int endColor;
 
 
-    public Ring(int p,  String value, String name,int startColor, int endColor) {
+    public Ring(int p, String value, String name, int startColor, int endColor) {
         this.progress = p;
         this.name = name;
         this.value = value;
         this.startColor = startColor;
         this.endColor = endColor;
-
     }
 
     public Ring() {
index 7e2aa9d..bef0aec 100644 (file)
@@ -11,637 +11,604 @@ import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.LinearGradient;
 import android.graphics.Paint;
+import android.graphics.PaintFlagsDrawFilter;
 import android.graphics.Path;
+import android.graphics.Rect;
 import android.graphics.RectF;
 import android.graphics.Shader;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.DecelerateInterpolator;
 import android.view.animation.LinearInterpolator;
 
+import androidx.annotation.ColorInt;
+import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
+
 import com.ic.sport.R;
+import com.ic.sport.util.AndroidUtils;
 
-import java.util.ArrayList;
-import java.util.List;
 
 public class RingProgress extends View {
+    public boolean isDebug = true;
+    private OnRingProgressInter onRingProgressInter;
 
-    private Paint mPaint;
-    private Bitmap mBitmapBg;
-    private Paint mPaintText;
-    private int SweepAngle = 180;
-    private int mPadding;
-    private int mWidth;
-
-    private int ringWidth = 0;
-
-
-    private int rotateAngle = 270;
-
-    private int bgShadowColor = Color.argb(100, 0, 0, 0);
-    private int bgColor = Color.rgb(141, 141, 141);
-
-    private List<Ring> mListRing = new ArrayList<>();
-    private RectF rectFBg = new RectF();
-    private boolean isCorner = true;
-    private boolean isDrawBg = true;
-    private boolean isDrawBgShadow = true;
-    private float ringWidthScale = 0f;
-    private boolean bgChange = false;
-
-    public int getSweepAngle() {
-        return SweepAngle;
-    }
-
-    public void setSweepAngle(int sweepAngle) {
-
-        if (sweepAngle < 0)
-            sweepAngle = 0;
-        else if (sweepAngle > 360)
-            sweepAngle = 360;
-        SweepAngle = sweepAngle;
-        bgChange = true;
-        invalidate();
-    }
-
-    public int getRotateAngle() {
-        return rotateAngle;
+    public interface OnRingProgressInter {
+        void progress(float scaleProgress, float progress, float max);
     }
 
-    public void setRotateAngle(int rotateAngle) {
-
-        if (rotateAngle < 0)
-            rotateAngle = 0;
-        else if (rotateAngle > 360)
-            rotateAngle = 360;
-
+    private int centerX;
+    private int centerY;
+    private Paint mPaint;
+    private Shader progressShader;
+//    private float viewWidth;
+//    private float viewHeight;
+
+    //内圆颜色
+    private int neiYuanColor;
+    //圆环半径
+    private int ringRadius;
+    //圆环宽度
+    private int ringWidth;
+    //圆环颜色
+    private int ringColor;
+    //    圆环进度颜色
+    private int ringProgressColor;
+    //圆环进度过度颜色
+//    private int ringProgressSecondColor;
+    //开始角度
+    private int startAngle = -45;
+    //是否顺时针
+    private boolean isClockwise = true;
+    //当前进度
+    private float progress = 10;
+    //用于执行动画时的进度回调
+    private float scaleProgress = progress;
+    //总进度
+    private float maxProgress = 1000;
+
+    //用于逻辑计算的总进度(主要使动画效果更平滑)
+    private final int viewMax = 3600;
+    //用于逻辑计算的当前进度(主要使动画效果更平滑)
+    private float viewProgress = progress * viewMax / maxProgress;
+
+    //不绘制的度数
+    private int disableAngle = 0;
+    //圆环进度是否为圆角
+    private boolean isRound = true;
+    //是否设置动画
+    private boolean useAnimation = true;
+    //动画执行时间
+    private int duration = 1000;
+
+    //进度百分比
+    private double progressPercent;
+    //进度百分比数值是否是小数
+    private boolean isDecimal = true;
+    //小数点后几位
+    private int decimalPointLength = 1;
+    //是否显示百分比
+    private boolean isShowPercentText = false;
+    //文字颜色
+    private int textColor;
+    //文字大小
+    private int textSize;
 
-        this.rotateAngle = rotateAngle;
-        invalidate();
+    public RingProgress(Context context) {
+        super(context);
+        initAttr(null);
     }
 
-    public boolean isCorner() {
-        return isCorner;
+    public RingProgress(Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+        initAttr(attrs);
     }
 
-    public void setCorner(boolean corner) {
-        isCorner = corner;
-        bgChange = true;
-        invalidate();
+    public RingProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        initAttr(attrs);
     }
 
-    public boolean isDrawBgShadow() {
-        return isDrawBgShadow;
-    }
+    private void initAttr(AttributeSet attrs) {
+        initData();
+        initPaint();
+        if (attrs == null) {
+            return;
+        }
+        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.CircleProgress);
+        neiYuanColor = typedArray.getColor(R.styleable.CircleProgress_neiYuanColor, getTransparentColor());
+        ringRadius = (int) typedArray.getDimension(R.styleable.CircleProgress_ringRadius, -1);
+        ringWidth = (int) typedArray.getDimension(R.styleable.CircleProgress_ringWidth, 30);
+        ringColor = typedArray.getColor(R.styleable.CircleProgress_ringColor,
+                ContextCompat.getColor(getContext(), R.color.top_color2));
+        ringProgressColor = typedArray.getColor(R.styleable.CircleProgress_ringProgressColor,
+                ContextCompat.getColor(getContext(), R.color.green1));
+        startAngle = typedArray.getInteger(R.styleable.CircleProgress_startAngle, 135);
+        isClockwise = typedArray.getBoolean(R.styleable.CircleProgress_isClockwise, false);
+        progress = typedArray.getFloat(R.styleable.CircleProgress_progress, 10);
+        maxProgress = typedArray.getFloat(R.styleable.CircleProgress_maxProgress, 100);
+
+        if (maxProgress <= 0) {
+            this.maxProgress = 0;
+        }
+        if (progress > maxProgress) {
+            this.progress = maxProgress;
+        } else if (progress < 0) {
+            this.progress = 0;
+        }
 
-    public void setDrawBgShadow(boolean drawBgShadow) {
-        isDrawBgShadow = drawBgShadow;
-        bgChange = true;
-        invalidate();
+        scaleProgress = progress;
+        viewProgress = progress * viewMax / maxProgress;
+
+        disableAngle = typedArray.getInteger(R.styleable.CircleProgress_disableAngle, 90);
+        isRound = typedArray.getBoolean(R.styleable.CircleProgress_isRound, true);
+        useAnimation = typedArray.getBoolean(R.styleable.CircleProgress_useAnimation, true);
+        duration = typedArray.getInteger(R.styleable.CircleProgress_duration, 1000);
+        isDecimal = typedArray.getBoolean(R.styleable.CircleProgress_isDecimal, true);
+        decimalPointLength = typedArray.getInteger(R.styleable.CircleProgress_decimalPointLength, 1);
+        isShowPercentText = typedArray.getBoolean(R.styleable.CircleProgress_isShowPercentText, true);
+        textColor = typedArray.getColor(R.styleable.CircleProgress_textColor, ContextCompat.getColor(getContext(), R.color.green1));
+        textSize = (int) typedArray.getDimension(R.styleable.CircleProgress_textSize, getDef_TextSize());
+        typedArray.recycle();
+//        initData();
     }
 
-    public void setDrawBgShadow(boolean drawBgShadow, int color) {
-        isDrawBgShadow = drawBgShadow;
-        this.bgShadowColor = color;
-        bgChange = true;
-        invalidate();
+    private int getTransparentColor() {
+        return ContextCompat.getColor(getContext(), R.color.transparent);
     }
 
-
-    public boolean isDrawBg() {
-        return isDrawBg;
+    private int getDef_TextSize() {
+        return dip2px(getContext(), 17);
     }
 
-    public void setDrawBg(boolean drawBg) {
-        isDrawBg = drawBg;
-        bgChange = true;
-        invalidate();
+    private void initPaint() {
+        mPaint = new Paint();
+        mPaint.setAntiAlias(true);
+        mPaint.setDither(true);
+        mPaint.setColor(Color.WHITE);
+        mPaint.setStyle(Paint.Style.FILL);
     }
 
-    public void setDrawBg(boolean drawBg, int color) {
-        isDrawBg = drawBg;
-        this.bgColor = color;
-        bgChange = true;
-        invalidate();
-    }
 
-    public List<Ring> getmListRing() {
-        return mListRing;
+    private void initData() {
+        neiYuanColor = ContextCompat.getColor(getContext(), R.color.transparent);
+        ringRadius = -1;
+        ringWidth = 30;
+        ringColor = ContextCompat.getColor(getContext(), R.color.top_color2);
+        ringProgressColor = ContextCompat.getColor(getContext(), R.color.green1);
+        textSize = dip2px(getContext(), 17);
+        textColor = ContextCompat.getColor(getContext(), R.color.green1);
     }
 
-    public void setmListRing(List<Ring> mListRing) {
-        this.mListRing = mListRing;
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+        int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+        int mWidth = 200;
+        int mHeight = 200;
+        if (getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT && getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
+            setMeasuredDimension(mWidth, mHeight);
+        } else if (getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT) {
+            setMeasuredDimension(mWidth, heightSize);
+        } else if (getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT) {
+            setMeasuredDimension(widthSize, mHeight);
+        }
     }
 
+ /*   @Override
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(w, h, oldw, oldh);
+        viewWidth=w;
+        viewHeight=h;
+    }*/
 
-    public float getRingWidthScale() {
-        return ringWidthScale;
-    }
-
-    public void setRingWidthScale(float ringWidthScale) {
-        this.ringWidthScale = ringWidthScale;
-        bgChange = true;
-        invalidate();
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        int WH = Math.min(getWidth() - getPaddingLeft()
+                        - getPaddingRight(),
+                getHeight() - getPaddingTop() - getPaddingBottom());
+        if (ringRadius < 0) {
+            ringRadius = (WH - ringWidth) / 2 - 5;
+        }
+        centerX = getWidth() / 2;
+        centerY = getHeight() / 2;
+        //绘制圆环
+        //drawRing(canvas);
+        drawRing2(canvas);
+        //绘制内圆
+        drawNeiYuan(canvas);
+        //绘制进度圆环
+        drawProgressRing(canvas);
+        //绘制进度百分比
+        if (isShowPercentText) {
+            drawProgressText(canvas);
+        }
     }
 
-
-    public void setData(List<Ring> mListRing, int time) {
-        this.mListRing.clear();
-        for (int i = 0; i < mListRing.size(); i++) {
-
-            RectF r = new RectF();
-            r.top = rectFBg.top + ringWidth * i;
-            r.bottom = rectFBg.bottom - ringWidth * i;
-            r.left = rectFBg.left + ringWidth * i;
-            r.right = rectFBg.right - ringWidth * i;
-            mListRing.get(i).setRectFRing(r);
+    private void drawProgressText(Canvas canvas) {
+        mPaint.reset();
+        mPaint.setAntiAlias(true);
+        mPaint.setDither(true);
+        progressPercent = AndroidUtils.chuFa(progress * 100, maxProgress, decimalPointLength);
+        String percentStr = progressPercent + "%";
+        if (!isDecimal) {
+            percentStr = ((int) progressPercent) + "%";
+        }
+        Rect rect = new Rect();
+        mPaint.setTextSize(textSize);
+        mPaint.setColor(textColor);
+        mPaint.getTextBounds(percentStr, 0, percentStr.length(), rect);
+        float baseLineHeight = Math.abs(mPaint.getFontMetrics().ascent);
+        canvas.drawText(percentStr + "", centerX - rect.width() / 2, centerY + baseLineHeight / 2, mPaint);
+
+    }
+
+    private void drawNeiYuan(Canvas canvas) {
+        mPaint.setAntiAlias(true);
+        mPaint.setDither(true);
+        mPaint.setColor(neiYuanColor);
+        mPaint.setStyle(Paint.Style.FILL);
+        canvas.drawCircle(centerX, centerY, ringRadius - ringWidth / 2, mPaint);
+    }
+
+    private void drawProgressRing(Canvas canvas) {
+        mPaint.setAntiAlias(true);
+        mPaint.setDither(true);
+        mPaint.setColor(ringProgressColor);
+        mPaint.setStyle(Paint.Style.STROKE);
+        mPaint.setStrokeWidth(ringWidth);
+        mPaint.setShader(null);
+
+        RectF progressRectF = new RectF(centerX - ringRadius, centerY - ringRadius,
+                centerX + ringRadius, centerY + ringRadius);
+        LinearGradient linearGradient = new LinearGradient(progressRectF.left, progressRectF.top,
+                progressRectF.left, progressRectF.bottom,
+                new int[]{
+                        Color.parseColor("#33D9FF"),
+                        Color.parseColor("#1657D9")
+                }, new float[]{0f, 1f},
+                Shader.TileMode.CLAMP);
+        if (linearGradient != null) {
+            mPaint.setShader(linearGradient);
+        } else {
+            mPaint.setShader(null);
         }
 
-        for (int i = 0; i < mListRing.size(); i++) {
-            this.mListRing.add(mListRing.get(i));
+        if (isRound) {
+            mPaint.setStrokeCap(Paint.Cap.ROUND);
         }
-        if (time > 0)
-            startAnim(time);
-        else
-            invalidate();
-    }
 
+        float angle = (float) AndroidUtils.chuFa(viewProgress * getEffectiveDegree(), viewMax, 2);
+        if (!isClockwise) {
+            angle = -1 * angle;
+        }
+        canvas.drawArc(progressRectF, startAngle, angle, false, mPaint);
+        mPaint.reset();//如果不reset,setShader导致设置进度无效果
+    }
+
+    private void drawRing2(Canvas canvas) {
+        mPaint.setAntiAlias(true);
+        mPaint.setDither(true);
+        mPaint.setStyle(Paint.Style.STROKE);
+        mPaint.setStrokeWidth(ringWidth);
+        mPaint.setColor(ringColor);
+        RectF rectF = new RectF(centerX - ringRadius,
+                centerY - ringRadius,
+                centerX + ringRadius,
+                centerY + ringRadius);
+        if (isRound) {
+            mPaint.setStrokeCap(Paint.Cap.ROUND);
+        }
+        float angle = getEffectiveDegree();
 
-    public RingProgress(Context context) {
-        this(context, null);
+        if (!isClockwise) {
+            angle = -1 * angle;
+        }
+        canvas.drawArc(rectF, startAngle, angle, false, mPaint);
     }
 
-    public RingProgress(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
+    private void drawRing(Canvas canvas) {
+        mPaint.setStyle(Paint.Style.STROKE);
+        mPaint.setStrokeWidth(ringWidth);
+        mPaint.setColor(ringColor);
+        canvas.drawCircle(centerX, centerY, ringRadius, mPaint);
     }
 
-    public RingProgress(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-        init(attrs);
+    /*******************************get*set********************************************/
+    public int getEffectiveDegree() {
+        return 360 - disableAngle;
     }
 
-
-    private void init(AttributeSet attrs) {
-        TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.RingProgress);
-        isCorner = typedArray.getBoolean(R.styleable.RingProgress_showRingCorner, false);
-        isDrawBg = typedArray.getBoolean(R.styleable.RingProgress_showBackground, false);
-        isDrawBgShadow = typedArray.getBoolean(R.styleable.RingProgress_showBackgroundShadow, false);
-        rotateAngle = typedArray.getInt(R.styleable.RingProgress_rotate, 270);
-        ringWidthScale = typedArray.getFloat(R.styleable.RingProgress_ringWidthScale, 0.5f);
-        bgShadowColor = typedArray.getColor(R.styleable.RingProgress_bgShadowColor, bgShadowColor);
-        bgColor = typedArray.getColor(R.styleable.RingProgress_bgColor, bgColor);
-        SweepAngle = typedArray.getInt(R.styleable.RingProgress_ringSweepAngle, 180);
-        typedArray.recycle();
-
-
-        initPaint();
+    public float getProgress() {
+        return progress;
     }
 
-
-    private void initPaint() {
-        mPaint = new Paint();
-
-        mPaintText = new Paint();
-        mPaintText.setAntiAlias(true);
-        mPaintText.setStyle(Paint.Style.FILL);
-        mPaintText.setColor(Color.WHITE);
-
+    public void setProgress(float progress) {
+        setProgress(progress, useAnimation);
     }
 
-
-    private void setmBitmapBg(Paint paint, Bitmap mBitmapBg) {
-        Canvas canvas = null;
-        canvas = new Canvas(mBitmapBg);
-
-        for (int i = 0; i < mListRing.size(); i++) {
-            paint.reset();
-            paint.setAntiAlias(true);
-            paint.setStrokeWidth(ringWidth);
-            paint.setStyle(Paint.Style.STROKE);
-            if (isCorner) {
-                paint.setStrokeCap(Paint.Cap.ROUND);
-                paint.setStrokeJoin(Paint.Join.ROUND);
-            }
-
-            int red = (bgColor & 0xff0000) >> 16;
-            int green = (bgColor & 0x00ff00) >> 8;
-            int blue = (bgColor & 0x0000ff);
-            int colorvaluer = red + (255 - red) / mListRing.size() * i;
-            int colorvalueg = green + (255 - green) / mListRing.size() * i;
-            int colorvalueb = blue + (255 - blue) / mListRing.size() * i;
-
-            paint.setColor(Color.rgb(colorvaluer, colorvalueg, colorvalueb));
-
-
-            Path pathBg = new Path();
-            RectF r = new RectF();
-            r.top = rectFBg.top + ringWidth * i;
-            r.bottom = rectFBg.bottom - ringWidth * i;
-            r.left = rectFBg.left + ringWidth * i;
-            r.right = rectFBg.right - ringWidth * i;
-            mListRing.get(i).setRectFRing(r);
-
-            pathBg.addArc(r, 0, SweepAngle);
-
-            if (i == 0 && isDrawBgShadow) {
-                paint.setShadowLayer(ringWidth / 3,
-                        0 - ringWidth / 4,
-                        0, bgShadowColor);
-            }
-            if (isDrawBg)
-                canvas.drawPath(pathBg, paint);
-
-        }
-        bgChange = false;
-
+    public int getDisableAngle() {
+        return disableAngle;
     }
 
-
-    private Bitmap getmBitmapBg(Paint paint) {
-
-        if (mBitmapBg == null) {
-            mBitmapBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888);
-            setmBitmapBg(paint, mBitmapBg);
-
+    public void setDisableAngle(int disableAngle) {
+        int beforeDisableAngle = this.disableAngle;
+        if (disableAngle > 360) {
+            this.disableAngle = 360;
+        } else if (disableAngle < 0) {
+            this.disableAngle = 0;
+        } else {
+            this.disableAngle = disableAngle;
         }
-
-        if (bgChange) {
-            mBitmapBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888);
-            setmBitmapBg(paint, mBitmapBg);
+        if (useAnimation) {
+            ValueAnimator valueAnimator = ValueAnimator.ofInt(disableAngle, beforeDisableAngle);
+            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    RingProgress.this.disableAngle = (int) animation.getAnimatedValue();
+                    invalidate();
+                }
+            });
+            valueAnimator.setInterpolator(new DecelerateInterpolator());
+            valueAnimator.setDuration(duration);
+            valueAnimator.start();
+        } else {
+            invalidate();
         }
-
-
-        return mBitmapBg;
-
     }
 
-
-    private void drawBg(Canvas canvas, Paint paint) {
-        paint.setAntiAlias(true);
-        canvas.drawBitmap(getmBitmapBg(paint), 0
-                , 0, paint);
+    public int getStartAngle() {
+        return startAngle;
     }
 
+    public RingProgress setStartAngle(int startAngle) {
+        this.startAngle = startAngle;
+        invalidateRingProgress();
+        return this;
+    }
 
-    private void drawProgress(Canvas canvas, Paint paint) {
-
-
-        for (int i = 0; i < mListRing.size(); i++) {
-
-            paint.reset();
-            paint.setAntiAlias(true);
-            paint.setStrokeWidth(ringWidth);
-            paint.setStyle(Paint.Style.STROKE);
-            Path pathProgress = new Path();
-            pathProgress.addArc(mListRing.get(i).getRectFRing(), 0,
-
-                    (int) (SweepAngle / 100f * mListRing.get(i).getProgress() * mAnimatedValue)
-
-            );
-
-            Shader mShader = new LinearGradient(mListRing.get(i).getRectFRing().left, mListRing.get(i).getRectFRing().top,
-                    mListRing.get(i).getRectFRing().left, mListRing.get(i).getRectFRing().bottom,
-                    new int[]{
-                            mListRing.get(i).getStartColor(),
-                            mListRing.get(i).getEndColor()
-
-                    }, new float[]{0f, 1f},
-                    Shader.TileMode.CLAMP);
-
-            paint.setShader(mShader);
-            if (isCorner) {
-                paint.setStrokeCap(Paint.Cap.ROUND);
-                paint.setStrokeJoin(Paint.Join.ROUND);
-            }
-            canvas.drawPath(pathProgress, paint);
-            paint.setShader(null);
-
-
-            mPaintText.setTextSize(mPaint.getStrokeWidth() / 2);
-
-
-            String textvalue = String.valueOf(mListRing.get(i).getValue());
-
-            float arc_length = (float) (Math.PI * mListRing.get(i).getRectFRing().width()
-                    * (mListRing.get(i).getProgress() / 100f))
-                    * (SweepAngle / 360f);
-
-            float textvalue_length = getFontlength(mPaintText, textvalue);
-
-            if (mAnimatedValue == 1) {
-
-
-                if (arc_length - textvalue_length * 1.5f <= 0) {
-
-
-                    float textvalue_length_one = textvalue_length * 1.0f / textvalue.length();
-
-
-                    int textvalue_size = (int) (arc_length / textvalue_length_one);
-
-                    if (textvalue_size >= textvalue.length()) {
-                        canvas.drawTextOnPath(textvalue
-                                ,
-                                pathProgress,
-                                10,
-                                getFontHeight(mPaintText) / 3,
-                                mPaintText);
-                    } else {
-                        String text = textvalue.substring(0, 1);
-                        for (int j = 0; j < textvalue_size; j++) {
-                            text = text + ".";
-                        }
-
-                        canvas.drawTextOnPath(text
-                                ,
-                                pathProgress,
-                                10,
-                                getFontHeight(mPaintText) / 3,
-                                mPaintText);
-
-
-                    }
-                } else {
-
-                    canvas.drawTextOnPath(textvalue
-                            ,
-                            pathProgress,
-                            (float) (arc_length
-                                    - textvalue_length * 1.5f),
-                            getFontHeight(mPaintText) / 3,
-                            mPaintText
-
-                    );
+    public void setProgress(float progress, boolean useAnimation) {
+        float beforeProgress = viewProgress;
+        if (progress > maxProgress) {
+            this.progress = maxProgress;
+        } else if (progress < 0) {
+            this.progress = 0;
+        } else {
+            this.progress = progress;
+        }
+        viewProgress = progress * viewMax / maxProgress;
+        if (useAnimation) {
+            ValueAnimator valueAnimator = ValueAnimator.ofFloat(beforeProgress, viewProgress);
+            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+                @Override
+                public void onAnimationUpdate(ValueAnimator animation) {
+                    RingProgress.this.viewProgress = (float) animation.getAnimatedValue();
+                    RingProgress.this.scaleProgress = RingProgress.this.viewProgress * RingProgress.this.maxProgress / viewMax;
+                    invalidate();
+                    setRingProgress(RingProgress.this.scaleProgress, RingProgress.this.progress, RingProgress.this.maxProgress);
                 }
-            }
-
-
-            String text = String.valueOf(mListRing.get(i).getName());
-
-
-            float textlength = getFontlength(mPaintText, text);
-
-            float textlength_one = textlength * 1.0f / text.length();
-
-            float showtextlength = (float) (arc_length
-                    - textvalue_length * 1.8f);
-            if (showtextlength < 0)
-                showtextlength = 0;
-
-            float textsize = showtextlength / textlength_one;
-
-            if (textsize > text.length()) {
-                textsize = text.length();
-            } else if (textsize < 1) {
-                textsize = 0;
-            }
-
-            canvas.drawTextOnPath(text.substring(0, (int) textsize)
-                    ,
-                    pathProgress,
-
-                    10, getFontHeight(mPaintText) / 3,
-                    mPaintText
-
-            );
-
-
+            });
+            valueAnimator.setInterpolator(new DecelerateInterpolator());
+            valueAnimator.setDuration(duration);
+            valueAnimator.start();
+        } else {
+            RingProgress.this.scaleProgress = this.progress;
+            invalidate();
+            setRingProgress(RingProgress.this.scaleProgress, RingProgress.this.progress, RingProgress.this.maxProgress);
         }
-
     }
 
-
-    @SuppressLint("DrawAllocation")
-    @Override
-    protected void onDraw(Canvas canvas) {
-        super.onDraw(canvas);
-
-
-        canvas.rotate(rotateAngle, getMeasuredWidth() / 2f, getMeasuredHeight() / 2f);
-        canvas.save();
-
-        if (mListRing.size() > 0)
-            ringWidth = (int) (
-                    mWidth / 2f / (mListRing.size() + 0.5f) * (1 - ringWidthScale));
-        mPadding = ringWidth;
-        rectFBg = new RectF(getMeasuredWidth() / 2 - mWidth / 2 + mPadding
-                , getMeasuredHeight() / 2 - mWidth / 2 + mPadding
-                , getMeasuredWidth() / 2 + mWidth / 2 - mPadding
-                , getMeasuredHeight() / 2 + mWidth / 2 - mPadding);
-
-        drawBg(canvas, mPaint);
-        drawProgress(canvas, mPaint);
-        canvas.restore();
-
+    public int getNeiYuanColor() {
+        return neiYuanColor;
     }
 
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        int widthSpecMode = MeasureSpec.getMode(widthMeasureSpec);
-        int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
-        int heightSpecMode = MeasureSpec.getMode(heightMeasureSpec);
-        int heightSpecSize = MeasureSpec.getSize(heightMeasureSpec);
-        if (widthSpecMode == MeasureSpec.AT_MOST
-                && heightSpecMode == MeasureSpec.AT_MOST) {
-            setMeasuredDimension(dip2px(30), dip2px(30));
-        } else if (widthSpecMode == MeasureSpec.AT_MOST) {
-            setMeasuredDimension(heightSpecSize, heightSpecSize);
-        } else if (heightSpecMode == MeasureSpec.AT_MOST) {
-            setMeasuredDimension(widthSpecSize, widthSpecSize);
-        }
-        if (getMeasuredWidth() > getHeight())
-            mWidth = getMeasuredHeight();
-        else
-            mWidth = getMeasuredWidth();
+    public RingProgress setNeiYuanColor(@ColorInt int neiYuanColor) {
+        this.neiYuanColor = neiYuanColor;
+        invalidateRingProgress();
+        return this;
     }
 
-    @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        super.onSizeChanged(w, h, oldw, oldh);
-        if (w > h)
-            mWidth = h;
-        else
-            mWidth = w;
-
-
+    public int getRingRadius() {
+        return ringRadius;
     }
 
-
-    public float getFontlength(Paint paint, String str) {
-        return paint.measureText(str);
+    public RingProgress setRingRadius(int ringRadius) {
+        this.ringRadius = ringRadius;
+        invalidateRingProgress();
+        return this;
     }
 
-    public float getFontHeight(Paint paint) {
-        Paint.FontMetrics fm = paint.getFontMetrics();
-        return fm.descent - fm.ascent;
+    public int getRingWidth() {
+        return ringWidth;
     }
 
-    public int dip2px(float dpValue) {
-        final float scale = getContext().getResources().getDisplayMetrics().density;
-        return (int) (dpValue * scale + 0.5f);
+    public RingProgress setRingWidth(int ringWidth) {
+        this.ringWidth = ringWidth;
+        invalidateRingProgress();
+        return this;
     }
 
-
-    public void startAnim(int time) {
-        stopAnim();
-        startViewAnim(0f, 1f, time);
+    public int getRingColor() {
+        return ringColor;
     }
 
-    private ValueAnimator valueAnimator;
-    private float mAnimatedValue = 1f;
-
-    public void stopAnim() {
-        if (valueAnimator != null) {
-            clearAnimation();
-            valueAnimator.setRepeatCount(0);
-            valueAnimator.cancel();
-            mAnimatedValue = 0f;
-            postInvalidate();
-        }
+    public RingProgress setRingColor(@ColorInt int ringColor) {
+        this.ringColor = ringColor;
+        invalidateRingProgress();
+        return this;
     }
 
-
-    private ValueAnimator startViewAnim(float startF, final float endF, long time) {
-        valueAnimator = ValueAnimator.ofFloat(startF, endF);
-        valueAnimator.setDuration(time);
-        valueAnimator.setInterpolator(new LinearInterpolator());
-        valueAnimator.setRepeatCount(0);
-        valueAnimator.setRepeatMode(ValueAnimator.RESTART);
-        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
-            @Override
-            public void onAnimationUpdate(ValueAnimator valueAnimator) {
-
-                mAnimatedValue = (float) valueAnimator.getAnimatedValue();
-                invalidate();
-
-
-            }
-        });
-        valueAnimator.addListener(new AnimatorListenerAdapter() {
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                super.onAnimationEnd(animation);
-
-            }
-
-            @Override
-            public void onAnimationStart(Animator animation) {
-                super.onAnimationStart(animation);
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-                super.onAnimationRepeat(animation);
-            }
-        });
-        if (!valueAnimator.isRunning()) {
-            valueAnimator.start();
-
-        }
-
-        return valueAnimator;
+    public int getRingProgressColor() {
+        return ringProgressColor;
     }
 
+    public RingProgress setRingProgressColor(@ColorInt int ringProgressColor) {
+        this.ringProgressColor = ringProgressColor;
+        invalidateRingProgress();
+        return this;
+    }
 
-    float startX = 0;
-    float startY = 0;
-
-    @Override
-    public boolean onTouchEvent(MotionEvent event) {
+    /*public int getRingProgressSecondColor() {
+        return ringProgressSecondColor;
+    }
 
-        if (MotionEvent.ACTION_DOWN == event.getAction()) {
-            startX = event.getX();
-            startY = event.getY();
-            return true;
-        } else if (MotionEvent.ACTION_UP == event.getAction()) {
-            if (Math.abs(event.getX() - startX) < 5 &&
-                    Math.abs(event.getY() - startY) < 5) {
+    public RingProgress setRingProgressSecondColor(@ColorInt int ringProgressSecondColor) {
+        this.ringProgressSecondColor = ringProgressSecondColor;
+        invalidateRingProgress();
+        return this;
+    }
+*/
 
+    public boolean isClockwise() {
+        return isClockwise;
+    }
 
-                float distance = (float) Math.sqrt(Math.pow(Math.abs((event.getX() - rectFBg.centerX())), 2)
-                        + Math.pow(Math.abs((event.getY() - rectFBg.centerY())), 2));
+    public RingProgress setClockwise(boolean clockwise) {
+        isClockwise = clockwise;
+        invalidateRingProgress();
+        return this;
+    }
 
-                for (int i = mListRing.size() - 1; i >= 0; i--) {
+    public Shader getProgressShader() {
+        return progressShader;
+    }
 
-                    if (mListRing.get(i).getRectFRing().width() / 2 + ringWidth / 2 > distance
-                            && mListRing.get(i).getRectFRing().width() / 2 - ringWidth / 2 < distance
-                    ) {
+    public RingProgress setProgressShader(Shader progressShader) {
+        this.progressShader = progressShader;
+        invalidateRingProgress();
+        return this;
+    }
 
-                        float angle =
-                                Math.round((float)
-                                        (Math.asin(
-                                                Math.abs((event.getY() - rectFBg.centerY())) / distance) / Math.PI * 180));
+    public float getMaxProgress() {
+        return maxProgress;
+    }
 
-                        if (event.getY() - rectFBg.centerY() >= 0 &&
-                                event.getX() - rectFBg.centerX() >= 0) {
-                            angle = angle + 0;
+    public RingProgress setMaxProgress(float maxProgress) {
+        this.maxProgress = maxProgress;
+        invalidateRingProgress();
+        return this;
+    }
 
-                        } else if (event.getY() - rectFBg.centerY() <= 0 &&
-                                event.getX() - rectFBg.centerX() >= 0) {
-                            angle = 360 - angle;
-                        } else if (event.getY() - rectFBg.centerY() <= 0 &&
-                                event.getX() - rectFBg.centerX() <= 0) {
-                            angle = 180 + angle;
-                        } else if (event.getY() - rectFBg.centerY() >= 0 &&
-                                event.getX() - rectFBg.centerX() <= 0) {
-                            angle = 180 - angle;
+    public boolean isRound() {
+        return isRound;
+    }
 
-                        }
+    public RingProgress setRound(boolean round) {
+        isRound = round;
+        invalidateRingProgress();
+        return this;
+    }
 
+    public boolean isUseAnimation() {
+        return useAnimation;
+    }
 
-                        if (mListRing.get(i).getProgress() / 100f * 360f + rotateAngle <= 360 && rotateAngle <= 360) {
+    public RingProgress setUseAnimation(boolean useAnimation) {
+        this.useAnimation = useAnimation;
+        invalidateRingProgress();
+        return this;
+    }
 
-                            if (angle >= rotateAngle && angle <= mListRing.get(i).getProgress() / 100f * 360f + rotateAngle) {
-                                if (mOnSelectRing != null) {
-                                    mOnSelectRing.Selected(mListRing.get(i));
-                                }
-                            }
+    public int getDuration() {
+        return duration;
+    }
 
+    public RingProgress setDuration(int duration) {
+        this.duration = duration;
+        invalidateRingProgress();
+        return this;
+    }
 
-                        } else if (mListRing.get(i).getProgress() / 100f * 360f + rotateAngle >= 360 && rotateAngle <= 360) {
+    public double getProgressPercent() {
+        return progressPercent;
+    }
 
+    public boolean isDecimal() {
+        return isDecimal;
+    }
 
-                            if (angle >= rotateAngle && angle <= 360) {
-                                if (mOnSelectRing != null) {
-                                    mOnSelectRing.Selected(mListRing.get(i));
-                                }
-                            } else if (angle >= 0 && mListRing.get(i).getProgress() / 100f * 360f + rotateAngle - 360 >= angle) {
-                                if (mOnSelectRing != null) {
-                                    mOnSelectRing.Selected(mListRing.get(i));
-                                }
-                            }
+    public RingProgress setDecimal(boolean decimal) {
+        isDecimal = decimal;
+        invalidateRingProgress();
+        return this;
+    }
 
+    public int getDecimalPointLength() {
+        return decimalPointLength;
+    }
 
-                        }
+    public RingProgress setDecimalPointLength(int decimalPointLength) {
+        this.decimalPointLength = decimalPointLength;
+        invalidateRingProgress();
+        return this;
+    }
 
+    public boolean isShowPercentText() {
+        return isShowPercentText;
+    }
 
-                        return true;
+    public RingProgress setShowPercentText(boolean showPercentText) {
+        isShowPercentText = showPercentText;
+        invalidateRingProgress();
+        return this;
+    }
 
-                    }
+    public int getTextColor() {
+        return textColor;
+    }
 
-                }
+    public RingProgress setTextColor(@ColorInt int textColor) {
+        this.textColor = textColor;
+        invalidateRingProgress();
+        return this;
+    }
 
+    public int getTextSize() {
+        return textSize;
+    }
 
-                return true;
+    public RingProgress setTextSize(int textSize) {
+        this.textSize = textSize;
+        invalidateRingProgress();
+        return this;
+    }
 
-            }
+    public OnRingProgressInter getOnRingProgressInter() {
+        return onRingProgressInter;
+    }
 
+    public RingProgress setOnRingProgressInter(OnRingProgressInter onRingProgressInter) {
+        this.onRingProgressInter = onRingProgressInter;
+        return this;
+    }
 
+    private void setRingProgress(float scaleProgress, float progress, float max) {
+        if (onRingProgressInter != null) {
+            onRingProgressInter.progress(scaleProgress, progress, max);
         }
-
-        return false;
     }
+ /*   public float getViewWidth() {
+        return viewWidth;
+    }
+    public float getViewHeight() {
+        return viewHeight;
+    }*/
 
+    private void invalidateRingProgress() {
+        invalidate();
+    }
 
-    private OnSelectRing mOnSelectRing;
-
-    public OnSelectRing getmOnSelectRing() {
-        return mOnSelectRing;
+    private int px2dip(Context context, float pxValue) {
+        float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (pxValue / scale + 0.5F);
     }
 
-    public void setOnSelectRing(OnSelectRing mOnSelectRing) {
-        this.mOnSelectRing = mOnSelectRing;
+    private int dip2px(Context context, float dipValue) {
+        float scale = context.getResources().getDisplayMetrics().density;
+        return (int) (dipValue * scale + 0.5F);
     }
 }
index 4ae33ec..03fc7bb 100644 (file)
@@ -4,6 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools">
 
     <data>
+
         <variable
             name="pedNumber"
             type="String" />
     </data>
 
     <FrameLayout
-        android:background="@mipmap/qs_background"
-        android:layout_height="match_parent"
         android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@mipmap/bg"
         tools:context=".fragment.pedometer.PedMainFragment">
 
         <com.ic.sport.widget.ring.RingProgress
             android:id="@+id/ring_progress"
-            android:layout_height="match_parent"
             android:layout_width="match_parent"
-            app:bgColor="#9C9B9B"
-            app:ringSweepAngle="280"
-            app:ringWidthScale="0.7"
-            app:rotate="130"
-            app:showBackground="true"
-            app:showRingCorner="true" />
+            android:layout_height="match_parent"
+            app:decimalPointLength="1"
+            app:isClockwise="true"
+            app:isDecimal="true"
+            app:isShowPercentText="false"
+            app:maxProgress="1000"
+            app:neiYuanColor="@color/transparent"
+            app:progress="1000"
+            app:ringColor="@color/top_color2"
+            app:ringProgressColor="@color/blue_00"
+            app:ringWidth="30dp"
+            app:useAnimation="true" />
 
         <TextView
             android:id="@+id/ped_number_tv"
-            android:includeFontPadding="false"
-            android:layout_gravity="center_horizontal"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
             android:layout_marginTop="90dp"
-            android:layout_width="wrap_content"
+            android:includeFontPadding="false"
             android:text="@{pedNumber}"
-            android:textColor="#FCBE03"
+            android:textColor="@color/white"
             android:textSize="72sp" />
 
         <TextView
             android:id="@+id/ped_date_tv"
-            android:layout_gravity="center_horizontal"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal"
             android:layout_marginTop="60dp"
-            android:layout_width="wrap_content"
             android:text="@string/ped_main_today"
             android:textColor="#FFFFFF"
             android:textSize="36sp" />
 
         <TextView
-            android:includeFontPadding="false"
-            android:layout_gravity="center_horizontal|bottom"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal|bottom"
             android:layout_marginBottom="90dp"
-            android:layout_width="wrap_content"
+            android:includeFontPadding="false"
             android:text="@string/ped_main_step"
-            android:textColor="#90FFFFFF"
+            android:textColor="@color/white"
             android:textSize="36sp" />
 
         <TextView
-            android:drawableTop="@drawable/ic_red_flag"
-            android:layout_gravity="center_horizontal|bottom"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="15dp"
             android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_horizontal|bottom"
+            android:layout_marginBottom="32dp"
             android:drawablePadding="1dp"
             android:text="@{pedTarget}"
-            android:textColor="#FFFFFF"
-            android:textSize="32sp" />
+            android:textColor="@color/white"
+            android:textSize="28sp"
+            android:textStyle="bold" />
     </FrameLayout>
 </layout>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-mdpi/bg.png b/app/src/main/res/mipmap-mdpi/bg.png
new file mode 100644 (file)
index 0000000..6124dce
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/bg.png differ
index 56cf593..55bd90a 100644 (file)
@@ -46,4 +46,5 @@
     <string name="pedometer_unit_inch">inch</string>
     <string name="pedometer_unit_foot">feet</string>
     <string name="reached_step_goal">completed</string>
+    <string name="target_text">aim:</string>
 </resources>
index fbfff96..8326cde 100644 (file)
@@ -46,5 +46,6 @@
     <string name="pedometer_unit_inch">英寸</string>
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
+    <string name="target_text">目标:</string>
 
 </resources>
index 8195e2a..4841326 100644 (file)
@@ -19,7 +19,6 @@
     <string name="tips_distance_unit">公里</string>
 
 
-
     <string name="ped_main_today">今日</string>
     <string name="ped_main_step">步</string>
 
@@ -48,4 +47,5 @@
     <string name="pedometer_unit_inch">英寸</string>
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
+    <string name="target_text">目标:</string>
 </resources>
index 822d36a..93ddf24 100644 (file)
@@ -1,14 +1,44 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 
-    <declare-styleable name="RingProgress">
-        <attr name="bgColor" format="color|reference" />
-        <attr name="bgShadowColor" format="color|reference"/>
-        <attr name="rotate" format="integer"/>
-        <attr name="showBackground" format="boolean"/>
-        <attr name="showBackgroundShadow" format="boolean"/>
-        <attr name="showRingCorner" format="boolean"/>
-        <attr name="ringWidthScale" format="float"/>
-        <attr name="ringSweepAngle" format="integer"/>
+    <declare-styleable name="CircleProgress">
+        <!--内圆颜色-->
+        <attr name="neiYuanColor" format="color"/>
+        <!--圆环半径-->
+        <attr name="ringRadius" format="dimension"/>
+        <!--圆环宽度-->
+        <attr name="ringWidth" format="dimension"/>
+        <!--圆环颜色-->
+        <attr name="ringColor" format="color"/>
+        <!--圆环进度颜色-->
+        <attr name="ringProgressColor" format="color"/>
+        <!--开始角度-->
+        <attr name="startAngle" format="integer"/>
+        <!--是否顺时针-->
+        <attr name="isClockwise" format="boolean"/>
+        <!--当前进度-->
+        <attr name="progress" format="float"/>
+        <!--总进度-->
+        <attr name="maxProgress" format="float"/>
+        <!--不绘制的度数-->
+        <attr name="disableAngle" format="integer"/>
+        <!--圆环进度是否为圆角-->
+        <attr name="isRound" format="boolean"/>
+        <!--是否设置动画-->
+        <attr name="useAnimation" format="boolean"/>
+        <!--动画执行时间-->
+        <attr name="duration" format="integer"/>
+        <!--进度百分比数值是否含小数-->
+        <!--<attr name="progressPercent" format="integer"/>-->
+        <attr name="isDecimal" format="boolean"/>
+        <!--小数点后几位-->
+        <attr name="decimalPointLength" format="integer"/>
+        <!--是否显示百分比-->
+        <attr name="isShowPercentText" format="boolean"/>
+        <!--文字颜色-->
+        <attr name="textColor" format="color"/>
+        <!--文字大小-->
+        <attr name="textSize" format="dimension"/>
+
     </declare-styleable>
 </resources>
\ No newline at end of file
index 4cf8613..6a1975d 100644 (file)
@@ -4,7 +4,63 @@
     <color name="colorPrimaryDark">#00574B</color>
     <color name="colorAccent">#D81B60</color>
 
+    <color name="mainBgColor">#000000</color>
+
+    <!-- 主题颜色-->
+    <color name="top_color1">#20000000</color>
+    <color name="top_color2">#FFCECBCB</color>
+
+
+    <color name="gray_f6">#f6f6f6</color>
+    <color name="gray_332">#000000</color>
+    <color name="gray_33">#333333</color>
+    <color name="gray_44">#444444</color>
+    <color name="gray_66">#666666</color>
+    <color name="gray_99">#999999</color>
+    <color name="gray_ea">#eaeaea</color>
+    <color name="gray_d7">#d7d7d7</color>
+    <color name="gray_f2">#f2f2f2</color>
+    <color name="gray_61">#616161</color>
+    <color name="background_f2">#f2f2f2</color>
+    <color name="image_bg">#FFF1EFEF</color>
+    <color name="gray_d4">#d4d4d4</color>
+    <color name="gray_dd">#DDDDDD</color>
+    <color name="green">#2DDB97</color>
+    <color name="green_press">#FF20D18C</color>
+    <color name="green1">#34e8a6</color>
+    <color name="green2">#22ddb0</color>
+    <color name="green_qian">#E6F9F7</color>
+    <color name="gray_ban">#50000000</color>
 
+
+    <color name="home_green">#06C1AE</color>
+    <color name="home_text_color">#419BF3</color>
+    <color name="orange">#FFC820</color>
+    <color name="orange_press">#eaa304</color>
+    <color name="blue">#4ed3fd</color>
+    <color name="red">#fc353a</color>
+    <color name="gray_press">#FFE4E0E0</color>
+    <color name="blue_press">#E2419BF3</color>
+    <color name="black_33">#333333</color>
+    <color name="home_title">#2ACBE0</color>
+    <color name="orange_ff">#ff712b</color>
+    <color name="orange_ff2">#FFF2EB</color>
+    <color name="blue_00">#419BF3</color>
+    <color name="hint_color">#FFC8C8C8</color>
+
+
+    <color name="colorText">#848484</color>
+    <color name="c_icon_normal">#848484</color>
+    <color name="c_icon">#56abe4</color>
+    <color name="colorPrimaryAlpha">#70000000</color>
+    <color name="colorPrimaryAlpha1">#BF58C2F7</color>
+    <color name="white">#ffffff</color>
+    <color name="white_half">#86FFFFFF</color>
+    <color name="gray_AB">#616161</color>
+    <color name="black">#000000</color>
     <color name="transparent">#00000000</color>
-    <color name="mainBgColor">#000000</color>
+    <color name="transparent_half">#70000000</color>
+    <color name="transparent_half_darker">#90000000</color>
+    <color name="transparent_half_darker_darker">#a0000000</color>
+    <color name="transparent_half_darker_darker_dark">#b0000000</color>
 </resources>
index 5676129..005eeed 100644 (file)
@@ -47,4 +47,5 @@
     <string name="pedometer_unit_inch">英寸</string>
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
+    <string name="target_text">目标:</string>
 </resources>
index 7e076d2..f078e1a 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Dec 04 09:20:50 CST 2020\r
-VERSION_CODE=21\r
+#Thu Apr 15 11:35:37 CST 2021\r
+VERSION_CODE=22\r