├── .gitignore
├── README.md
├── RectCircleProgressButton
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── clownqiang
│ │ └── rectcircleprogressbutton
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── clownqiang
│ │ │ └── rectcircleprogressbutton
│ │ │ └── RectCircleProgressButton.java
│ └── res
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── clownqiang
│ └── rectcircleprogressbutton
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── clownqiang
│ │ └── sample
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── clownqiang
│ │ │ └── sample
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── clownqiang
│ └── sample
│ └── ExampleUnitTest.java
├── screenshot
└── android.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea/
5 | .DS_Store
6 | /build
7 | /captures
8 |
9 | deploy.settings
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RectCircleProgressButton
2 |
3 |
4 | 前段时间工作需要用到一个按钮的效果,但是简单做了一下,最近闲下来一点整理了一下,代码略乱,欢迎各种类型issue,后续看看再整理吧。
5 |
6 |
7 |
8 | ### 怎么使用
9 | ```
10 | dependencies {
11 | compile 'com.clownqiang:RectCircleProgressButton:1.0.1'
12 | }
13 | ```
14 |
15 | ```
16 |
30 | ```
31 |
32 | ### 配置
33 | ```
34 | rcpb_rec_text 按钮显示文字,默认显示Download
35 | rcpb_rec_text_color 文字颜色
36 | rcpb_rec_text_size 文字大小
37 | rcpb_rec_color 矩形状态颜色
38 | rcpb_rec_to_circle_color 矩形变换到圆形动画时颜色
39 | rcpb_circle_color 圆形状态颜色
40 | rcpb_rec_stoke_width 线条宽度
41 | rcpb_rec_to_circle_interval 矩形变换圆形动画时间(ms)
42 | rcpb_rotate_speed 圆形旋转动画时间(ms)
43 | ```
44 |
45 | 可以实现接口AnimationStatusListener:
46 |
47 | ```
48 | void startLoading(int status); //变为圆形旋转状态,开始加载
49 | void resetView(int status); //reset到矩形状态,停止加载
50 | ```
51 |
52 | 同时方法resetButtonView()用于需要代码主动回退状态。
53 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | deploy.gradle
3 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:24.0.0'
25 | }
26 |
27 | //apply from: 'deploy.gradle'
--------------------------------------------------------------------------------
/RectCircleProgressButton/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/clownqiang/Mac_Dev_Package/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/androidTest/java/com/clownqiang/rectcircleprogressbutton/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.rectcircleprogressbutton;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/main/java/com/clownqiang/rectcircleprogressbutton/RectCircleProgressButton.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.rectcircleprogressbutton;
2 |
3 | import java.lang.ref.WeakReference;
4 | import java.util.concurrent.ExecutorService;
5 | import java.util.concurrent.Executors;
6 |
7 | import android.animation.Animator;
8 | import android.animation.AnimatorListenerAdapter;
9 | import android.animation.ValueAnimator;
10 | import android.annotation.TargetApi;
11 | import android.content.Context;
12 | import android.content.res.TypedArray;
13 | import android.graphics.Canvas;
14 | import android.graphics.Color;
15 | import android.graphics.Paint;
16 | import android.graphics.Path;
17 | import android.graphics.RectF;
18 | import android.os.Build;
19 | import android.os.Handler;
20 | import android.os.Message;
21 | import android.util.AttributeSet;
22 | import android.view.View;
23 |
24 | /**
25 | * Created by clownqiang on 16/7/19.
26 | */
27 | public class RectCircleProgressButton extends View
28 | implements
29 | View.OnClickListener {
30 |
31 | public static final int RECTANGLE = 0;
32 | public static final int REC_TO_CIRCLE = 1;
33 | public static final int CIRCLE_TO_REC = 2;
34 | public static final int CIRCLE = 3;
35 | public static final int CIRCLE_ROUND = 4;
36 |
37 | private static final String DEFAULT_TEXT = "Download";
38 |
39 | private AnimationStatusListener listener;
40 | private int status = RECTANGLE;
41 |
42 | private Paint paint;
43 | private int recColor = Color.BLACK;
44 | private int recToCircleColor = Color.BLACK;
45 | private int circleColor = Color.RED;
46 | // 圆角半径
47 | private int r = 0;
48 | // 圆形的圆心坐标
49 | private int x, y = 0;
50 | // 画笔宽度
51 | private int strokeWidth = 0;
52 | // Button长宽
53 | private int REC_WIDTH;
54 | private int REC_HEIGHT;
55 | private int LIMIT_VALUE;
56 | private int drawWidth;
57 | private int drawHeight;
58 | // 由长方形变化到圆形动画时间
59 | private int recToCircleInterval;
60 | // 旋转动画速度(ms)
61 | private int rotateSpeed;
62 | // 默认显示的文字
63 | private String recText;
64 | private int recTextColor;
65 | private int recTextSize;
66 | // 旋转角度变化
67 | private int startAngle = 15;
68 | // 控制CIRCLE_ROUND 在线程中绘制
69 | private boolean isCircleRoundRun = false;
70 |
71 | private boolean lock = false;
72 |
73 | private CircleRoundThread circleRoundTask;
74 |
75 | private ExecutorService executors;
76 |
77 | private MessageHandler handler;
78 |
79 | public RectCircleProgressButton(Context context, AttributeSet attrs) {
80 | super(context, attrs);
81 | init(context, attrs);
82 | }
83 |
84 | private void init(Context context, AttributeSet attrs) {
85 | TypedArray typedArray = null;
86 | try {
87 | typedArray = context.obtainStyledAttributes(attrs,
88 | R.styleable.RectCircleProgressButton);
89 | recText = typedArray
90 | .getString(R.styleable.RectCircleProgressButton_rcpb_rec_text);
91 | recTextColor = typedArray.getColor(
92 | R.styleable.RectCircleProgressButton_rcpb_rec_text_color,
93 | Color.BLACK);
94 | recTextSize = typedArray.getDimensionPixelSize(
95 | R.styleable.RectCircleProgressButton_rcpb_rec_text_size,
96 | getResources().getDimensionPixelSize(
97 | R.dimen.font_text_size_default));
98 | recColor = typedArray.getColor(
99 | R.styleable.RectCircleProgressButton_rcpb_rec_color,
100 | Color.BLACK);
101 | recToCircleColor = typedArray
102 | .getColor(
103 | R.styleable.RectCircleProgressButton_rcpb_rec_to_circle_color,
104 | Color.BLACK);
105 | circleColor = typedArray.getColor(
106 | R.styleable.RectCircleProgressButton_rcpb_circle_color,
107 | Color.RED);
108 | strokeWidth = typedArray.getDimensionPixelSize(
109 | R.styleable.RectCircleProgressButton_rcpb_rec_stoke_width,
110 | 2);
111 | rotateSpeed = typedArray.getInteger(
112 | R.styleable.RectCircleProgressButton_rcpb_rotate_speed, 20);
113 | recToCircleInterval = typedArray
114 | .getInteger(
115 | R.styleable.RectCircleProgressButton_rcpb_rec_to_circle_interval,
116 | 800);
117 | recText = null == recText ? DEFAULT_TEXT : recText;
118 | } finally {
119 | if (typedArray != null) {
120 | typedArray.recycle();
121 | }
122 | }
123 | initPaint();
124 | initThread();
125 | setOnClickListener(this);
126 | }
127 | private void initPaint() {
128 | paint = new Paint();
129 | paint.setAntiAlias(true);
130 | }
131 |
132 | private void initThread() {
133 | handler = new MessageHandler(this);
134 | executors = Executors.newSingleThreadExecutor();
135 | circleRoundTask = new CircleRoundThread();
136 | }
137 |
138 | @Override
139 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
140 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
141 | initRectValue();
142 | }
143 |
144 | private void initRectValue() {
145 | REC_WIDTH = getMeasuredWidth();
146 | REC_HEIGHT = getMeasuredHeight();
147 | LIMIT_VALUE = (REC_WIDTH + REC_HEIGHT) / 2;
148 |
149 | drawWidth = REC_WIDTH;
150 | drawHeight = REC_HEIGHT;
151 |
152 | r = REC_HEIGHT / 2;
153 | x = REC_WIDTH / 2;
154 | y = REC_HEIGHT / 2;
155 |
156 | }
157 | @Override
158 | protected void onDraw(Canvas canvas) {
159 | super.onDraw(canvas);
160 | drawTypeByStatus(status, canvas, drawWidth, drawHeight);
161 | }
162 |
163 | private void drawTypeByStatus(int status, Canvas canvas, int width,
164 | int height) {
165 | switch (status) {
166 | case RECTANGLE :
167 | paint.setColor(recColor);
168 | paint.setStrokeWidth(strokeWidth);
169 | paint.setStyle(Paint.Style.STROKE);
170 | drawRoundRect(width, height, canvas);
171 |
172 | paint.setTextAlign(Paint.Align.CENTER);
173 | paint.setColor(recTextColor);
174 | paint.setTextSize(recTextSize);
175 | paint.setStyle(Paint.Style.FILL);
176 | drawText(width, height, recText, canvas);
177 | break;
178 | case REC_TO_CIRCLE :
179 | paint.setColor(recToCircleColor);
180 | paint.setStyle(Paint.Style.STROKE);
181 | paint.setStrokeWidth(strokeWidth);
182 | drawRoundRect(width, height, canvas);
183 | break;
184 | case CIRCLE_TO_REC :
185 | paint.setColor(recToCircleColor);
186 | paint.setStyle(Paint.Style.STROKE);
187 | paint.setStrokeWidth(strokeWidth);
188 | drawRoundRect(width, height, canvas);
189 | break;
190 | case CIRCLE :
191 | paint.setColor(circleColor);
192 | paint.setStyle(Paint.Style.STROKE);
193 | paint.setStrokeWidth(strokeWidth);
194 | drawCircle(canvas);
195 | drawX(canvas);
196 | break;
197 | case CIRCLE_ROUND :
198 | paint.setColor(circleColor);
199 | paint.setStyle(Paint.Style.STROKE);
200 | paint.setStrokeWidth(strokeWidth);
201 |
202 | drawCircleRound(canvas);
203 | drawX(canvas);
204 | break;
205 | }
206 | }
207 |
208 | private void drawRoundRect(int width, int height, Canvas canvas) {
209 | RectF roundRect = getRoundRectF(width, height);
210 | canvas.drawRoundRect(roundRect, r, r, paint);
211 | }
212 |
213 | private void drawCircle(Canvas canvas) {
214 | canvas.drawCircle(x, y, r - strokeWidth, paint);
215 | }
216 |
217 | private void drawText(int width, int height, String recText, Canvas canvas) {
218 | RectF rectF = getRoundRectF(width, height);
219 | Paint.FontMetricsInt fontMetricsInt = paint.getFontMetricsInt();
220 | int baseLine = (int) ((rectF.bottom + rectF.top - fontMetricsInt.bottom - fontMetricsInt.top) / 2);
221 | canvas.drawText(recText, rectF.centerX(), baseLine, paint);
222 | }
223 |
224 | private void drawX(Canvas canvas) {
225 | Path path = new Path();
226 | int r = this.r / 3;
227 | path.moveTo(x - r, y + r);
228 | path.lineTo(x + r, y - r);
229 | path.moveTo(x - r, y - r);
230 | path.lineTo(x + r, y + r);
231 | canvas.drawPath(path, paint);
232 | }
233 |
234 | private void drawCircleRound(Canvas canvas) {
235 | int r = this.r - strokeWidth;
236 | Path path = new Path();
237 | path.moveTo(x - r, y - r);
238 | RectF oval = new RectF(x - r, y - r, x + r, y + r);
239 | path.arcTo(oval, startAngle, 345, true);
240 |
241 | canvas.drawPath(path, paint);
242 | }
243 |
244 | private RectF getRoundRectF(int width, int height) {
245 | return new RectF(REC_WIDTH - width + strokeWidth, strokeWidth, width
246 | - strokeWidth, height - strokeWidth);
247 | }
248 |
249 | private void setStatusToCircleRound() {
250 | // 一次view转换的终态
251 | status = CIRCLE_ROUND;
252 | isCircleRoundRun = true;
253 | executors.submit(circleRoundTask);
254 | }
255 |
256 | private void reset() {
257 | startAngle = 15;
258 | lock = false;
259 | isCircleRoundRun = false;
260 | }
261 |
262 | @Override
263 | public void onClick(View view) {
264 | if (CIRCLE_ROUND == status) {
265 | reset();
266 | status = CIRCLE;
267 | }
268 | if (!lock) {
269 | lock = true;
270 | rectToCirWidthChange();
271 | }
272 | }
273 |
274 | /**
275 | * 如果在加载过程由于网络问题,调用此方法重置View状态
276 | */
277 | public void resetButtonView() {
278 | if (CIRCLE_ROUND == status) {
279 | reset();
280 | status = CIRCLE;
281 | }
282 | if (!lock && status == CIRCLE) {
283 | lock = true;
284 | rectToCirWidthChange();
285 | }
286 | }
287 |
288 | public interface AnimationStatusListener {
289 | void startLoading(int status);
290 | void resetView(int status);
291 | }
292 |
293 | public void setAnimationRectButtonListener(AnimationStatusListener listener) {
294 | this.listener = listener;
295 | }
296 |
297 | private void handleResetView() {
298 | if (null != listener) {
299 | listener.resetView(status);
300 | }
301 | }
302 |
303 | private void handleStartLoading() {
304 | if (null != listener) {
305 | listener.startLoading(status);
306 | }
307 | }
308 |
309 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
310 | private void rectToCirWidthChange() {
311 | ValueAnimator valueAnimator = null;
312 | if (status == RECTANGLE) {
313 | status = REC_TO_CIRCLE;
314 | valueAnimator = ValueAnimator.ofInt(REC_WIDTH, LIMIT_VALUE);
315 | valueAnimator.addListener(new AnimatorListenerAdapter() {
316 | @Override
317 | public void onAnimationEnd(Animator animation) {
318 | super.onAnimationEnd(animation);
319 | status = CIRCLE;
320 | handleStartLoading();
321 | handleMessage();
322 | setStatusToCircleRound();
323 | }
324 | });
325 | } else if (status == CIRCLE) {
326 | status = CIRCLE_TO_REC;
327 | valueAnimator = ValueAnimator.ofInt(LIMIT_VALUE, REC_WIDTH);
328 | valueAnimator.addListener(new AnimatorListenerAdapter() {
329 | @Override
330 | public void onAnimationEnd(Animator animation) {
331 | super.onAnimationEnd(animation);
332 | status = RECTANGLE;
333 | handleResetView();
334 | handleMessage();
335 | }
336 | });
337 | }
338 |
339 | assert valueAnimator != null;
340 | valueAnimator
341 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
342 | @Override
343 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
344 | drawWidth = (int) valueAnimator.getAnimatedValue();
345 | handleMessage();
346 | }
347 |
348 | });
349 | valueAnimator.setDuration(recToCircleInterval);
350 | valueAnimator.start();
351 | }
352 |
353 | class CircleRoundThread implements Runnable {
354 |
355 | @Override
356 | public void run() {
357 | while (isCircleRoundRun) {
358 | sleep(rotateSpeed);
359 | handleMessage();
360 | }
361 | }
362 | }
363 |
364 | private static class MessageHandler extends Handler {
365 | private final WeakReference button;
366 |
367 | public MessageHandler(RectCircleProgressButton rectCircleProgressButton) {
368 | this.button = new WeakReference(
369 | rectCircleProgressButton);
370 | }
371 |
372 | @Override
373 | public void handleMessage(Message msg) {
374 | super.handleMessage(msg);
375 | RectCircleProgressButton button = this.button.get();
376 | if (button != null) {
377 | switch (msg.what) {
378 | case RECTANGLE :
379 | // 重置一下状态
380 | button.drawWidth = button.REC_WIDTH;
381 | button.reset();
382 | break;
383 | case REC_TO_CIRCLE :
384 | break;
385 | case CIRCLE_TO_REC :
386 | if (button.drawWidth > button.REC_WIDTH) {
387 | button.drawWidth = button.REC_WIDTH;
388 | }
389 | break;
390 | case CIRCLE :
391 | button.lock = false;
392 | break;
393 | case CIRCLE_ROUND :
394 | button.startAngle = button.startAngle + 10;
395 | break;
396 | }
397 | button.invalidate();
398 | }
399 | }
400 | }
401 |
402 | private void handleMessage() {
403 | Message message = new Message();
404 | message.what = status;
405 | handler.sendMessage(message);
406 | }
407 |
408 | private void sleep(long ms) {
409 | try {
410 | Thread.sleep(ms);
411 | } catch (InterruptedException e) {
412 | e.printStackTrace();
413 | }
414 | }
415 | }
416 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 15sp
4 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RectCircleProgressButton
3 | Download
4 |
5 |
--------------------------------------------------------------------------------
/RectCircleProgressButton/src/test/java/com/clownqiang/rectcircleprogressbutton/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.rectcircleprogressbutton;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/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 | mavenCentral()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.1.2'
10 |
11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | mavenCentral()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.clownqiang.sample"
9 | minSdkVersion 14
10 | targetSdkVersion 24
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:24.0.0'
26 | compile 'com.clownqiang:RectCircleProgressButton:1.0.1'
27 | }
28 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/clownqiang/Mac_Dev_Package/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/clownqiang/sample/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.sample;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/clownqiang/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.sample;
2 |
3 | import com.clownqiang.rectcircleprogressbutton.RectCircleProgressButton;
4 |
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.util.Log;
8 | import android.view.View;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | private static final String TAG = "MainActivity";
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | final RectCircleProgressButton button = (RectCircleProgressButton) findViewById(R.id.btn_rect_circle);
19 | button.setAnimationRectButtonListener(new RectCircleProgressButton.AnimationStatusListener() {
20 | @Override
21 | public void startLoading(int status) {
22 | Log.d(TAG, "startLoading..." + status);
23 | }
24 |
25 | @Override
26 | public void resetView(int status) {
27 | Log.d(TAG, "resetView..." + status);
28 | }
29 | });
30 |
31 | findViewById(R.id.btn_reset).setOnClickListener(
32 | new View.OnClickListener() {
33 | @Override
34 | public void onClick(View view) {
35 | button.resetButtonView();
36 | }
37 | });
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
29 |
30 |
37 |
38 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Sample
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/clownqiang/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.clownqiang.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/screenshot/android.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClownQiang/RectCircleProgressButton/d608a759e3042a137d3304a438933b5b7e6704c0/screenshot/android.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':RectCircleProgressButton', ':sample'
2 |
--------------------------------------------------------------------------------