├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── README.MD ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── chenzy │ │ └── demo │ │ └── MainActivity.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── czy │ │ └── zydownloading │ │ └── ZYDownloading.java │ └── res │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Abstraction issuesJava 39 | 40 | 41 | Android 42 | 43 | 44 | Android > Lint > Correctness 45 | 46 | 47 | Android > Lint > Performance 48 | 49 | 50 | Android > Lint > Security 51 | 52 | 53 | Groovy 54 | 55 | 56 | Internationalization issuesJava 57 | 58 | 59 | J2ME issuesJava 60 | 61 | 62 | JUnit issuesJava 63 | 64 | 65 | Java 66 | 67 | 68 | Java language level migration aidsJava 69 | 70 | 71 | Javadoc issuesJava 72 | 73 | 74 | Memory issuesJava 75 | 76 | 77 | Performance issuesJava 78 | 79 | 80 | Probable bugsGroovy 81 | 82 | 83 | Probable bugsJava 84 | 85 | 86 | Spelling 87 | 88 | 89 | Visibility issuesJava 90 | 91 | 92 | XML 93 | 94 | 95 | 96 | 97 | AndroidLintOldTargetApi 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 119 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | ##ZYDownloading 2 | >一个蛮酷的加载进度条 3 | 4 | ####效果 5 | ![](https://github.com/zhangyuChen1991/some_sources/blob/master/ZYDownloading/ZYDownloading.gif) 6 | ####使用 7 | >这个小loading是一个自定义view,只有一个文件,下载下来拷到你的项目中即可使用,在布局中正常指定宽高即可。 8 | 9 | ####相关接口 10 | >* setCircleColor(int circleColor) 设置圆形填充颜色 11 | >* setArrowColor(int arrowColor) 设置箭头填充颜色 12 | >* startDownload() 开始下载 13 | >* isDownloading() 是否正在下载 14 | >* stopDownloading() 中止下载 15 | >* setProgress(int progress) 设置下载进度(0--100) 16 | 17 | 18 | 最后,谢谢光临,如果喜欢,欢迎star! -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | defaultConfig { 7 | applicationId "com.chenzy.demo" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.0.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(path: ':library') 30 | } 31 | -------------------------------------------------------------------------------- /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 E:\czyWorkSpace\envirment\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/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/chenzy/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.chenzy.demo; 2 | 3 | import android.app.Activity; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | import android.view.View; 9 | 10 | import com.czy.zydownloading.ZYDownloading; 11 | 12 | public class MainActivity extends Activity implements View.OnClickListener { 13 | 14 | private int progress = 0; 15 | ZYDownloading zyDownloading; 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | zyDownloading = (ZYDownloading) findViewById(R.id.acd_zydownloading); 21 | zyDownloading.setOnClickListener(this); 22 | } 23 | 24 | @Override 25 | public void onClick(View v) { 26 | switch (v.getId()) { 27 | case R.id.acd_zydownloading: 28 | if (!zyDownloading.isDownloading()) { 29 | progress = 0; 30 | zyDownloading.startDownload(); 31 | handler.sendMessageDelayed(Message.obtain(), 1500); 32 | } 33 | break; 34 | } 35 | } 36 | 37 | private Handler handler = new Handler() { 38 | @Override 39 | public void handleMessage(Message msg) { 40 | zyDownloading.setProgress(progress); 41 | if (progress < 100) { 42 | progress += 1; 43 | handler.sendMessageDelayed(Message.obtain(), 20); 44 | } 45 | 46 | super.handleMessage(msg); 47 | } 48 | }; 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 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 | Demo 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /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:2.2.2' 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 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyuChen1991/ZYDownloading/eecb55482fada857683def02cc472b4864cdef19/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.0.1' 30 | testCompile 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /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 E:\czyWorkSpace\envirment\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/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/java/com/czy/zydownloading/ZYDownloading.java: -------------------------------------------------------------------------------- 1 | package com.czy.zydownloading; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.CornerPathEffect; 11 | import android.graphics.Paint; 12 | import android.graphics.Path; 13 | import android.os.Build; 14 | import android.util.AttributeSet; 15 | import android.util.Log; 16 | import android.view.View; 17 | import android.view.animation.LinearInterpolator; 18 | 19 | /** 20 | * 一个蛮酷的加载进度条 21 | * Created by zhangyu on 2016/12/17. 22 | */ 23 | 24 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 25 | public class ZYDownloading extends View { 26 | private static final String TAG = "CoolDownloading"; 27 | private int vWidth, vHeight; 28 | private Point center, lineCenter; 29 | private final double sin45 = Math.sin(45 * 2 * Math.PI / 360); 30 | private Context context; 31 | private Paint outPaint, innerPaint, circlePaint; 32 | //左右两段三阶贝塞尔曲线的起点、终点、各自的两个控制点 33 | private Point startP, stopPL, stopPR, ctrlL1, ctrlL2, ctrlR1, ctrlR2; 34 | //贝塞尔曲线控制点坐标与中心点坐标的差值 与 圆框半径的比率 35 | private float ctrlWRate = 1.35f, ctrlHRate = 1; 36 | //左右两段三阶贝塞尔曲线的path 37 | private Path pathLeft, pathRight, linePath, cornerRectPath, progressRectPath; 38 | private ValueAnimator scaleAnim, circleToLinePathAnim, lineJumpAnim, arrowToRectAnim, mergeAnim; 39 | private final int SCALE = 0X1229, CIRCLE_TO_LINE = 0X1331, LINE_JUMP = 0X1332, SHOW_LOADINGBAR = 0X1333; 40 | private int nowDrawState = SCALE; 41 | //直线是否弹跳到最高点 42 | private boolean JUMP_HIGHEST = false; 43 | //弹跳到最高点的y位置 以及与中心点的垂直距离 44 | private float jumpHightY, distance; 45 | //圆圈的半径 46 | private float circleRadius; 47 | private int circlePaintAlpha = 255; 48 | //圆形填充颜色 49 | private int circleColor = Color.parseColor("#A52A2A");//Color.parseColor("#A9A9A9"); 50 | //箭头颜色 51 | private int arrowColor = Color.WHITE;//Color.BLACK; 52 | //下载进度 100满格 53 | private int progress = 0; 54 | 55 | //是否正在下载 56 | private boolean isDownloading = false; 57 | 58 | 59 | public ZYDownloading(Context context) { 60 | super(context); 61 | init(context); 62 | } 63 | 64 | public ZYDownloading(Context context, AttributeSet attrs) { 65 | super(context, attrs); 66 | init(context); 67 | } 68 | 69 | public ZYDownloading(Context context, AttributeSet attrs, int defStyleAttr) { 70 | super(context, attrs, defStyleAttr); 71 | init(context); 72 | } 73 | 74 | private void init(final Context context) { 75 | this.context = context; 76 | outPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 77 | outPaint.setStyle(Paint.Style.STROKE); 78 | outPaint.setColor(arrowColor); 79 | outPaint.setStrokeWidth(5); 80 | 81 | innerPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 82 | innerPaint.setStrokeWidth(5); 83 | innerPaint.setStyle(Paint.Style.FILL); 84 | 85 | circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 86 | circlePaint.setStyle(Paint.Style.FILL); 87 | 88 | pathLeft = new Path(); 89 | pathRight = new Path(); 90 | linePath = new Path(); 91 | cornerRectPath = new Path(); 92 | progressRectPath = new Path(); 93 | 94 | 95 | LinearInterpolator linearInterpolator = new LinearInterpolator(); 96 | 97 | scaleAnim = ValueAnimator.ofFloat(1, 0.85f, 1); 98 | scaleAnim.setInterpolator(linearInterpolator); 99 | scaleAnim.setDuration(350); 100 | scaleAnim.addUpdateListener(scaleListener); 101 | scaleAnim.addListener(new AnimatorListenerAdapter() { 102 | @Override 103 | public void onAnimationEnd(Animator animation) { 104 | nowDrawState = CIRCLE_TO_LINE; 105 | //开始上下弹的动画 106 | circleToLinePathAnim.start(); 107 | 108 | } 109 | }); 110 | 111 | circleToLinePathAnim = ValueAnimator.ofFloat(0, 1); 112 | circleToLinePathAnim.setInterpolator(linearInterpolator); 113 | circleToLinePathAnim.setDuration(200); 114 | circleToLinePathAnim.addUpdateListener(C2LUpdateListener); 115 | circleToLinePathAnim.addListener(new AnimatorListenerAdapter() { 116 | @Override 117 | public void onAnimationEnd(Animator animation) { 118 | nowDrawState = LINE_JUMP; 119 | //开始上下弹的动画 120 | lineJumpAnim.start(); 121 | 122 | } 123 | }); 124 | 125 | lineJumpAnim = ValueAnimator.ofFloat(0, -2.5f, 1.3f, -1f, 0.5f, -0.2f,0); 126 | lineJumpAnim.setInterpolator(linearInterpolator); 127 | lineJumpAnim.setDuration(450); 128 | lineJumpAnim.addUpdateListener(LJumpUpdateListener); 129 | 130 | arrowToRectAnim = ValueAnimator.ofFloat(0, -0.5f, 1); 131 | arrowToRectAnim.setInterpolator(linearInterpolator); 132 | arrowToRectAnim.setDuration(350);//350 133 | arrowToRectAnim.addUpdateListener(arrowToCircleAnimListener); 134 | arrowToRectAnim.addListener(new AnimatorListenerAdapter() { 135 | @Override 136 | public void onAnimationEnd(Animator animation) { 137 | 138 | nowDrawState = SHOW_LOADINGBAR; 139 | mergeAnim.start(); 140 | super.onAnimationEnd(animation); 141 | } 142 | }); 143 | 144 | //圆滑方框与线条融合的动画 145 | mergeAnim = ValueAnimator.ofFloat(0, 1); 146 | mergeAnim.setInterpolator(linearInterpolator); 147 | mergeAnim.setDuration(350); 148 | mergeAnim.addUpdateListener(mergeAnimListener); 149 | mergeAnim.addListener(new AnimatorListenerAdapter() { 150 | @Override 151 | public void onAnimationEnd(Animator animation) { 152 | JUMP_HIGHEST = false; 153 | radius = circleRadius; 154 | arrowCenter = new Point(center.x, center.y); 155 | circlePaintAlpha = 255; 156 | super.onAnimationEnd(animation); 157 | } 158 | }); 159 | 160 | } 161 | 162 | private float barHeight = 5; 163 | 164 | @Override 165 | protected void onDraw(Canvas canvas) { 166 | super.onDraw(canvas); 167 | if (nowDrawState == SCALE) {//圆框缩放阶段 168 | drawInnerCircle(canvas, circlePaintAlpha); 169 | drawCurvePath(canvas); 170 | drawArrow(canvas); 171 | } else if (nowDrawState == CIRCLE_TO_LINE) { 172 | drawCurvePath(canvas); 173 | if (startP.y <= center.y + rate3 * circleRadius) {//碰到曲线时,跟随弹动 174 | arrowCenter.y = startP.y - rate3 * circleRadius; 175 | drawArrow(canvas); 176 | } else { 177 | drawArrow(canvas); 178 | } 179 | } else if (nowDrawState == LINE_JUMP) { 180 | drawLinePath(canvas); 181 | if (!JUMP_HIGHEST) {//在接触过程中还没弹到最高点,跟随线条上弹 182 | arrowCenter.y = lineCenter.y - rate3 * circleRadius; 183 | drawArrow(canvas); 184 | } else {//接触过程中弹到最高点,开始飞起,再落下,过程中箭头渐变成圆角方框 185 | drawArrowToRect(canvas, radius); 186 | } 187 | } else if (nowDrawState == SHOW_LOADINGBAR) { 188 | drawArrowToRect(canvas, radius); 189 | drawLoadingBar(canvas, barHeight); 190 | } 191 | } 192 | 193 | /** 194 | * 绘制上下跳动的直线轨迹 195 | * 196 | * @param canvas 197 | */ 198 | private void drawLinePath(Canvas canvas) { 199 | outPaint.setStyle(Paint.Style.STROKE); 200 | linePath.reset(); 201 | //从上一阶段两条三阶贝塞尔曲线变成直线后再让直线上下跳动 202 | //stopL成为现在的linePath新起点,stopR成为新的终点 lineCenter作为控制点 构造新的二阶贝塞尔曲线 203 | linePath.moveTo(stopPL.x, stopPL.y); 204 | linePath.quadTo(lineCenter.x, lineCenter.y, stopPR.x, stopPR.y); 205 | canvas.drawPath(linePath, outPaint); 206 | } 207 | 208 | /** 209 | * 绘制贝塞尔曲线的轨迹 210 | * 211 | * @param canvas 212 | */ 213 | private void drawCurvePath(Canvas canvas) { 214 | outPaint.setStyle(Paint.Style.STROKE); 215 | pathLeft.reset(); 216 | pathRight.reset(); 217 | 218 | pathLeft.moveTo(startP.x, startP.y); 219 | pathRight.moveTo(startP.x, startP.y); 220 | 221 | pathLeft.cubicTo(ctrlL1.x, ctrlL1.y, ctrlL2.x, ctrlL2.y, stopPL.x, stopPL.y); 222 | pathRight.cubicTo(ctrlR1.x, ctrlR1.y, ctrlR2.x, ctrlR2.y, stopPR.x, stopPR.y); 223 | 224 | canvas.drawPath(pathLeft, outPaint); 225 | canvas.drawPath(pathRight, outPaint); 226 | } 227 | 228 | private void drawInnerCircle(Canvas canvas, int alpha) { 229 | Path circlePath = new Path(); 230 | circlePath.moveTo(startP.x, startP.y); 231 | circlePath.cubicTo(ctrlL1.x, ctrlL1.y, ctrlL2.x, ctrlL2.y, stopPL.x, stopPL.y); 232 | circlePath.cubicTo(ctrlR2.x, ctrlR2.y, ctrlR1.x, ctrlR1.y, startP.x, startP.y); 233 | 234 | circlePaint.setColor(circleColor); 235 | circlePaint.setAlpha(alpha); 236 | canvas.drawPath(circlePath, circlePaint); 237 | } 238 | 239 | //箭头的各个顶点 240 | Point arrowP0, arrowP1, arrowP2, arrowP3, arrowP4, arrowP5, arrowP6; 241 | //中心点到各个顶点距离与大圆半径的比率 242 | private float rate1 = 0.27f, rate2 = 0.55f, rate3 = 2 * rate1; 243 | private Point arrowCenter; 244 | 245 | private void initData() { 246 | center = new Point(vWidth / 2f, vHeight / 2f); 247 | 248 | float base = vWidth > vHeight ? vWidth : vHeight; 249 | circleRadius = base * 0.8f / 8f; 250 | //初始化直线的中心点 251 | lineCenter = new Point(center.x, center.y); 252 | 253 | //圆的外切正方形,两段贝塞尔曲线,控制点分别为正方形的四个顶点 254 | //左下角顶点 ctrlL1 左上角顶点 ctrlL2; 右下角顶点 ctrlR1 右上角顶点 ctrlR2 255 | updateCtrlPoint(); 256 | 257 | arrowCenter = new Point(center.x, center.y); 258 | } 259 | 260 | private void updateCtrlPoint() { 261 | 262 | //初始数据模拟画圆 263 | //将圆分为左半边曲线和右半边曲线,起点为圆上正下方的点,终点为正上方的点 264 | startP = new Point(center.x, center.y + ctrlHRate * circleRadius); 265 | stopPL = new Point(center.x, center.y - ctrlHRate * circleRadius); 266 | stopPR = new Point(center.x, center.y - ctrlHRate * circleRadius); 267 | 268 | ctrlL1 = new Point(center.x - ctrlWRate * circleRadius, center.y + ctrlHRate * circleRadius); 269 | ctrlL2 = new Point(center.x - ctrlWRate * circleRadius, center.y - ctrlHRate * circleRadius); 270 | ctrlR1 = new Point(center.x + ctrlWRate * circleRadius, center.y + ctrlHRate * circleRadius); 271 | ctrlR2 = new Point(center.x + ctrlWRate * circleRadius, center.y - ctrlHRate * circleRadius); 272 | } 273 | 274 | private ValueAnimator.AnimatorUpdateListener scaleListener = new ValueAnimator.AnimatorUpdateListener() { 275 | 276 | @Override 277 | public void onAnimationUpdate(ValueAnimator animation) { 278 | float value = (float) animation.getAnimatedValue();//value 1-->0.8-->1 279 | ctrlWRate = value * 1.35f; 280 | ctrlHRate = value; 281 | 282 | rate1 = 0.27f * value; 283 | rate2 = 0.55f * value; 284 | rate3 = 2 * rate1; 285 | 286 | updateCtrlPoint(); 287 | Log.i(TAG, "circlePaintAlpha = " + circlePaintAlpha); 288 | if (circlePaintAlpha > 0) { 289 | circlePaintAlpha -= 5; 290 | circlePaintAlpha = circlePaintAlpha < 0 ? 0 : circlePaintAlpha; 291 | } 292 | invalidate(); 293 | } 294 | }; 295 | 296 | /** 297 | * 圆变直线的动画监听 描述数据变化过程 298 | */ 299 | private ValueAnimator.AnimatorUpdateListener C2LUpdateListener = new ValueAnimator.AnimatorUpdateListener() { 300 | @Override 301 | public void onAnimationUpdate(ValueAnimator animation) { 302 | float value = (float) animation.getAnimatedValue();//value 0-->1 303 | startP.y = center.y + (1 - value) * circleRadius; 304 | 305 | stopPR.x = center.x + value * 3.8f * circleRadius; 306 | stopPR.y = center.y - (1 - value) * circleRadius; 307 | 308 | stopPL.x = center.x - value * 3.8f * circleRadius; 309 | stopPL.y = center.y - (1 - value) * circleRadius; 310 | 311 | ctrlL1.y = center.y + (1 - value) * circleRadius; 312 | 313 | ctrlL2.y = center.y - circleRadius + value * circleRadius; 314 | 315 | ctrlR1.y = center.y + (1 - value) * circleRadius; 316 | 317 | ctrlR2.y = center.y - circleRadius + value * circleRadius; 318 | 319 | invalidate(); 320 | } 321 | }; 322 | 323 | /** 324 | * 直线上下跳动的动画监听 描述数据变化过程 325 | */ 326 | private ValueAnimator.AnimatorUpdateListener LJumpUpdateListener = new ValueAnimator.AnimatorUpdateListener() { 327 | 328 | @Override 329 | public void onAnimationUpdate(ValueAnimator animation) { 330 | float value = (float) animation.getAnimatedValue(); 331 | lineCenter.y = center.y + value * circleRadius; 332 | 333 | Log.d(TAG, "LJumpUpdateListener value = " + value); 334 | if (!JUMP_HIGHEST && value <= -2.1f) { 335 | JUMP_HIGHEST = true; 336 | arrowToRectAnim.start(); 337 | //接触线的时候弹到的最高点 338 | jumpHightY = lineCenter.y; 339 | distance = center.y - jumpHightY; 340 | } 341 | invalidate(); 342 | } 343 | }; 344 | 345 | private float radius = circleRadius; 346 | private ValueAnimator.AnimatorUpdateListener arrowToCircleAnimListener = new ValueAnimator.AnimatorUpdateListener() { 347 | 348 | @Override 349 | public void onAnimationUpdate(ValueAnimator animation) { 350 | //arrow0、3、4、6点位移至左上、右上、右下、左下方形成矩形 顶点加圆弧效果,模拟圆形 351 | float value = (float) animation.getAnimatedValue();//value 0-->-0.25-->1 352 | 353 | //中心点变化 354 | arrowCenter.y = jumpHightY + distance * value - rate3 * circleRadius; 355 | 356 | if (value > 0 && value <= 1) {//arrow顶点位移变化,只有0,3,4,6与value关联变化 357 | radius = circleRadius + value * circleRadius; 358 | float valueH = value * 0.4f; 359 | arrowP0 = new Point(arrowCenter.x - (rate1 + valueH) * circleRadius, arrowCenter.y - rate2 * value * circleRadius); 360 | arrowP1 = new Point(arrowCenter.x - rate1 * circleRadius, arrowCenter.y - circleRadius * rate2); 361 | arrowP2 = new Point(arrowCenter.x + rate1 * circleRadius, arrowCenter.y - circleRadius * rate2); 362 | arrowP3 = new Point(arrowCenter.x + (rate1 + valueH) * circleRadius, arrowCenter.y - rate2 * value * circleRadius); 363 | arrowP4 = new Point(arrowCenter.x + (rate3 - rate1 + valueH) * circleRadius, arrowCenter.y + value * rate3 * circleRadius); 364 | arrowP5 = new Point(arrowCenter.x, arrowCenter.y + rate3 * circleRadius); 365 | arrowP6 = new Point(arrowCenter.x - (rate3 + valueH - rate1) * circleRadius, arrowCenter.y + value * rate3 * circleRadius); 366 | } else { 367 | updateArrowPointByCenter(); 368 | } 369 | invalidate(); 370 | } 371 | }; 372 | 373 | private ValueAnimator.AnimatorUpdateListener mergeAnimListener = new ValueAnimator.AnimatorUpdateListener() { 374 | 375 | @Override 376 | public void onAnimationUpdate(ValueAnimator animation) { 377 | float value = (float) animation.getAnimatedValue();//value 0-->1 378 | //圆弧线框向下缩小 线条变粗 379 | //点0,1,2,3向下移 380 | float distance = center.y - arrowP0.y; 381 | arrowP0.y = center.y - (1 - value) * distance; 382 | arrowP1.y = center.y - (1 - value) * distance; 383 | arrowP2.y = center.y - (1 - value) * distance; 384 | arrowP3.y = center.y - (1 - value) * distance; 385 | 386 | barHeight = 5 + 25 * value; 387 | 388 | invalidate(); 389 | } 390 | }; 391 | 392 | private void drawArrow(Canvas canvas) { 393 | innerPaint.setPathEffect(null); 394 | innerPaint.setColor(arrowColor); 395 | updateArrowPointByCenter(); 396 | 397 | Path arrowPath = createArrowPath(); 398 | 399 | canvas.drawPath(arrowPath, innerPaint); 400 | } 401 | 402 | private void drawArrowToRect(Canvas canvas, float radius) { 403 | //arrow0、3、4、6点位移至左上、右上、右下、左下方形成矩形 顶点加圆弧效果 404 | innerPaint.setPathEffect(new CornerPathEffect(radius)); 405 | innerPaint.setColor(arrowColor); 406 | Path path = createArrowPath(); 407 | 408 | canvas.drawPath(path, innerPaint); 409 | 410 | } 411 | 412 | /** 413 | * @param canvas 414 | * @param height 415 | */ 416 | private void drawLoadingBar(Canvas canvas, float height) { 417 | innerPaint.setStyle(Paint.Style.FILL); 418 | innerPaint.setPathEffect(new CornerPathEffect(30)); 419 | //完整矩形左上角,右下角的点 420 | Point lu = new Point(stopPL.x, stopPL.y - height); 421 | Point rd = new Point(stopPR.x, stopPR.y + height); 422 | 423 | float length = stopPR.x - stopPL.x; 424 | //进度右下角点 425 | 426 | innerPaint.setTextSize(35); 427 | 428 | 429 | //完整进度条长度 430 | innerPaint.setColor(arrowColor); 431 | cornerRectPath.reset(); 432 | cornerRectPath.moveTo(lu.x, lu.y); 433 | cornerRectPath.lineTo(rd.x, lu.y); 434 | cornerRectPath.lineTo(rd.x, rd.y); 435 | cornerRectPath.lineTo(lu.x, rd.y); 436 | cornerRectPath.close(); 437 | canvas.drawPath(cornerRectPath, innerPaint); 438 | 439 | 440 | //已下载长度 441 | innerPaint.setColor(circleColor); 442 | progressRectPath.reset(); 443 | progressRectPath.moveTo(lu.x, lu.y); 444 | progressRectPath.lineTo(lu.x + progress * 0.01f * length, lu.y); 445 | progressRectPath.lineTo(lu.x + progress * 0.01f * length, rd.y); 446 | progressRectPath.lineTo(lu.x, rd.y); 447 | progressRectPath.close(); 448 | canvas.drawPath(progressRectPath, innerPaint); 449 | 450 | 451 | String text = progress + "%"; 452 | innerPaint.setColor(arrowColor); 453 | canvas.drawText(text, lu.x + progress * 0.01f * length - text.length() * 25, stopPR.y + 10, innerPaint); 454 | } 455 | 456 | /** 457 | * 根据中心点绘制箭头各顶点 458 | */ 459 | private void updateArrowPointByCenter() { 460 | arrowP0 = new Point(arrowCenter.x - rate1 * circleRadius, arrowCenter.y); 461 | arrowP1 = new Point(arrowCenter.x - rate1 * circleRadius, arrowCenter.y - circleRadius * rate2); 462 | arrowP2 = new Point(arrowCenter.x + rate1 * circleRadius, arrowCenter.y - circleRadius * rate2); 463 | arrowP3 = new Point(arrowCenter.x + rate1 * circleRadius, arrowCenter.y); 464 | arrowP4 = new Point(arrowCenter.x + rate3 * circleRadius, arrowCenter.y); 465 | arrowP5 = new Point(arrowCenter.x, arrowCenter.y + rate3 * circleRadius); 466 | arrowP6 = new Point(arrowCenter.x - rate3 * circleRadius, arrowCenter.y); 467 | } 468 | 469 | private Path createArrowPath() { 470 | Path arrowPath = new Path(); 471 | arrowPath.moveTo(arrowP0.x, arrowP0.y); 472 | arrowPath.lineTo(arrowP1.x, arrowP1.y); 473 | arrowPath.lineTo(arrowP2.x, arrowP2.y); 474 | arrowPath.lineTo(arrowP3.x, arrowP3.y); 475 | arrowPath.lineTo(arrowP4.x, arrowP4.y); 476 | arrowPath.lineTo(arrowP5.x, arrowP5.y); 477 | arrowPath.lineTo(arrowP6.x, arrowP6.y); 478 | arrowPath.close(); 479 | return arrowPath; 480 | } 481 | 482 | @Override 483 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 484 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 485 | vHeight = getMeasuredHeight(); 486 | vWidth = getMeasuredWidth(); 487 | 488 | initData(); 489 | } 490 | 491 | 492 | /** 493 | * 设置下载进度 494 | * 495 | * @param progress 496 | */ 497 | public void setProgress(int progress) { 498 | this.progress = progress; 499 | if (progress == 100) {//下载完毕 500 | isDownloading = false; 501 | 502 | } 503 | invalidate(); 504 | } 505 | 506 | /** 507 | * 设置圆形填充颜色 508 | * 509 | * @param circleColor 510 | */ 511 | public void setCircleColor(int circleColor) { 512 | this.circleColor = circleColor; 513 | } 514 | 515 | /** 516 | * 设置箭头填充颜色 517 | * 518 | * @param arrowColor 519 | */ 520 | public void setArrowColor(int arrowColor) { 521 | this.arrowColor = arrowColor; 522 | } 523 | 524 | 525 | public boolean startDownload() { 526 | if (!isDownloading) { 527 | progress = 0; 528 | isDownloading = true; 529 | nowDrawState = SCALE; 530 | scaleAnim.start(); 531 | return true; 532 | } 533 | return false; 534 | } 535 | 536 | public void stopDownloading() { 537 | isDownloading = false; 538 | scaleAnim.cancel(); 539 | circleToLinePathAnim.cancel(); 540 | lineJumpAnim.cancel(); 541 | mergeAnim.cancel(); 542 | nowDrawState = SCALE; 543 | invalidate(); 544 | } 545 | 546 | /** 547 | * 是否正在下载 548 | * 549 | * @return 550 | */ 551 | public boolean isDownloading() { 552 | return isDownloading; 553 | } 554 | 555 | private class Point { 556 | float x, y; 557 | 558 | public Point(float x, float y) { 559 | this.x = x; 560 | this.y = y; 561 | } 562 | 563 | public Point() { 564 | } 565 | } 566 | } 567 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Library 3 | 4 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | --------------------------------------------------------------------------------