├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── quanqi │ │ └── circularporgress │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── quanqi │ │ └── circularporgress │ │ └── 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 │ ├── demo.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── deploy.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── quanqi │ │ └── circularprogress │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── org │ │ └── quanqi │ │ └── circularprogress │ │ ├── CircularProgressDrawable.java │ │ └── CircularProgressView.java │ └── res │ └── values │ ├── circular_progress.xml │ └── strings.xml ├── settings.gradle └── shots └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Intellij project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | 31 | .directory 32 | 33 | # gradle wrapper working directory 34 | .gradle 35 | 36 | build/ 37 | 38 | # maven 39 | target/ 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A circular progressbar with sweeping angle 2 | ![demo](shots/demo.gif) 3 | 4 | ## usage 5 | 6 | In build.gradle config dependency. 7 | 8 | ``` groovy 9 | compile 'org.quanqi:CircularProgress:1.0.2' 10 | ``` 11 | 12 | In laout xml 13 | 14 | ``` xml 15 | 23 | ``` 24 | 25 | ## LICENSE 26 | bsd-2 27 | 28 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /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 "org.quanqi.circularporgress" 9 | minSdkVersion 14 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(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:21.0.3' 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 /Users/cindy/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/org/quanqi/circularporgress/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.quanqi.circularporgress; 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/org/quanqi/circularporgress/MainActivity.java: -------------------------------------------------------------------------------- 1 | package org.quanqi.circularporgress; 2 | 3 | import android.support.v7.app.ActionBarActivity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.widget.TextView; 8 | 9 | 10 | public class MainActivity extends ActionBarActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | } 17 | 18 | 19 | @Override 20 | public boolean onCreateOptionsMenu(Menu menu) { 21 | // Inflate the menu; this adds items to the action bar if it is present. 22 | getMenuInflater().inflate(R.menu.menu_main, menu); 23 | return true; 24 | } 25 | 26 | @Override 27 | public boolean onOptionsItemSelected(MenuItem item) { 28 | // Handle action bar item clicks here. The action bar will 29 | // automatically handle clicks on the Home/Up button, so long 30 | // as you specify a parent activity in AndroidManifest.xml. 31 | int id = item.getItemId(); 32 | 33 | //noinspection SimplifiableIfStatement 34 | if (id == R.id.action_settings) { 35 | return true; 36 | } 37 | 38 | return super.onOptionsItemSelected(item); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 26 | 27 | 32 | 33 | 39 | 40 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #ff0000 5 | #00ff00 6 | #0000ff 7 | 8 | -------------------------------------------------------------------------------- /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 | CircularPorgress 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 | -------------------------------------------------------------------------------- /deploy.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Chris Banes 3 | * Copyright 2014 Jing Quanqi 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | apply plugin:'maven' 19 | apply plugin:'signing' 20 | 21 | def isReleaseBuild() { 22 | return VERSION_NAME.contains("SNAPSHOT") == false 23 | } 24 | 25 | def getReleaseRepositoryUrl() { 26 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL 27 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 28 | } 29 | 30 | def getSnapshotRepositoryUrl() { 31 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL 32 | : "https://oss.sonatype.org/content/repositories/snapshots/" 33 | } 34 | 35 | def getRepositoryUsername() { 36 | return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" 37 | } 38 | 39 | def getRepositoryPassword() { 40 | return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" 41 | } 42 | 43 | 44 | afterEvaluate { project -> 45 | uploadArchives { 46 | repositories { 47 | mavenDeployer { 48 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 49 | 50 | pom.groupId = GROUP 51 | pom.artifactId = POM_ARTIFACT_ID 52 | pom.version = VERSION_NAME 53 | 54 | repository(url: getReleaseRepositoryUrl()) { 55 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 56 | } 57 | snapshotRepository(url: getSnapshotRepositoryUrl()) { 58 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 59 | } 60 | 61 | pom.project { 62 | name = POM_NAME 63 | packaging = POM_PACKAGING 64 | description = POM_DESCRIPTION 65 | url = POM_URL 66 | 67 | scm { 68 | url = project.hasProperty('POM_SCM_URL') ? POM_SCM_URL : "" 69 | connection = project.hasProperty('POM_SCM_CONNECTION') ? POM_SCM_CONNECTION : "" 70 | developerConnection = project.hasProperty('POM_SCM_DEV_CONNECTION') ? POM_SCM_DEV_CONNECTION : "" 71 | } 72 | 73 | licenses { 74 | license { 75 | name = POM_LICENCE_NAME 76 | url = POM_LICENCE_URL 77 | distribution = POM_LICENCE_DIST 78 | } 79 | } 80 | 81 | developers { 82 | developer { 83 | id = POM_DEVELOPER_ID 84 | name = POM_DEVELOPER_NAME 85 | } 86 | } 87 | } 88 | } 89 | } 90 | } 91 | 92 | signing { 93 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") && hasProperty('signing.keyId') } 94 | sign configurations.archives 95 | } 96 | 97 | task androidJavadocs(type: Javadoc) { 98 | failOnError false 99 | source = android.sourceSets.main.java.sourceFiles 100 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 101 | } 102 | 103 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { 104 | classifier = 'javadoc' 105 | from androidJavadocs.destinationDir 106 | } 107 | 108 | task androidSourcesJar(type: Jar) { 109 | classifier = 'sources' 110 | from android.sourceSets.main.java.sourceFiles 111 | } 112 | 113 | artifacts { 114 | archives androidSourcesJar 115 | archives androidJavadocsJar 116 | } 117 | } 118 | 119 | -------------------------------------------------------------------------------- /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/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/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 | apply from: file('../deploy.gradle') 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 21 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | resourcePrefix 'circular_' 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile 'com.android.support:support-annotations:21.0.3' 25 | } 26 | 27 | task test << { 28 | 29 | if (project.hasProperty("POM_LICENCE_NAME")) { 30 | println "project has pom" 31 | } else { 32 | println "project has no pom" 33 | } 34 | 35 | if (hasProperty("POM_LICENCE_NAME")) { 36 | println "has pom" 37 | } else { 38 | println "has no pom" 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=1.0.2 2 | VERSION_CODE=2 3 | GROUP=org.quanqi 4 | 5 | POM_DESCRIPTION=A circular progressbar with sweeping angle for android. 6 | POM_URL=https://github.com/dodocat/CircularProgress 7 | POM_SCM_URL=https://github.com/dodocat/CircularProgress.git 8 | POM_SCM_CONNECTION=scm:git@github.com:dodocat/CircularProgress.git 9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:dodocat/CircularProgress.git 10 | POM_LICENCE_NAME=The BSD 2-Clause License 11 | POM_LICENCE_URL=http://opensource.org/licenses/bsd-license.html 12 | POM_LICENCE_DIST=repo 13 | POM_DEVELOPER_ID=dodocat 14 | POM_DEVELOPER_NAME=Jing Quanqi 15 | 16 | POM_NAME=Android circular progress 17 | POM_ARTIFACT_ID=CircularProgress 18 | POM_PACKAGING=aar 19 | -------------------------------------------------------------------------------- /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 /Users/cindy/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/org/quanqi/circularprogress/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.quanqi.circularprogress; 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 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /library/src/main/java/org/quanqi/circularprogress/CircularProgressDrawable.java: -------------------------------------------------------------------------------- 1 | package org.quanqi.circularprogress; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.graphics.Canvas; 7 | import android.graphics.ColorFilter; 8 | import android.graphics.Paint; 9 | import android.graphics.PixelFormat; 10 | import android.graphics.Rect; 11 | import android.graphics.RectF; 12 | import android.graphics.drawable.Animatable; 13 | import android.graphics.drawable.Drawable; 14 | import android.util.Property; 15 | import android.view.animation.DecelerateInterpolator; 16 | import android.view.animation.Interpolator; 17 | import android.view.animation.LinearInterpolator; 18 | 19 | 20 | /** 21 | * By cindy on 12/22/14 3:55 PM. 22 | */ 23 | public class CircularProgressDrawable extends Drawable implements Animatable { 24 | 25 | private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator(); 26 | 27 | private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator(); 28 | 29 | private int angleAnimatorDuration = 2000; 30 | 31 | private int sweepAnimatorDuration = 600; 32 | 33 | private int minSweepAngle = 30; 34 | 35 | private final RectF fBounds = new RectF(); 36 | 37 | private ObjectAnimator mObjectAnimatorSweep; 38 | 39 | private ObjectAnimator mObjectAnimatorAngle; 40 | 41 | private boolean mModeAppearing; 42 | private Paint mPaint; 43 | 44 | private float mCurrentGlobalAngleOffset; 45 | 46 | private float mCurrentGlobalAngle; 47 | 48 | private float mCurrentSweepAngle; 49 | 50 | private float mBorderWidth; 51 | 52 | private boolean mRunning; 53 | 54 | public CircularProgressDrawable(int color, float borderWidth) { 55 | mBorderWidth = borderWidth; 56 | 57 | mPaint = new Paint(); 58 | mPaint.setAntiAlias(true); 59 | mPaint.setStyle(Paint.Style.STROKE); 60 | mPaint.setStrokeWidth(borderWidth); 61 | mPaint.setColor(color); 62 | 63 | setupAnimations(); 64 | } 65 | 66 | @Override 67 | public void draw(Canvas canvas) { 68 | float startAngle = mCurrentGlobalAngle - mCurrentGlobalAngleOffset; 69 | float sweepAngle = mCurrentSweepAngle; 70 | if (mModeAppearing) { 71 | sweepAngle += minSweepAngle; 72 | } else { 73 | startAngle = startAngle + sweepAngle; 74 | sweepAngle = 360 - sweepAngle - minSweepAngle; 75 | } 76 | canvas.drawArc(fBounds, startAngle, sweepAngle, false, mPaint); 77 | } 78 | 79 | @Override 80 | public void setAlpha(int alpha) { 81 | mPaint.setAlpha(alpha); 82 | } 83 | 84 | @Override 85 | public void setColorFilter(ColorFilter cf) { 86 | mPaint.setColorFilter(cf); 87 | } 88 | 89 | @Override 90 | public int getOpacity() { 91 | return PixelFormat.TRANSPARENT; 92 | } 93 | 94 | private void toggleAppearingMode() { 95 | mModeAppearing = !mModeAppearing; 96 | if (mModeAppearing) { 97 | mCurrentGlobalAngleOffset = (mCurrentGlobalAngleOffset + minSweepAngle * 2) % 360; 98 | } 99 | } 100 | 101 | @Override 102 | protected void onBoundsChange(Rect bounds) { 103 | super.onBoundsChange(bounds); 104 | fBounds.left = bounds.left + mBorderWidth / 2f + .5f; 105 | fBounds.right = bounds.right - mBorderWidth / 2f - .5f; 106 | fBounds.top = bounds.top + mBorderWidth / 2f + .5f; 107 | fBounds.bottom = bounds.bottom - mBorderWidth / 2f - .5f; 108 | } 109 | 110 | 111 | private Property mAngleProperty = 112 | new Property(Float.class, "angle") { 113 | @Override 114 | public Float get(CircularProgressDrawable object) { 115 | return object.getCurrentGlobalAngle(); 116 | } 117 | 118 | @Override 119 | public void set(CircularProgressDrawable object, Float value) { 120 | object.setCurrentGlobalAngle(value); 121 | } 122 | }; 123 | 124 | private Property mSweepProperty = 125 | new Property(Float.class, "arc") { 126 | @Override 127 | public Float get(CircularProgressDrawable object) { 128 | return object.getCurrentSweepAngle(); 129 | } 130 | 131 | @Override 132 | public void set(CircularProgressDrawable object, Float value) { 133 | object.setCurrentSweepAngle(value); 134 | } 135 | }; 136 | 137 | private void setupAnimations() { 138 | mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, 360f); 139 | mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR); 140 | mObjectAnimatorAngle.setDuration(angleAnimatorDuration); 141 | mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART); 142 | mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE); 143 | 144 | mObjectAnimatorSweep = ObjectAnimator.ofFloat(this, 145 | mSweepProperty, 360f - minSweepAngle * 2); 146 | mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR); 147 | mObjectAnimatorSweep.setDuration(sweepAnimatorDuration); 148 | mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART); 149 | mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE); 150 | mObjectAnimatorSweep.addListener(new Animator.AnimatorListener() { 151 | @Override 152 | public void onAnimationStart(Animator animation) { 153 | 154 | } 155 | 156 | @Override 157 | public void onAnimationEnd(Animator animation) { 158 | 159 | } 160 | 161 | @Override 162 | public void onAnimationCancel(Animator animation) { 163 | 164 | } 165 | 166 | @Override 167 | public void onAnimationRepeat(Animator animation) { 168 | toggleAppearingMode(); 169 | } 170 | }); 171 | } 172 | 173 | @Override 174 | public void start() { 175 | if (isRunning()) { 176 | return; 177 | } 178 | mRunning = true; 179 | mObjectAnimatorAngle.start(); 180 | mObjectAnimatorSweep.start(); 181 | invalidateSelf(); 182 | } 183 | 184 | @Override 185 | public void stop() { 186 | if (!isRunning()) { 187 | return; 188 | } 189 | mRunning = false; 190 | mObjectAnimatorAngle.cancel(); 191 | mObjectAnimatorSweep.cancel(); 192 | invalidateSelf(); 193 | } 194 | 195 | @Override 196 | public boolean isRunning() { 197 | return mRunning; 198 | } 199 | 200 | public void setCurrentGlobalAngle(float currentGlobalAngle) { 201 | mCurrentGlobalAngle = currentGlobalAngle; 202 | invalidateSelf(); 203 | } 204 | 205 | public float getCurrentGlobalAngle() { 206 | return mCurrentGlobalAngle; 207 | } 208 | 209 | public void setCurrentSweepAngle(float currentSweepAngle) { 210 | mCurrentSweepAngle = currentSweepAngle; 211 | invalidateSelf(); 212 | } 213 | 214 | public float getCurrentSweepAngle() { 215 | return mCurrentSweepAngle; 216 | } 217 | 218 | public static final class Builder { 219 | 220 | private CircularProgressDrawable drawable; 221 | private int angleAnimatorDuration = 2000; 222 | private int sweepAnimatorDuration = 600; 223 | private int minSweepAngle = 30; 224 | private int borderWidth = 4; 225 | private int color = 0x00ff00; 226 | 227 | public CircularProgressDrawable build() { 228 | CircularProgressDrawable drawable = new CircularProgressDrawable(color, borderWidth); 229 | drawable.angleAnimatorDuration = angleAnimatorDuration; 230 | drawable.sweepAnimatorDuration = sweepAnimatorDuration; 231 | drawable.minSweepAngle = minSweepAngle; 232 | return drawable; 233 | } 234 | 235 | public void angleAnimatorDuration(int millis) { 236 | this.angleAnimatorDuration = millis; 237 | } 238 | 239 | public void sweepAnimatorDuration(int millis) { 240 | this.sweepAnimatorDuration = millis; 241 | } 242 | 243 | public void borderWidth(int px) { 244 | this.borderWidth = px; 245 | } 246 | 247 | public void color(int color) { 248 | this.color = color; 249 | } 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /library/src/main/java/org/quanqi/circularprogress/CircularProgressView.java: -------------------------------------------------------------------------------- 1 | package org.quanqi.circularprogress; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.content.Context; 7 | import android.content.res.TypedArray; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.graphics.Paint.Cap; 12 | import android.graphics.RectF; 13 | import android.support.annotation.NonNull; 14 | import android.util.AttributeSet; 15 | import android.util.Property; 16 | import android.view.View; 17 | import android.view.animation.AccelerateDecelerateInterpolator; 18 | import android.view.animation.Interpolator; 19 | import android.view.animation.LinearInterpolator; 20 | 21 | /** 22 | * By cindy on 12/22/14 3:53 PM. 23 | */ 24 | public class CircularProgressView extends View { 25 | 26 | private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator(); 27 | private static final Interpolator SWEEP_INTERPOLATOR = new AccelerateDecelerateInterpolator(); 28 | 29 | private int angleAnimatorDuration; 30 | 31 | private int sweepAnimatorDuration; 32 | 33 | private int minSweepAngle; 34 | 35 | private float mBorderWidth; 36 | 37 | private final RectF fBounds = new RectF(); 38 | private ObjectAnimator mObjectAnimatorSweep; 39 | private ObjectAnimator mObjectAnimatorAngle; 40 | private boolean mModeAppearing = true; 41 | private Paint mPaint; 42 | private float mCurrentGlobalAngleOffset; 43 | private float mCurrentGlobalAngle; 44 | 45 | private float mCurrentSweepAngle; 46 | private boolean mRunning; 47 | private int[] mColors; 48 | private int mCurrentColorIndex; 49 | private int mNextColorIndex; 50 | 51 | public CircularProgressView(Context context) { 52 | this(context, null); 53 | } 54 | 55 | public CircularProgressView(Context context, AttributeSet attrs) { 56 | this(context, attrs, 0); 57 | } 58 | 59 | public CircularProgressView(Context context, AttributeSet attrs, int defStyleAttr) { 60 | super(context, attrs, defStyleAttr); 61 | 62 | TypedArray a = context.obtainStyledAttributes( 63 | attrs, 64 | R.styleable.CircularProgressView, 65 | defStyleAttr, 0); 66 | 67 | mBorderWidth = a.getDimension( 68 | R.styleable.CircularProgressView_borderWidth, 69 | getResources().getDimension(R.dimen.circular_default_border_width)); 70 | 71 | angleAnimatorDuration = a.getInt( 72 | R.styleable.CircularProgressView_angleAnimationDurationMillis, 73 | getResources().getInteger(R.integer.circular_default_angleAnimationDurationMillis)); 74 | 75 | sweepAnimatorDuration = a.getInt( 76 | R.styleable.CircularProgressView_sweepAnimationDurationMillis, 77 | getResources().getInteger(R.integer.circular_default_sweepAnimationDuration)); 78 | 79 | minSweepAngle = a.getInt( 80 | R.styleable.CircularProgressView_minSweepAngle, 81 | getResources().getInteger(R.integer.circular_default_miniSweepAngle)); 82 | 83 | int colorArrayId = a.getResourceId(R.styleable.CircularProgressView_colorSequence, 84 | R.array.circular_default_color_sequence); 85 | if (isInEditMode()) { 86 | mColors = new int[4]; 87 | mColors[0] = getResources().getColor(R.color.circular_blue); 88 | mColors[1] = getResources().getColor(R.color.circular_green); 89 | mColors[2] = getResources().getColor(R.color.circular_red); 90 | mColors[3] = getResources().getColor(R.color.circular_yellow); 91 | } else { 92 | mColors = getResources().getIntArray(colorArrayId); 93 | } 94 | a.recycle(); 95 | 96 | mCurrentColorIndex = 0; 97 | mNextColorIndex = 1; 98 | 99 | mPaint = new Paint(); 100 | mPaint.setAntiAlias(true); 101 | mPaint.setStyle(Paint.Style.STROKE); 102 | mPaint.setStrokeCap(Cap.ROUND); 103 | mPaint.setStrokeWidth(mBorderWidth); 104 | mPaint.setColor(mColors[mCurrentColorIndex]); 105 | 106 | setupAnimations(); 107 | } 108 | 109 | private void innerStart() { 110 | if (isRunning()) { 111 | return; 112 | } 113 | mRunning = true; 114 | mObjectAnimatorAngle.start(); 115 | mObjectAnimatorSweep.start(); 116 | invalidate(); 117 | } 118 | 119 | private void innerStop() { 120 | if (!isRunning()) { 121 | return; 122 | } 123 | mRunning = false; 124 | mObjectAnimatorAngle.cancel(); 125 | mObjectAnimatorSweep.cancel(); 126 | invalidate(); 127 | } 128 | 129 | private boolean isRunning() { 130 | return mRunning; 131 | } 132 | 133 | @Override 134 | protected void onVisibilityChanged(@NonNull View changedView, int visibility) { 135 | super.onVisibilityChanged(changedView, visibility); 136 | if (visibility == VISIBLE) { 137 | innerStart(); 138 | } else { 139 | innerStop(); 140 | } 141 | } 142 | 143 | @Override 144 | protected void onAttachedToWindow() { 145 | innerStart(); 146 | super.onAttachedToWindow(); 147 | } 148 | 149 | @Override 150 | protected void onDetachedFromWindow() { 151 | innerStop(); 152 | super.onDetachedFromWindow(); 153 | } 154 | 155 | @Override 156 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 157 | super.onSizeChanged(w, h, oldw, oldh); 158 | fBounds.left = mBorderWidth / 2f + .5f; 159 | fBounds.right = w - mBorderWidth / 2f - .5f; 160 | fBounds.top = mBorderWidth / 2f + .5f; 161 | fBounds.bottom = h - mBorderWidth / 2f - .5f; 162 | } 163 | 164 | @Override 165 | public void draw(Canvas canvas) { 166 | super.draw(canvas); 167 | float startAngle = mCurrentGlobalAngle - mCurrentGlobalAngleOffset; 168 | float sweepAngle = mCurrentSweepAngle; 169 | if (mModeAppearing) { 170 | mPaint.setColor(gradient(mColors[mCurrentColorIndex], mColors[mNextColorIndex], 171 | mCurrentSweepAngle / (360 - minSweepAngle * 2))); 172 | sweepAngle += minSweepAngle; 173 | } else { 174 | startAngle = startAngle + sweepAngle; 175 | sweepAngle = 360 - sweepAngle - minSweepAngle; 176 | } 177 | canvas.drawArc(fBounds, startAngle, sweepAngle, false, mPaint); 178 | } 179 | 180 | private static int gradient(int color1, int color2, float p) { 181 | int r1 = (color1 & 0xff0000) >> 16; 182 | int g1 = (color1 & 0xff00) >> 8; 183 | int b1 = color1 & 0xff; 184 | int r2 = (color2 & 0xff0000) >> 16; 185 | int g2 = (color2 & 0xff00) >> 8; 186 | int b2 = color2 & 0xff; 187 | int newr = (int) (r2 * p + r1 * (1 - p)); 188 | int newg = (int) (g2 * p + g1 * (1 - p)); 189 | int newb = (int) (b2 * p + b1 * (1 - p)); 190 | return Color.argb(255, newr, newg, newb); 191 | } 192 | 193 | private void toggleAppearingMode() { 194 | mModeAppearing = !mModeAppearing; 195 | if (mModeAppearing) { 196 | mCurrentColorIndex = ++mCurrentColorIndex % mColors.length; 197 | mNextColorIndex = ++mNextColorIndex % mColors.length; 198 | mCurrentGlobalAngleOffset = (mCurrentGlobalAngleOffset + minSweepAngle * 2) % 360; 199 | } 200 | } 201 | 202 | private Property mAngleProperty = new Property(Float.class, "angle") { 203 | @Override 204 | public Float get(CircularProgressView object) { 205 | return object.getCurrentGlobalAngle(); 206 | } 207 | 208 | @Override 209 | public void set(CircularProgressView object, Float value) { 210 | object.setCurrentGlobalAngle(value); 211 | } 212 | }; 213 | 214 | private Property mSweepProperty = new Property(Float.class, "arc") { 215 | @Override 216 | public Float get(CircularProgressView object) { 217 | return object.getCurrentSweepAngle(); 218 | } 219 | 220 | @Override 221 | public void set(CircularProgressView object, Float value) { 222 | object.setCurrentSweepAngle(value); 223 | } 224 | }; 225 | 226 | private void setupAnimations() { 227 | mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, 360f); 228 | mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR); 229 | mObjectAnimatorAngle.setDuration(angleAnimatorDuration); 230 | mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART); 231 | mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE); 232 | 233 | mObjectAnimatorSweep = ObjectAnimator.ofFloat(this, mSweepProperty, 360f - minSweepAngle * 2); 234 | mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR); 235 | mObjectAnimatorSweep.setDuration(sweepAnimatorDuration); 236 | mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART); 237 | mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE); 238 | mObjectAnimatorSweep.addListener(new Animator.AnimatorListener() { 239 | @Override 240 | public void onAnimationStart(Animator animation) { 241 | 242 | } 243 | 244 | @Override 245 | public void onAnimationEnd(Animator animation) { 246 | 247 | } 248 | 249 | @Override 250 | public void onAnimationCancel(Animator animation) { 251 | 252 | } 253 | 254 | @Override 255 | public void onAnimationRepeat(Animator animation) { 256 | toggleAppearingMode(); 257 | } 258 | }); 259 | } 260 | 261 | public void setCurrentGlobalAngle(float currentGlobalAngle) { 262 | mCurrentGlobalAngle = currentGlobalAngle; 263 | invalidate(); 264 | } 265 | 266 | public float getCurrentGlobalAngle() { 267 | return mCurrentGlobalAngle; 268 | } 269 | 270 | public void setCurrentSweepAngle(float currentSweepAngle) { 271 | mCurrentSweepAngle = currentSweepAngle; 272 | invalidate(); 273 | } 274 | 275 | public float getCurrentSweepAngle() { 276 | return mCurrentSweepAngle; 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /library/src/main/res/values/circular_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 4dp 13 | 14 | 15 | @color/circular_red 16 | @color/circular_blue 17 | @color/circular_yellow 18 | @color/circular_green 19 | 20 | 21 | 900 22 | 2000 23 | 30 24 | 25 | #F90101 26 | #0266C8 27 | #F2B50F 28 | #00933B 29 | 30 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /shots/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dodocat/CircularProgress/a5439d009433dab59ec5bda0167426937c8a371e/shots/demo.gif --------------------------------------------------------------------------------