├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── scopes
│ └── scope_settings.xml
└── vcs.xml
├── ImageFolder
└── 1.png
├── MyCircleProgress
└── MyCircleProgress.iml
├── MyCircleProgressBar.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── gxl
│ │ └── mycircleprogressbar
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── gxl
│ │ └── mycircleprogressbar
│ │ └── MainActivity.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── layout
│ └── activity_main.xml
│ ├── menu
│ └── menu_main.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── library.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── gxl
│ │ └── circleprogress
│ │ └── library
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── gxl
│ │ └── circleprogress
│ │ └── library
│ │ ├── util
│ │ ├── DrawThread.java
│ │ ├── TrackTool.java
│ │ └── UnitUtils.java
│ │ └── view
│ │ ├── MyCircleView.java
│ │ ├── MyProgressView.java
│ │ ├── MySurfaceView.java
│ │ ├── RiseNumberBase.java
│ │ └── RiseNumberTextView.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ ├── ic_launcher.png
│ └── ring1.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── color.xml
│ └── strings.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | MyCircleProgressBar
--------------------------------------------------------------------------------
/.idea/compiler.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 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 1.8
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ImageFolder/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/ImageFolder/1.png
--------------------------------------------------------------------------------
/MyCircleProgress/MyCircleProgress.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MyCircleProgressBar.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MyCircleProgressBar
2 | 自定义圆形进度条
3 | 
4 | 将项目作为第三方类库直接引用
5 | 在布局文件中添加如下代码(作为一般的控件用):
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
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 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
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 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.1"
6 |
7 | defaultConfig {
8 | applicationId "com.gxl.mycircleprogressbar"
9 | minSdkVersion 8
10 | targetSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
24 | compile 'com.android.support:appcompat-v7:21.0.2'
25 | compile project(':library')
26 | }
27 |
--------------------------------------------------------------------------------
/app/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 D:\Program Files (x86)\Android 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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/gxl/mycircleprogressbar/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.gxl.mycircleprogressbar;
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 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gxl/mycircleprogressbar/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.gxl.mycircleprogressbar;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.support.v7.app.ActionBarActivity;
6 | import android.view.View;
7 | import android.widget.Button;
8 |
9 | import com.gxl.circleprogress.library.view.MyProgressView;
10 |
11 |
12 | public class MainActivity extends ActionBarActivity {
13 | private MyProgressView mProgressView,mProgressView1,mProgressView2;
14 | private Button mButton;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 |
21 | mProgressView = (MyProgressView) findViewById(R.id.mProgressView);
22 | mProgressView.setmNumber(200);
23 | mProgressView.setmNumberColor(Color.GREEN);
24 | mProgressView.setmNumberSize(80);
25 | mProgressView.setmStrokeWidth(15);
26 | mProgressView1 = (MyProgressView) findViewById(R.id.mProgressView1);
27 | mProgressView1.setmNumber(250);
28 | mProgressView2 = (MyProgressView) findViewById(R.id.mProgressView2);
29 | mProgressView2.setmNumber(410);
30 | mProgressView2.setTextVisible(false);
31 | mButton = (Button) findViewById(R.id.btn);
32 | mButton.setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 | mProgressView.startAnim();
36 | mProgressView1.startAnim();
37 | mProgressView2.startAnim();
38 |
39 | }
40 | });
41 |
42 | }
43 |
44 |
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
17 |
23 |
24 |
31 |
32 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | MyCircleProgressBar
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.0.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/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/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
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.2.1-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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "21.1.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 8
9 | targetSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
23 | compile 'com.android.support:appcompat-v7:21.0.2'
24 | compile 'com.nineoldandroids:library:2.4.0'
25 | }
26 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
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 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
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 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/library/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 D:/Program Files (x86)/Android 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 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/gxl/circleprogress/library/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library;
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 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/util/DrawThread.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.util;
2 |
3 |
4 | import android.view.SurfaceView;
5 |
6 | import com.gxl.circleprogress.library.view.MySurfaceView;
7 |
8 |
9 | /**
10 | * @author Sodino E-mail:sodinoopen@hotmail.com
11 | * @version Time:2012-6-18 上午03:14:31
12 | */
13 | public class DrawThread extends Thread {
14 | private SurfaceView surfaceView;
15 | private boolean running;
16 |
17 | public DrawThread(SurfaceView surfaceView) {
18 | this.surfaceView = surfaceView;
19 | }
20 |
21 | @Override
22 | public void run() {
23 | if (surfaceView == null) {
24 | return;
25 | }
26 |
27 | if (surfaceView instanceof MySurfaceView) {
28 | //先让线程睡眠500毫秒 避免侧边栏效果和指针效果冲突
29 | try {
30 | sleep(500);
31 | } catch (InterruptedException e) {
32 | e.printStackTrace();
33 | }
34 |
35 | ((MySurfaceView) surfaceView).drawTrack();
36 | }
37 | }
38 |
39 | public void setRunning(boolean b) {
40 | running = b;
41 | }
42 |
43 | public boolean isRunning() {
44 | return running;
45 | }
46 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/util/TrackTool.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.util;
2 |
3 | public class TrackTool {
4 | private static final String TAG = "TrackTool";
5 | // 圆盘指针速率
6 | public static final int RUN_STEP = 3;
7 | private float centerX, cneterY, r;
8 | private int stopX;
9 | private int stopY;
10 | private int startX, startY;
11 |
12 | public int getStartX() {
13 | return startX;
14 | }
15 |
16 | public void setStartX(int startX) {
17 | this.startX = startX;
18 | }
19 |
20 | public int getStartY() {
21 | return startY;
22 | }
23 |
24 | public void setStartY(int startY) {
25 | this.startY = startY;
26 | }
27 |
28 | public float getCenterX() {
29 | return centerX;
30 | }
31 |
32 | public void setCenterX(float centerX) {
33 | this.centerX = centerX;
34 | }
35 |
36 | public float getR() {
37 | return r;
38 | }
39 |
40 | public void setR(float r) {
41 | this.r = r;
42 | }
43 |
44 | // private boolean isFirst = true;
45 | private boolean isChange = false;
46 |
47 | public boolean isChange() {
48 | return isChange;
49 | }
50 |
51 | public void setChange(boolean isChange) {
52 | this.isChange = isChange;
53 | }
54 |
55 | /*
56 | * public boolean isFirst() { return isFirst; }
57 | *
58 | * public void setFirst(boolean isFirst) { this.isFirst = isFirst; }
59 | */
60 |
61 | private boolean doing;
62 |
63 | public void start() {
64 | doing = true;
65 | }
66 |
67 | /* 圆心坐标 以及半径长度 */
68 | public void setParams(float centerX, float cneterY, float r, int stopX,
69 | int stopY) {
70 | this.centerX = centerX;
71 | this.cneterY = cneterY;
72 | this.r = r;
73 | this.stopX = stopX;
74 | this.stopY = stopY;
75 | int edge = (int) Math.sqrt(r * r / 2);
76 | this.x = (int) (centerX - edge);
77 | this.y = (int) (cneterY + edge);
78 | this.startX = this.x;
79 | this.startY = this.y;
80 | }
81 |
82 | /** 根据当前时间计算小球的X/Y坐标。 */
83 | public void compute() {
84 |
85 | float y2 = r * r - (centerX - x) * (centerX - x);
86 | if (y2 < 0) {
87 | y2 = 0;
88 | }
89 | if (isChange) {
90 | y = (int) (cneterY - Math.sqrt(y2));
91 | } else {
92 | y = (int) (cneterY + Math.sqrt(y2));
93 | }
94 |
95 | if (Math.abs(x - stopX) <= RUN_STEP
96 | && Math.abs(y - stopY) < 20) {
97 | doing = false;
98 | return;
99 | }
100 |
101 | }
102 |
103 | private int x, y;
104 |
105 | public void setY(int y) {
106 | this.y = y;
107 | }
108 |
109 | public int getX() {
110 | return x;
111 | }
112 |
113 | public int getY() {
114 | return y;
115 | }
116 |
117 | public void setX(int x) {
118 |
119 | if (x >= (centerX + r)) {
120 | isChange = false;
121 | this.x = x;
122 | } else if (x <= (centerX - r)) {
123 | isChange = true;
124 | this.x = x;
125 | } else {
126 | this.x = x;
127 | }
128 |
129 | }
130 |
131 | /** 反转Y轴正方向。适应手机的真实坐标系。 */
132 | public float getMirrorY(int parentHeight, int bitHeight) {
133 | int half = parentHeight >> 1;
134 | float tmp = half + (half - y);
135 | tmp -= bitHeight;
136 | return tmp;
137 | }
138 |
139 | public boolean doing() {
140 | return doing;
141 | }
142 |
143 | public void cancel() {
144 | doing = false;
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/util/UnitUtils.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.util;
2 |
3 | import android.content.Context;
4 |
5 | public class UnitUtils {
6 | /**
7 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
8 | */
9 | public static int dip2px(Context context, float dpValue) {
10 | final float scale = context.getResources().getDisplayMetrics().density;
11 | return (int) (dpValue * scale + 0.5f);
12 | }
13 |
14 | /**
15 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
16 | */
17 | public static int px2dip(Context context, float pxValue) {
18 | final float scale = context.getResources().getDisplayMetrics().density;
19 | return (int) (pxValue / scale + 0.5f);
20 | }
21 |
22 | /**
23 | * 将sp值转换为px值,保证文字大小不变
24 | *
25 | * @param spValue
26 | * @param fontScale
27 | * (DisplayMetrics类中属性scaledDensity)
28 | * @return
29 | */
30 | public static int sp2px(Context context, float spValue) {
31 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
32 | return (int) (spValue * fontScale + 0.5f);
33 | }
34 |
35 |
36 | /**
37 | * 将px值转换为sp值,保证文字大小不变
38 | *
39 | * @param pxValue
40 | * @param fontScale
41 | * (DisplayMetrics类中属性scaledDensity)
42 | * @return
43 | */
44 | public static int px2sp(Context context, float pxValue) {
45 | final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
46 | return (int) (pxValue / fontScale + 0.5f);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/view/MyCircleView.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.view;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Matrix;
8 | import android.graphics.Paint;
9 | import android.graphics.Paint.Style;
10 | import android.graphics.RectF;
11 | import android.graphics.Shader;
12 | import android.graphics.SweepGradient;
13 | import android.util.AttributeSet;
14 | import android.view.View;
15 |
16 | import com.gxl.circleprogress.library.R;
17 |
18 |
19 | public class MyCircleView extends View {
20 | private float mRadius;
21 | private float CenterX, CenterY;
22 | private float mWWidth;
23 | private int mStrokeWidthSmall;
24 |
25 | public int getmStrokeWidthSmall() {
26 | return mStrokeWidthSmall;
27 | }
28 |
29 | public void setmStrokeWidthSmall(int mStrokeWidthSmall) {
30 | this.mStrokeWidthSmall = mStrokeWidthSmall;
31 | }
32 |
33 | private int mStrokeWidthBig;
34 | private int mDistance;
35 | private int mEdge;
36 | private static final String TAG = "MyCircleView";
37 |
38 | public MyCircleView(Context context) {
39 | super(context);
40 | this.setWillNotDraw(false);// 必须
41 |
42 | }
43 |
44 | public MyCircleView(Context context, AttributeSet attrs, int defStyle) {
45 | super(context, attrs, defStyle);
46 | this.setWillNotDraw(false);// 必须
47 |
48 | }
49 |
50 | public MyCircleView(Context context, AttributeSet attrs) {
51 |
52 | super(context, attrs);
53 | this.setWillNotDraw(false);// 必须
54 | this.setBackgroundColor(Color.TRANSPARENT);
55 |
56 | }
57 |
58 | public void setCircleView(float centerX, float centerY, float radius,
59 | int Wwidth) {
60 | this.CenterX = centerX;
61 | this.CenterY = centerY;
62 | this.mRadius = radius;
63 | this.mWWidth = Wwidth;
64 |
65 | // 45度角交点
66 | mEdge = (int) Math.sqrt(mRadius * mRadius / 2);
67 | }
68 |
69 | @SuppressLint("DrawAllocation")
70 | @Override
71 | protected void onDraw(Canvas canvas) {
72 | super.onDraw(canvas);
73 | if (mWWidth > 0 && mWWidth <= 480) {
74 | if(mStrokeWidthSmall == 0)
75 | mStrokeWidthSmall = 4;
76 | mStrokeWidthBig = 2;
77 | mDistance = 10;
78 | } else if (mWWidth > 480 && mWWidth <= 720) {
79 | if(mStrokeWidthSmall == 0)
80 | mStrokeWidthSmall = 6;
81 | mStrokeWidthBig = 4;
82 | mDistance = 15;
83 | } else if (mWWidth > 720 && mWWidth <= 1080) {
84 | if(mStrokeWidthSmall == 0)
85 | mStrokeWidthSmall = 8;
86 | mStrokeWidthBig = 6;
87 | mDistance = 20;
88 | }
89 |
90 | Paint paint = new Paint();
91 | paint.setColor(Color.WHITE);
92 | paint.setDither(true);
93 | // Shader mShader = new RadialGradient(0, 0, radius, colors, positions,
94 | // tile);
95 | int color1 = Color.parseColor("#6eaf0a");
96 | int color2 = Color.parseColor("#f89023");
97 | int color3 = Color.parseColor("#df043e");
98 | int color4 = Color.parseColor("#9d136b");
99 | int color5 = Color.parseColor("#2c0946");
100 |
101 | // // 一个材质,打造出一个线性梯度沿著一条线。
102 | // 采用梯度渐变的效果
103 | Shader mShader = new SweepGradient(CenterX, CenterY - 5
104 | , new int[] {
105 | color1, color2, color3, color4, color5 }, null);
106 | Matrix matrix = new Matrix();
107 | matrix.setRotate(135, CenterX, CenterY);
108 | mShader.setLocalMatrix(matrix);
109 | paint.setStrokeCap(Paint.Cap.ROUND);//设置圆弧末端形状
110 | paint.setShader(mShader);
111 | paint.setStyle(Style.STROKE);
112 | paint.setStrokeWidth(mStrokeWidthSmall);
113 | paint.setAntiAlias(true);
114 | RectF oval = new RectF(CenterX - mRadius, CenterY - mRadius, CenterX
115 | + mRadius, CenterY + mRadius);
116 |
117 | //画小圆弧
118 | canvas.drawArc(oval, 135, 270, false, paint);
119 |
120 | // 圆心
121 | // canvas.drawCircle(CenterX, CenterY, 2, paint);
122 | paint.setColor(getResources().getColor(R.color.white2));
123 | paint.setStrokeWidth(mStrokeWidthBig);
124 | paint.setShader(null);
125 | // canvas.drawCircle(CenterX, CenterY, mRadius + 10, paint);
126 | oval.set(CenterX - mRadius - mStrokeWidthBig - mDistance, CenterY - mRadius
127 | - mStrokeWidthBig - mDistance, CenterX + mRadius + mStrokeWidthBig + mDistance,
128 | CenterY + mRadius + mStrokeWidthBig + mDistance);
129 | // 画大圆弧
130 | canvas.drawArc(oval, 135, 270, false, paint);
131 |
132 | drawPointAndText(CenterX, CenterY, mRadius, canvas);
133 |
134 | }
135 |
136 | private void drawPointAndText(float CenterX, float CenterY, float mRadius,
137 | Canvas canvas) {
138 | int textSize = 0;
139 | int sRadius = 0;
140 | if (mWWidth > 0 && mWWidth <= 480) {
141 | textSize = 15;
142 | sRadius = 4;
143 | } else if (mWWidth > 480 && mWWidth <= 720) {
144 | textSize = 20;
145 | sRadius = 6;
146 | } else if (mWWidth > 720 && mWWidth <= 1080) {
147 | textSize = 35;
148 | sRadius = 8;
149 | }
150 |
151 | Paint paint = new Paint();
152 | paint.setColor(getResources().getColor(R.color.white1));
153 | paint.setAntiAlias(true);
154 | paint.setTextSize(textSize);
155 | // 圆弧与X轴交点
156 | /*canvas.drawCircle(CenterX - mRadius - mStrokeWidthBig / 2, CenterY,
157 | sRadius, paint);*/
158 | canvas.drawText("50", CenterX - mRadius - mStrokeWidthBig - textSize
159 | * 2, CenterY + 10, paint);
160 | /*canvas.drawCircle(CenterX + mRadius + mStrokeWidthBig / 2, CenterY,
161 | sRadius, paint);*/
162 | canvas.drawText("300", CenterX + mRadius + mStrokeWidthBig + textSize,
163 | CenterY + 10, paint);
164 | // 圆弧与Y轴交点
165 | /*canvas.drawCircle(CenterX, CenterY - mRadius - mStrokeWidthBig / 2,
166 | sRadius, paint);*/
167 | canvas.drawText("150", CenterX - textSize, CenterY - mRadius
168 | - mStrokeWidthBig - textSize, paint);
169 | // canvas.drawCircle(CenterX, CenterY + mRadius + 10, 6, paint);
170 | // canvas.drawText("270度", CenterX - 20, CenterY + mRadius + 50, paint);
171 |
172 | // 左垂直X轴交点
173 | /*canvas.drawCircle(CenterX - mEdge - mStrokeWidthBig / 2, CenterY
174 | - mEdge - 10, sRadius, paint);*/
175 | canvas.drawText("100",
176 | CenterX - mEdge - mStrokeWidthBig - textSize * 2 - 10, CenterY
177 | - mEdge - 10, paint);
178 | /*canvas.drawCircle(CenterX - mEdge - mStrokeWidthBig / 2, CenterY
179 | + mEdge + 10, sRadius, paint);*/
180 | canvas.drawText("0", CenterX - mEdge - mStrokeWidthBig - textSize * 2,
181 | CenterY + mEdge + 20, paint);
182 | // 右垂直X轴交点
183 | /*canvas.drawCircle(CenterX + mEdge + mStrokeWidthBig / 2, CenterY
184 | - mEdge - 10, sRadius, paint);*/
185 | canvas.drawText("200", CenterX + mEdge + mStrokeWidthBig + textSize,
186 | CenterY - mEdge - 10, paint);
187 | /*canvas.drawCircle(CenterX + mEdge + mStrokeWidthBig / 2, CenterY
188 | + mEdge + 10, sRadius, paint);*/
189 | canvas.drawText("500", CenterX + mEdge + mStrokeWidthBig + textSize,
190 | CenterY + mEdge + 20, paint);
191 | }
192 |
193 | }
194 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/view/MyProgressView.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.view;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.graphics.Color;
8 | import android.util.AttributeSet;
9 | import android.util.Log;
10 | import android.view.Gravity;
11 | import android.view.View;
12 | import android.view.ViewTreeObserver;
13 | import android.widget.FrameLayout;
14 |
15 | import com.gxl.circleprogress.library.R;
16 | import com.gxl.circleprogress.library.util.UnitUtils;
17 |
18 | /**
19 | * Created by Administrator on 2015/1/15.
20 | */
21 | public class MyProgressView extends FrameLayout {
22 | private static final String TAG = "MyProgressView";
23 | private Context mContext;
24 | private MyCircleView mCircleView;
25 | private MySurfaceView mSurfaceView;
26 | private RiseNumberTextView mRiseNumberTextView;
27 | //MyProgressView 本身的宽度和高度
28 | private int mFrameLayoutWidth,mFrameLayoutHeight;
29 |
30 | public boolean isTextVisible() {
31 | return isTextVisible;
32 | }
33 |
34 | public void setTextVisible(boolean isTextVisible) {
35 | this.isTextVisible = isTextVisible;
36 | }
37 |
38 | private boolean isTextVisible = true;
39 |
40 |
41 | public int getmStrokeWidth() {
42 | return mStrokeWidth;
43 | }
44 |
45 | public void setmStrokeWidth(int mStrokeWidth) {
46 | this.mStrokeWidth = UnitUtils.px2dip(mContext, mStrokeWidth);
47 | }
48 |
49 | //设置圆弧描边的大小
50 | private int mStrokeWidth;
51 |
52 | // 屏幕分辨率
53 | private int mWWidth;
54 |
55 | public int getmNumber() {
56 | return mNumber;
57 | }
58 |
59 | public void setmNumber(int mNumber) {
60 | this.mNumber = mNumber;
61 | }
62 |
63 | //设定的进度
64 | private int mNumber;
65 |
66 | public int getmNumberSize() {
67 | return mNumberSize;
68 | }
69 |
70 | public void setmNumberSize(int mNumberSize) {
71 | this.mNumberSize = mNumberSize;
72 | }
73 | //设置数字大小
74 | private int mNumberSize;
75 |
76 | public int getmNumberColor() {
77 | return mNumberColor;
78 | }
79 |
80 | public void setmNumberColor(int mNumberColor) {
81 | this.mNumberColor = mNumberColor;
82 | }
83 |
84 | //设置数字颜色
85 | private int mNumberColor;
86 | //根据进度换算圆弧的角度
87 | private int mAngle;
88 | //根据进度换算圆弧的弧度
89 | private int mRadian;
90 | // 指针停留X坐标
91 | private int stopX;
92 | // 指针停留Y坐标
93 | private int stopY;
94 |
95 | public Bitmap getmPointer() {
96 | return mPointer;
97 | }
98 |
99 | public void setmPointer(Bitmap mPointer) {
100 | this.mPointer = mPointer;
101 | }
102 |
103 | private Bitmap mPointer;
104 |
105 | public MyProgressView(Context context) {
106 | super(context);
107 | }
108 |
109 | public MyProgressView(final Context context, AttributeSet attrs) {
110 | super(context, attrs);
111 | mContext = context;
112 | // this.setBackgroundColor(Color.TRANSPARENT);
113 | // 获取屏幕宽度
114 | mWWidth = ((Activity)context).getWindowManager().getDefaultDisplay().getWidth();
115 | mRiseNumberTextView = new RiseNumberTextView(context,attrs);
116 | mRiseNumberTextView.setGravity(Gravity.CENTER);
117 | mCircleView = new MyCircleView(context,attrs);
118 | mSurfaceView = new MySurfaceView(context,attrs);
119 |
120 | addView(mRiseNumberTextView);
121 | addView(mCircleView);
122 | addView(mSurfaceView);
123 | Log.v(TAG,"==========>MyProgressView");
124 |
125 | // 界面开始绘制之前调用 直接获取宽度和高度则为0 因为控件还没有开始进行绘制
126 | ViewTreeObserver vto = getViewTreeObserver();
127 | vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
128 |
129 | @Override
130 | public void onGlobalLayout() {
131 | getViewTreeObserver()
132 | .removeGlobalOnLayoutListener(this);
133 | mFrameLayoutWidth = getWidth();
134 | mFrameLayoutHeight = mFrameLayoutWidth;
135 | initCircleView();
136 | if(isTextVisible){
137 | mRiseNumberTextView.setVisibility(View.VISIBLE);
138 | if(mNumberSize == 0)
139 | mNumberSize = 60;
140 |
141 | mRiseNumberTextView.setTextSize(UnitUtils.px2sp(context,mNumberSize));
142 | if(mNumberColor == 0)
143 | mNumberColor = Color.BLUE;
144 |
145 | mRiseNumberTextView.setTextColor(mNumberColor);
146 | mRiseNumberTextView.withNumber(mNumber).start();
147 | mRiseNumberTextView.setOnEnd(new RiseNumberTextView.EndListener() {
148 | @Override
149 | public void onEndFinish() {
150 | mRiseNumberTextView.setText("" + mNumber);
151 | }
152 | });
153 | }else {
154 | mRiseNumberTextView.setVisibility(View.INVISIBLE);
155 | }
156 |
157 | }
158 | });
159 |
160 |
161 |
162 | }
163 |
164 |
165 | @Override
166 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
167 | //设定FrameLayout的高度为相对宽度的值
168 | super.onMeasure(widthMeasureSpec, widthMeasureSpec - 80);
169 | }
170 |
171 | // 初始化中间圆环
172 | public void initCircleView() {
173 | int centerX = mFrameLayoutWidth / 2;
174 | int centerY = mFrameLayoutHeight / 2;
175 | //圆弧半径
176 | int Radius = 0;
177 | if(mWWidth >0 && mWWidth <= 350){
178 | Radius = centerY - 35;
179 | centerY = centerY - 10;
180 | }else if (mWWidth > 350 && mWWidth <= 650) {
181 | Radius = centerY - 65;
182 | centerY = centerY - 20;
183 | } else if (mWWidth > 650 && mWWidth <= 830) {
184 | Radius = centerY - 80;
185 | centerY = centerY - 20;
186 | } else if (mWWidth > 830 && mWWidth <= 1080) {
187 | Radius = centerY - 125;
188 | centerY = centerY - 25;
189 | }
190 |
191 | /* 等分的情况下的角度计算公式
192 | * mRadian = 27 * mNumber / 50;
193 | * 0-200pm25之间的角度计算公式
194 | * mRadian = 9 * mNumber / 10;
195 | * 200-300pm25之间的角度计算公式
196 | * mRadian = 9 * mNumber / 20;
197 | * //300-500Pm25之间的角度计算公式
198 | * mRadian = 9 * mNumber / 40;
199 | */
200 |
201 | if (mNumber >= 0 && mNumber <= 200) {
202 | mRadian = 9 * mNumber / 10; // 0-200pm25之间的角度计算公式
203 | if (mRadian >= 0 && mRadian <= 45) {
204 | mAngle = 45 - mRadian;
205 | stopX = (int) (centerX - Math.cos(Math.toRadians(mAngle))
206 | * Radius);
207 | stopY = (int) (centerY + Math.sin(Math.toRadians(mAngle))
208 | * Radius);
209 |
210 | } else if (mRadian > 45 && mRadian <= 135) {
211 | mAngle = mRadian - 45;
212 | stopX = (int) (centerX - Math.cos(Math.toRadians(mAngle))
213 | * Radius);
214 | stopY = (int) (centerY - Math.sin(Math.toRadians(mAngle))
215 | * Radius);
216 |
217 | } else if (mRadian > 135 && mRadian <= 225) {
218 | mAngle = 225 - mRadian;
219 | stopX = (int) (centerX + Math.cos(Math.toRadians(mAngle))
220 | * Radius);
221 | stopY = (int) (centerY - Math.sin(Math.toRadians(mAngle))
222 | * Radius);
223 |
224 | }
225 | } else if (mNumber > 200 && mNumber <= 300) {
226 | mRadian = 9 * (mNumber - 200) / 20;
227 | mAngle = 45 - mRadian;
228 | stopX = (int) (centerX + Math.cos(Math.toRadians(mAngle)) * Radius);
229 | stopY = (int) (centerY - Math.sin(Math.toRadians(mAngle)) * Radius);
230 |
231 | } else if (mNumber > 300 && mNumber <= 500) {
232 | mRadian = 9 * (mNumber - 300) / 40;
233 | mAngle = mRadian;
234 | stopX = (int) (centerX + Math.cos(Math.toRadians(mAngle)) * Radius);
235 | stopY = (int) (centerY + Math.sin(Math.toRadians(mAngle)) * Radius);
236 | } else if (mNumber > 500) {
237 | mRadian = 9 * (500 - 300) / 40;
238 | mAngle = mRadian;
239 | stopX = (int) (centerX + Math.cos(Math.toRadians(mAngle)) * Radius);
240 | stopY = (int) (centerY + Math.sin(Math.toRadians(mAngle)) * Radius);
241 |
242 | }
243 |
244 | mCircleView.setCircleView(centerX, centerY, Radius, mWWidth);
245 | mCircleView.setmStrokeWidthSmall(mStrokeWidth);
246 | mSurfaceView.setParms(centerX, centerY, Radius, stopX, stopY);
247 | if(mPointer == null){
248 | mSurfaceView.setIcon(BitmapFactory.decodeResource(getResources(),
249 | R.drawable.ring1));
250 | }else {
251 | mSurfaceView.setIcon(mPointer);
252 | }
253 |
254 | mSurfaceView.showMovie();
255 | }
256 |
257 | public void startAnim(){
258 | mSurfaceView.showMovie();
259 | mRiseNumberTextView.withNumber(mNumber).start();
260 | }
261 |
262 |
263 | }
264 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/view/MySurfaceView.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.view;
2 |
3 |
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.Color;
8 | import android.graphics.Paint;
9 | import android.graphics.PixelFormat;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.SurfaceHolder;
13 | import android.view.SurfaceView;
14 | import com.gxl.circleprogress.library.util.DrawThread;
15 | import com.gxl.circleprogress.library.util.TrackTool;
16 |
17 |
18 | public class MySurfaceView extends SurfaceView implements
19 | SurfaceHolder.Callback {
20 |
21 | private static final String TAG = "MySurfaceView";
22 | /** 每30ms刷一帧。 */
23 | private static final long SLEEP_DURATION = 1;
24 | /** 动画图标。 */
25 | private Bitmap bitmap;
26 |
27 | // SurfaceView句柄 用来控制SurfaceView
28 | private SurfaceHolder mSurfaceHolder;
29 | private TrackTool mTrackTool;
30 | private DrawThread thread;
31 |
32 | /** 默认未创建,相当于Destory。 */
33 | private boolean surfaceDestoryed = true;
34 |
35 | public MySurfaceView(Context context) {
36 | super(context);
37 | Log.v(TAG, "MySurfaceView1");
38 | this.setWillNotDraw(false);// 必须
39 | init();
40 | }
41 |
42 | public MySurfaceView(Context context, AttributeSet attrs, int defStyle) {
43 | super(context, attrs, defStyle);
44 | Log.v(TAG, "MySurfaceView2");
45 | this.setWillNotDraw(false);// 必须
46 | init();
47 | }
48 |
49 | public MySurfaceView(Context context, AttributeSet attrs) {
50 | super(context, attrs);
51 | Log.v(TAG, "MySurfaceView3");
52 | this.setWillNotDraw(false);// 必须
53 | this.setBackgroundColor(Color.TRANSPARENT);
54 | init();
55 |
56 | }
57 |
58 | private void init() {
59 | Log.v(TAG, "init==================>");
60 | mSurfaceHolder = getHolder();
61 | mSurfaceHolder.addCallback(this);
62 | // 设置surfaceView背景透明
63 | mSurfaceHolder.setFormat(PixelFormat.TRANSPARENT);
64 | setZOrderOnTop(true);
65 | mTrackTool = new TrackTool();
66 | }
67 |
68 | @Override
69 | public void surfaceCreated(SurfaceHolder holder) {
70 | Log.v(TAG, "-----------------surfaceCreated------------");
71 | surfaceDestoryed = false;
72 | // 当返回首页的时候调用
73 | /*
74 | * mTrackTool.setChange(false); mTrackTool.setX(mTrackTool.getStartX());
75 | * mTrackTool.setY(mTrackTool.getStartY());
76 | */
77 | showMovie();
78 | // drawCircle(holder);
79 | }
80 |
81 | @Override
82 | public void surfaceChanged(SurfaceHolder holder, int format, int width,
83 | int height) {
84 |
85 | Log.v(TAG, "-----------------surfaceChanged------------");
86 |
87 | }
88 |
89 | @Override
90 | public void surfaceDestroyed(SurfaceHolder holder) {
91 | Log.v(TAG, "-----------------surfaceDestroyed------------");
92 | surfaceDestoryed = true;
93 | }
94 |
95 |
96 | public void drawTrack() {
97 | Canvas canvas = null;
98 | Paint pTmp = new Paint();
99 | pTmp.setAntiAlias(true);
100 | pTmp.setColor(Color.RED);
101 | Paint paint = new Paint();
102 | // 设置抗锯齿
103 | paint.setAntiAlias(true);
104 | paint.setColor(Color.CYAN);
105 | mTrackTool.start();
106 | while (mTrackTool.doing()) {
107 | try {
108 |
109 | // 先计算测量
110 | mTrackTool.compute();
111 |
112 | // 绘上新图区域
113 | int x = mTrackTool.getX();
114 | // float y = (float) physicalTool.getY();
115 | int y = mTrackTool.getY();
116 |
117 | canvas = mSurfaceHolder.lockCanvas();
118 | // 设置画布的背景为透明。
119 | canvas.drawColor(Color.TRANSPARENT,
120 | android.graphics.PorterDuff.Mode.CLEAR);
121 |
122 | canvas.drawRect(x, y, x, y, pTmp);
123 | canvas.drawBitmap(bitmap, x - bitmap.getWidth() / 2,
124 | y - bitmap.getHeight() / 2, paint);
125 | mSurfaceHolder.unlockCanvasAndPost(canvas);
126 | // Thread.sleep(SLEEP_DURATION);
127 |
128 | if (mTrackTool.isChange()) {
129 | mTrackTool.setX(x + TrackTool.RUN_STEP);
130 | } else {
131 | mTrackTool.setX(x - TrackTool.RUN_STEP);
132 | }
133 |
134 | } catch (Exception e) {
135 | e.printStackTrace();
136 | }
137 | }
138 | // 清除屏幕内容
139 | // 直接按"Home"回桌面,SurfaceView被销毁了,lockCanvas返回为null。
140 | if (surfaceDestoryed == true && canvas != null) {
141 | canvas = mSurfaceHolder.lockCanvas();
142 | canvas.drawColor(Color.TRANSPARENT,
143 | android.graphics.PorterDuff.Mode.CLEAR);
144 | mSurfaceHolder.unlockCanvasAndPost(canvas);
145 | }
146 |
147 | // thread.setRunning(false);
148 |
149 | }
150 |
151 | public void setIcon(Bitmap bit) {
152 | bitmap = bit;
153 | }
154 |
155 | public void setParms(float CenterX, float CenterY, float r, int stopX,
156 | int stopY) {
157 | mTrackTool.setParams(CenterX, CenterY, r, stopX, stopY);
158 | }
159 |
160 | public void showMovie() {
161 | mTrackTool.setChange(false);
162 | mTrackTool.setX(mTrackTool.getStartX());
163 | mTrackTool.setY(mTrackTool.getStartY());
164 | if (thread == null) {
165 | thread = new DrawThread(this);
166 | } else if (thread.getState() == Thread.State.TERMINATED) {
167 | thread.setRunning(false);
168 | thread = new DrawThread(this);
169 | }
170 | if (thread.getState() == Thread.State.NEW) {
171 | thread.start();
172 | }
173 | }
174 |
175 | }
176 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/view/RiseNumberBase.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.view;
2 |
3 | /**
4 | * Created by lee on 2014/7/29.
5 | */
6 | public interface RiseNumberBase {
7 | public void start();
8 | public RiseNumberTextView withNumber(float number);
9 | public RiseNumberTextView withNumber(double number);
10 | public RiseNumberTextView withNumber(int number);
11 | public RiseNumberTextView setDuration(long duration);
12 | public void setOnEnd(RiseNumberTextView.EndListener callback);
13 | }
14 |
--------------------------------------------------------------------------------
/library/src/main/java/com/gxl/circleprogress/library/view/RiseNumberTextView.java:
--------------------------------------------------------------------------------
1 | package com.gxl.circleprogress.library.view;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.util.AttributeSet;
6 | import android.widget.TextView;
7 |
8 | import java.text.DecimalFormat;
9 |
10 | /**
11 | * Created by lee on 2014/7/29.
12 | */
13 | public class RiseNumberTextView extends TextView implements RiseNumberBase {
14 |
15 | private static final int STOPPED = 0;
16 |
17 | private static final int RUNNING = 1;
18 |
19 | private int mPlayingState = STOPPED;
20 |
21 | private double number;
22 |
23 | private double fromNumber;
24 |
25 | private long duration = 1500;
26 | /**
27 | * 1.int 2.float
28 | */
29 | private int numberType = 2;
30 |
31 | private DecimalFormat fnum;
32 |
33 | private EndListener mEndListener = null;
34 |
35 | final static int[] sizeTable = { 9, 99, 999, 9999, 99999, 999999, 9999999,
36 | 99999999, 999999999, Integer.MAX_VALUE };
37 |
38 | public RiseNumberTextView(Context context) {
39 | super(context);
40 | }
41 |
42 | public RiseNumberTextView(Context context, AttributeSet attr) {
43 | super(context, attr);
44 | }
45 |
46 | public RiseNumberTextView(Context context, AttributeSet attr, int defStyle) {
47 | super(context, attr, defStyle);
48 | }
49 |
50 | public interface EndListener {
51 | public void onEndFinish();
52 | }
53 |
54 | public boolean isRunning() {
55 | return (mPlayingState == RUNNING);
56 | }
57 |
58 |
59 | private void runDouble() {
60 | ValueAnimator valueAnimator = ValueAnimator.ofFloat((float)fromNumber, (float)number);
61 | valueAnimator.setDuration(duration);
62 |
63 | valueAnimator
64 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
65 | @Override
66 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
67 |
68 | setText(fnum.format(Double.parseDouble(valueAnimator
69 | .getAnimatedValue().toString())));
70 | if (valueAnimator.getAnimatedFraction() >= 1) {
71 | mPlayingState = STOPPED;
72 | if (mEndListener != null)
73 | mEndListener.onEndFinish();
74 | }
75 | }
76 |
77 | });
78 | valueAnimator.start();
79 | }
80 |
81 |
82 | private void runFloat() {
83 | ValueAnimator valueAnimator = ValueAnimator.ofFloat((float)fromNumber, (float)number);
84 | valueAnimator.setDuration(duration);
85 |
86 | valueAnimator
87 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
88 | @Override
89 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
90 |
91 | setText(fnum.format(Float.parseFloat(valueAnimator
92 | .getAnimatedValue().toString())));
93 | if (valueAnimator.getAnimatedFraction() >= 1) {
94 | mPlayingState = STOPPED;
95 | if (mEndListener != null)
96 | mEndListener.onEndFinish();
97 | }
98 | }
99 |
100 | });
101 | valueAnimator.start();
102 | }
103 |
104 | private void runInt() {
105 | ValueAnimator valueAnimator = ValueAnimator.ofInt((int) fromNumber,
106 | (int) number);
107 | valueAnimator.setDuration(duration);
108 |
109 | valueAnimator
110 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
111 | @Override
112 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
113 |
114 | setText(valueAnimator.getAnimatedValue().toString());
115 | if (valueAnimator.getAnimatedFraction() >= 1) {
116 | mPlayingState = STOPPED;
117 | if (mEndListener != null)
118 | mEndListener.onEndFinish();
119 | }
120 | }
121 | });
122 | valueAnimator.start();
123 | }
124 |
125 | static int sizeOfInt(int x) {
126 | for (int i = 0;; i++)
127 | if (x <= sizeTable[i])
128 | return i + 1;
129 | }
130 |
131 | @Override
132 | protected void onFinishInflate() {
133 | super.onFinishInflate();
134 | fnum = new DecimalFormat("##0.00");
135 | }
136 |
137 | @Override
138 | public void start() {
139 |
140 | if (!isRunning()) {
141 | mPlayingState = RUNNING;
142 | if (numberType == 1){
143 | runInt();
144 | }
145 | else if (numberType == 2) {
146 | runFloat();
147 | }else if (numberType == 3) {
148 | runDouble();
149 | }
150 | }
151 | }
152 |
153 | @Override
154 | public RiseNumberTextView withNumber(float number) {
155 |
156 | this.number = number;
157 | numberType = 2;
158 | if (number > 1000) {
159 | fromNumber = number- (double) Math.pow(10, sizeOfInt((int) number) - 2);
160 | } else {
161 | fromNumber = number / 2;
162 | }
163 |
164 | return this;
165 | }
166 |
167 | @Override
168 | public RiseNumberTextView withNumber(double number) {
169 |
170 | this.number = number;
171 | numberType = 3;
172 | if (number > 1000) {
173 | fromNumber = number - (double) Math.pow(10, sizeOfInt((int) number) - 2);
174 | } else {
175 | fromNumber = number / 2;
176 | }
177 |
178 | return this;
179 | }
180 |
181 | @Override
182 | public RiseNumberTextView withNumber(int number) {
183 | this.number = number;
184 | numberType = 1;
185 | if (number > 1000) {
186 | fromNumber = number - (double) Math.pow(10, sizeOfInt((int) number) - 2);
187 | } else {
188 | fromNumber = number / 2;
189 | }
190 |
191 | return this;
192 |
193 | }
194 |
195 | @Override
196 | public RiseNumberTextView setDuration(long duration) {
197 | this.duration = duration;
198 | return this;
199 | }
200 |
201 | @Override
202 | public void setOnEnd(EndListener callback) {
203 | mEndListener = callback;
204 | }
205 |
206 | }
207 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/library/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/library/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/library/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xhdpi/ring1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/library/src/main/res/drawable-xhdpi/ring1.png
--------------------------------------------------------------------------------
/library/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jtsky/MyCircleProgressBar/0887fb6a8c79840e4ab54a6477009024cf39be25/library/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ffffffff
4 | #99FFFFFF
5 | #5FFFFFFF
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------