├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── xyz │ │ └── kongzz │ │ └── countdownview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── fonts │ │ │ └── text_backwards.ttf │ ├── java │ │ └── xyz │ │ │ └── kongzz │ │ │ └── countdownview │ │ │ ├── MainActivity.java │ │ │ └── ProgressRing.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── xyz │ └── kongzz │ └── countdownview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── img ├── effect.png └── view.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | xmlns:android 11 | 12 | ^$ 13 | 14 | 15 | 16 |
17 |
18 | 19 | 20 | 21 | xmlns:.* 22 | 23 | ^$ 24 | 25 | 26 | BY_NAME 27 | 28 |
29 |
30 | 31 | 32 | 33 | .*:id 34 | 35 | http://schemas.android.com/apk/res/android 36 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | 44 | .*:name 45 | 46 | http://schemas.android.com/apk/res/android 47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | name 56 | 57 | ^$ 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 66 | style 67 | 68 | ^$ 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | .* 78 | 79 | ^$ 80 | 81 | 82 | BY_NAME 83 | 84 |
85 |
86 | 87 | 88 | 89 | .* 90 | 91 | http://schemas.android.com/apk/res/android 92 | 93 | 94 | ANDROID_ATTRIBUTE_ORDER 95 | 96 |
97 |
98 | 99 | 100 | 101 | .* 102 | 103 | .* 104 | 105 | 106 | BY_NAME 107 | 108 |
109 |
110 |
111 |
112 |
113 |
-------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CountDownView 2 | **简介** 3 | 4 | 这是一个渐变加载进度条,可以用来做时间倒计时,中间可添加文字。 5 | 6 | **效果预览** 7 | 8 | ![png](https://github.com/Kong-xyZ/CountDownView/blob/master/img/effect.png) 9 | ![gif](https://github.com/Kong-xyZ/CountDownView/blob/master/img/view.gif) 10 | 11 | **使用方法** 12 | 13 | 1.在XML布局中添加控件 14 | 15 | ```xml 16 | 32 | ``` 33 | 34 | **具体属性介绍** 35 | 36 | ```xml 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | ``` 60 | 61 | 2.在代码中使用 62 | 63 | ```java 64 | mProgressRing.setText(mProgressSecond + "S"); 65 | mProgressRing.setProgress((float) (mProgressSecond * 10 / 6)); 66 | ``` 67 | 68 | 通过这两个接口对View进行参数设置。 69 | 如果要进度条走的更加丝滑,可以对setProgress中的值更为精细,0.0~100.0(精确度到0.1)即可。 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | defaultConfig { 7 | applicationId "xyz.kongzz.countdownview" 8 | minSdkVersion 21 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'androidx.appcompat:appcompat:1.0.2' 25 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 26 | testImplementation 'junit:junit:4.12' 27 | androidTestImplementation 'androidx.test.ext:junit:1.1.0' 28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' 29 | } 30 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/xyz/kongzz/countdownview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package xyz.kongzz.countdownview; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("xyz.kongzz.countdownview", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/assets/fonts/text_backwards.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/assets/fonts/text_backwards.ttf -------------------------------------------------------------------------------- /app/src/main/java/xyz/kongzz/countdownview/MainActivity.java: -------------------------------------------------------------------------------- 1 | package xyz.kongzz.countdownview; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | import android.os.Message; 8 | import android.util.Log; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | private ProgressRing mProgressRing; 13 | private int mProgressSecond = 60; 14 | private final int MESSAGE_PROGRESS = 0; 15 | 16 | private Handler mHandler = new Handler(new Handler.Callback() { 17 | @Override 18 | public boolean handleMessage(Message msg) { 19 | switch (msg.what) { 20 | case MESSAGE_PROGRESS: 21 | mProgressSecond--; 22 | if (mProgressSecond < 0) { 23 | // TODO 倒计时结束 24 | mProgressSecond = 60; 25 | return false; 26 | } 27 | mProgressRing.setText(mProgressSecond + "S"); 28 | mProgressRing.setProgress((float) (mProgressSecond * 10 / 6)); 29 | mHandler.sendEmptyMessageDelayed(MESSAGE_PROGRESS, 1000); 30 | break; 31 | default: 32 | break; 33 | } 34 | return false; 35 | } 36 | }); 37 | 38 | @Override 39 | protected void onCreate(Bundle savedInstanceState) { 40 | super.onCreate(savedInstanceState); 41 | setContentView(R.layout.activity_main); 42 | 43 | mProgressRing = findViewById(R.id.pr_progress); 44 | 45 | mHandler.sendEmptyMessage(MESSAGE_PROGRESS); 46 | 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/xyz/kongzz/countdownview/ProgressRing.java: -------------------------------------------------------------------------------- 1 | package xyz.kongzz.countdownview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.Rect; 9 | import android.graphics.RectF; 10 | import android.graphics.Typeface; 11 | import android.util.AttributeSet; 12 | import android.view.View; 13 | 14 | import androidx.annotation.FloatRange; 15 | import androidx.annotation.Nullable; 16 | 17 | /** 18 | * @author Kong 19 | * @date 2020-01-10 20 | * @desc 渐变加载进度条 21 | */ 22 | public class ProgressRing extends View { 23 | 24 | // 进度条起始颜色 25 | private int mProgressStartColor; 26 | // 进度条结束颜色 27 | private int mProgressEndColor; 28 | // 背景起始颜色 29 | private int mBgStartColor; 30 | // 背景中间颜色 31 | private int mBgMidColor; 32 | // 背景结束颜色 33 | private int mBgEndColor; 34 | // 进度条的进度值 35 | private float mProgress; 36 | // 进度条中间文字 37 | private String mText; 38 | // 进度条的宽度 39 | private float mProgressWidth; 40 | // 起始角度 41 | private int mStartAngle; 42 | // 扫视角度 43 | private int mSweepAngle; 44 | // 单位角度 45 | private float mUnitAngle; 46 | // 绘制的高度 47 | private int mMeasureHeight; 48 | // 绘制的宽度 49 | private int mMeasureWidth; 50 | // 背景Paint 51 | private Paint mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); 52 | // 进度Paint 53 | private Paint mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); 54 | 55 | private RectF mRectF; 56 | private Paint mPaint; 57 | private Paint mMainCirclePaint; 58 | private Paint mWhiteCirclePaint; 59 | 60 | // 文字字体 61 | private Typeface mFace; 62 | // 当前进度 63 | private float mCurProgress = 0; 64 | 65 | private Context mContext; 66 | 67 | public ProgressRing(Context context, @Nullable AttributeSet attrs) { 68 | super(context, attrs); 69 | 70 | mContext = context; 71 | 72 | TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ProgressRing); 73 | 74 | mProgressStartColor = ta.getColor(R.styleable.ProgressRing_pr_progress_start_color, Color.YELLOW); 75 | mProgressEndColor = ta.getColor(R.styleable.ProgressRing_pr_progress_end_color, mProgressStartColor); 76 | mBgStartColor = ta.getColor(R.styleable.ProgressRing_pr_bg_start_color, Color.LTGRAY); 77 | mBgMidColor = ta.getColor(R.styleable.ProgressRing_pr_bg_mid_color, mBgStartColor); 78 | mBgEndColor = ta.getColor(R.styleable.ProgressRing_pr_bg_end_color, mBgStartColor); 79 | mProgress = ta.getInt(R.styleable.ProgressRing_pr_progress, 80); 80 | mProgressWidth = ta.getDimension(R.styleable.ProgressRing_pr_progress_width, 8f); 81 | mStartAngle = ta.getInt(R.styleable.ProgressRing_pr_start_angle, -90); 82 | mSweepAngle = ta.getInt(R.styleable.ProgressRing_pr_sweep_angle, 360); 83 | mText = ta.getString(R.styleable.ProgressRing_pr_show_text); 84 | 85 | ta.recycle(); 86 | 87 | mUnitAngle = (float) (mSweepAngle / 100.0); 88 | 89 | mBgPaint.setStyle(Paint.Style.STROKE); 90 | mBgPaint.setStrokeCap(Paint.Cap.ROUND); 91 | mBgPaint.setStrokeWidth(mProgressWidth); 92 | 93 | mProgressPaint.setStyle(Paint.Style.STROKE); 94 | mProgressPaint.setStrokeCap(Paint.Cap.ROUND); 95 | mProgressPaint.setStrokeWidth(mProgressWidth); 96 | 97 | mFace = Typeface.createFromAsset(getContext().getAssets(), "fonts/text_backwards.ttf"); 98 | 99 | mPaint = new Paint(); 100 | mPaint.setTextSize(dp2px(30)); 101 | mPaint.setStyle(Paint.Style.FILL); 102 | mPaint.setTextAlign(Paint.Align.CENTER); 103 | mPaint.setColor(Color.BLACK); 104 | mPaint.setTypeface(mFace); 105 | mPaint.setAntiAlias(true); 106 | 107 | mMainCirclePaint = new Paint(); 108 | mMainCirclePaint.setColor(getResources().getColor(R.color.bg_ring)); 109 | mMainCirclePaint.setStyle(Paint.Style.FILL); 110 | mMainCirclePaint.setStrokeWidth(8); 111 | 112 | mWhiteCirclePaint = new Paint(); 113 | mWhiteCirclePaint.setColor(getResources().getColor(R.color.color_white)); 114 | mWhiteCirclePaint.setStyle(Paint.Style.FILL); 115 | mWhiteCirclePaint.setStrokeWidth(8); 116 | 117 | mText = ""; 118 | } 119 | 120 | @Override 121 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 122 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 123 | mMeasureWidth = getMeasuredWidth(); 124 | mMeasureHeight = getMeasuredHeight(); 125 | if (mRectF == null) { 126 | float halfProgressWidth = mProgressWidth / 2; 127 | mRectF = new RectF(halfProgressWidth + getPaddingLeft() + dp2px(26), 128 | halfProgressWidth + getPaddingTop() + dp2px(26), 129 | mMeasureWidth - halfProgressWidth - getPaddingRight() - dp2px(26), 130 | mMeasureHeight - halfProgressWidth - getPaddingBottom() - dp2px(26)); 131 | } 132 | } 133 | 134 | @Override 135 | protected void onDraw(Canvas canvas) { 136 | super.onDraw(canvas); 137 | mCurProgress = mProgress; 138 | // 绘制背景 139 | canvas.drawCircle(getWidth() >> 1, getHeight() >> 1, 140 | dp2px(89), mMainCirclePaint); 141 | canvas.drawCircle(getWidth() >> 1, getHeight() >> 1, 142 | dp2px(54), mWhiteCirclePaint); 143 | // 绘制进度 144 | drawProgress(canvas); 145 | // 绘制文字 146 | drawText(canvas); 147 | } 148 | 149 | /** 150 | * 绘制文字 151 | */ 152 | private void drawText(Canvas canvas) { 153 | Rect bounds = new Rect(); 154 | mPaint.getTextBounds(mText, 0, mText.length(), bounds); 155 | int height = bounds.height(); 156 | canvas.drawText(mText, canvas.getWidth() >> 1, (canvas.getHeight() >> 1) + (height >> 1), mPaint); 157 | } 158 | 159 | /** 160 | * 绘制进度条 161 | */ 162 | private void drawProgress(Canvas canvas) { 163 | for (int i = 0, end = (int) (mCurProgress * mUnitAngle); i <= end; i++) { 164 | mProgressPaint.setColor(getGradient(i / (mCurProgress * mUnitAngle), 165 | mProgressStartColor, mProgressEndColor)); 166 | canvas.drawArc(mRectF, 167 | mSweepAngle + mStartAngle - i, 168 | 1, 169 | false, 170 | mProgressPaint); 171 | } 172 | } 173 | 174 | /** 175 | * 设置进度 176 | */ 177 | public void setProgress(@FloatRange(from = 0, to = 100) float progress) { 178 | this.mProgress = progress; 179 | invalidate(); 180 | } 181 | 182 | /** 183 | * 获取当前进度 184 | */ 185 | public float getProgress() { 186 | return mProgress; 187 | } 188 | 189 | /** 190 | * 设置文字 191 | */ 192 | public void setText(String text) { 193 | mText = text; 194 | } 195 | 196 | /** 197 | * 获取当前渐变颜色 198 | */ 199 | public int getGradient(float fraction, int startColor, int endColor) { 200 | if (fraction > 1) { 201 | fraction = 1; 202 | } 203 | int alphaStart = Color.alpha(startColor); 204 | int redStart = Color.red(startColor); 205 | int blueStart = Color.blue(startColor); 206 | int greenStart = Color.green(startColor); 207 | int alphaEnd = Color.alpha(endColor); 208 | int redEnd = Color.red(endColor); 209 | int blueEnd = Color.blue(endColor); 210 | int greenEnd = Color.green(endColor); 211 | int alphaDifference = alphaEnd - alphaStart; 212 | int redDifference = redEnd - redStart; 213 | int blueDifference = blueEnd - blueStart; 214 | int greenDifference = greenEnd - greenStart; 215 | int alphaCurrent = (int) (alphaStart + fraction * alphaDifference); 216 | int redCurrent = (int) (redStart + fraction * redDifference); 217 | int blueCurrent = (int) (blueStart + fraction * blueDifference); 218 | int greenCurrent = (int) (greenStart + fraction * greenDifference); 219 | return Color.argb(alphaCurrent, redCurrent, greenCurrent, blueCurrent); 220 | } 221 | 222 | public int dp2px(final float dpValue) { 223 | final float scale = mContext.getResources().getDisplayMetrics().density; 224 | return (int) (dpValue * scale + 0.5f); 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFC700 4 | #FFC700 5 | @color/color_white 6 | #88FFFFFF 7 | #f0262626 8 | 9 | #FFFFFFFF 10 | 11 | #FFC700 12 | #D5C8B8 13 | #C8C8CB 14 | #B1B1B1 15 | #C7C7C7 16 | #000001 17 | #4D000001 18 | #7A000001 19 | #99000001 20 | #BD000001 21 | #DBDBDB 22 | #D9DBE2 23 | #8A8D8F 24 | #3D8A8D8F 25 | #758A8D8F 26 | 27 | #D9DBE2 28 | #FFF4EE 29 | 30 | #A2AFCA 31 | @color/color_white 32 | #00000000 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CountDownView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/xyz/kongzz/countdownview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package xyz.kongzz.countdownview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.5.3' 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | 21 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 10 15:39:14 GMT+08:00 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /img/effect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/img/effect.png -------------------------------------------------------------------------------- /img/view.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kong-xyZ/CountDownView/374ff097c2b3472d2bb123f1a16e1b3dcec38cdf/img/view.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name='CountDownView' 3 | --------------------------------------------------------------------------------