├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── ok.png
│ │ │ └── down.png
│ │ ├── 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
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── styles.xml
│ │ │ └── attrs.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── y
│ │ └── progressview
│ │ ├── view
│ │ ├── ProgressDefaults.java
│ │ └── ProgressBarView.java
│ │ ├── MainActivity.java
│ │ └── ProgressHandler.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ok.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/drawable/ok.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/drawable/down.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/7449/ProgressView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ProgressView
3 | download
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .idea/markdown-navigator/
10 | /.idea/
11 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 11 20:21:49 CST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ProgressView
2 | Custom view scrollbar
3 |
4 | 
5 | 
6 | 
7 |
8 | Custom view to achieve the download progress display
9 | Fully customizable controls, font size, ring width, solid or hollow, ring width, ring color, progress font weight, font color, etc., can be customized
10 |
11 | Code specific situation
12 |
13 | 自定义view实现下载进度的展示
14 | 控件完全自定义,字体大小,圆环宽度,实心或者空心,圆环的宽度,圆环的颜色,进度字体的粗细,字体颜色等等都可以自定义
15 |
16 | 具体的情况看代码
--------------------------------------------------------------------------------
/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:\sdk\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/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '25.0.0'
6 |
7 | defaultConfig {
8 | applicationId "com.example.y.progressview"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.3.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
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
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/y/progressview/view/ProgressDefaults.java:
--------------------------------------------------------------------------------
1 | package com.example.y.progressview.view;
2 |
3 | import android.graphics.Color;
4 |
5 | /**
6 | * by y on 2016/5/25.
7 | */
8 | public class ProgressDefaults {
9 |
10 |
11 | /**
12 | * 判断数据的最小值
13 | */
14 | public static final int MIN = 1;
15 |
16 | /**
17 | * 最大进度
18 | */
19 | public static final int PROGRESS_BAR_MAX = 100;
20 |
21 | /**
22 | * 默认进度
23 | */
24 | public static final int CURRENT_PROGRESS = 0;
25 |
26 | /**
27 | * 默认圆环宽度
28 | */
29 | public static final float CIRCLES_WIDTH = 5;
30 | /**
31 | * 默认进度宽度
32 | */
33 | public static final float CURRENT_SCHEDULE_WIDTH = 6;
34 |
35 | /**
36 | * 默认圆环颜色
37 | */
38 | public static final int CIRCLES_COLOR = Color.GRAY;
39 |
40 | /**
41 | * 默认字体的粗细程度
42 | */
43 | public static final float TEXT_CRUDE = 0;
44 |
45 | /**
46 | * 默认字体颜色
47 | */
48 | public static final int TEXT_COLOR = Color.GRAY;
49 |
50 | /**
51 | * 默认字体大小
52 | */
53 | public static final float TEXT_SIZE = 25;
54 |
55 | /**
56 | * 默认进度的颜色
57 | */
58 | public static final int CURRENT_PROGRESS_COLOR = Color.YELLOW;
59 |
60 | /**
61 | * 是否显示百分比
62 | */
63 | public static final boolean IS_PERCENT = true;
64 |
65 | /**
66 | * 默认风格
67 | */
68 | public static final int STYLE = 1;
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/y/progressview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.y.progressview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 |
8 | import com.example.y.progressview.view.ProgressBarView;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 |
13 | private ProgressHandler progressHandler = new ProgressHandler();
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | Button button = (Button) findViewById(R.id.btn);
21 | final ProgressBarView progressBarView = (ProgressBarView) findViewById(R.id.view);
22 |
23 | assert button != null;
24 | assert progressBarView != null;
25 | progressBarView.setPercent(false);
26 | progressBarView.setStyle(1);
27 |
28 |
29 | button.setOnClickListener(new View.OnClickListener() {
30 | @Override
31 | public void onClick(View v) {
32 | progressHandler.sendEmptyMessageDelayed(ProgressHandler.UPDATE, ProgressHandler.TIME);
33 | }
34 | });
35 |
36 |
37 | progressHandler.setProgress(new ProgressHandler.Progress() {
38 | @Override
39 | public void setSchedule(int schedule) {
40 | progressBarView.setCurrentProgress(schedule);
41 | }
42 |
43 | @Override
44 | public void onSuccess() {
45 | }
46 | });
47 |
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/y/progressview/ProgressHandler.java:
--------------------------------------------------------------------------------
1 | package com.example.y.progressview;
2 |
3 |
4 | import android.os.Handler;
5 | import android.os.Message;
6 |
7 | import com.example.y.progressview.view.ProgressDefaults;
8 |
9 | /**
10 | * by 12406 on 2016/5/25.
11 | */
12 | public class ProgressHandler extends Handler {
13 |
14 | public Progress progress;
15 |
16 | public void setProgress(Progress progress) {
17 | this.progress = progress;
18 | }
19 |
20 |
21 | /**
22 | * 请求更新
23 | */
24 | public static final int UPDATE = 1;
25 | /**
26 | * 请求暂停
27 | */
28 | public static final int KEEP = 2;
29 | /**
30 | * 请求恢复
31 | */
32 | public static final int BREAK = 3;
33 | /**
34 | * 请求移除
35 | */
36 | public static final int REMOVE = -1;
37 | /**
38 | * 记录最新进度
39 | */
40 | public static final int PAGE = 4;
41 |
42 | //间隔时间
43 | public static final long TIME = 100;
44 |
45 | public static int SCHEDULE = 0;
46 |
47 | @Override
48 |
49 | public void handleMessage(Message msg) {
50 | super.handleMessage(msg);
51 | if (hasMessages(UPDATE)) {
52 | removeMessages(UPDATE);
53 | }
54 | switch (msg.what) {
55 | case UPDATE:
56 | if (!(SCHEDULE == ProgressDefaults.PROGRESS_BAR_MAX)) {
57 | SCHEDULE++;
58 | sendEmptyMessageDelayed(UPDATE, TIME);
59 | } else {
60 | sendEmptyMessageDelayed(REMOVE, TIME);
61 | }
62 | if (progress != null) {
63 | progress.setSchedule(SCHEDULE);
64 | }
65 | break;
66 | case KEEP:
67 | break;
68 | case BREAK:
69 | sendEmptyMessageDelayed(UPDATE, TIME);
70 | break;
71 | case PAGE:
72 | SCHEDULE = msg.arg1;
73 | break;
74 | case REMOVE:
75 | progress.onSuccess();
76 | SCHEDULE = 0;
77 | break;
78 | default:
79 | sendEmptyMessageDelayed(UPDATE, TIME);
80 | break;
81 | }
82 | }
83 |
84 |
85 | public interface Progress {
86 | void setSchedule(int schedule);
87 |
88 | void onSuccess();
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/y/progressview/view/ProgressBarView.java:
--------------------------------------------------------------------------------
1 | package com.example.y.progressview.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.graphics.RectF;
8 | import android.graphics.Typeface;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.View;
12 |
13 | import com.example.y.progressview.R;
14 |
15 |
16 | /**
17 | * by 12406 on 2016/5/24.
18 | */
19 | public class ProgressBarView extends View {
20 |
21 | //空心
22 | public static final int STROKE = 1;
23 | //实心
24 | public static final int FILL = 0;
25 |
26 |
27 | private Paint mPaint;
28 | private int style;
29 |
30 | //圆环的宽度
31 | private float circlesWidth;
32 | //圆环的颜色
33 | private int circlesColor;
34 | //进度字体的粗细程度
35 | private float textCrude;
36 | //字体颜色
37 | private int textColor;
38 | //字体大小
39 | private float textSize;
40 | //设置字体
41 | private Typeface mTypeface;
42 | //当前进度
43 | private int currentProgress;
44 | //进度颜色
45 | private int currentProgressColor;
46 | //进度圆环的宽度
47 | private float currentScheduleWidth;
48 | //是否显示百分比
49 | private boolean isPercent;
50 | private RectF rectF;
51 |
52 |
53 | public ProgressBarView(Context context) {
54 | super(context);
55 | }
56 |
57 | public ProgressBarView(Context context, AttributeSet attrs) {
58 | super(context, attrs);
59 | init(context, attrs);
60 | }
61 |
62 | public ProgressBarView(Context context, AttributeSet attrs, int defStyleAttr) {
63 | super(context, attrs, defStyleAttr);
64 | init(context, attrs);
65 | }
66 |
67 | private void init(Context context, AttributeSet attrs) {
68 |
69 | mPaint = new Paint();
70 | rectF = new RectF();
71 | mPaint.setAntiAlias(true);
72 | TypedArray mTypedArray = context.obtainStyledAttributes(attrs, R.styleable.CirclesProgressBar);
73 |
74 |
75 | //初始化圆环变量
76 | circlesWidth = mTypedArray.getDimension(R.styleable.CirclesProgressBar_circlesWidth, ProgressDefaults.CIRCLES_WIDTH);
77 | circlesColor = mTypedArray.getColor(R.styleable.CirclesProgressBar_circlesColor, ProgressDefaults.CIRCLES_COLOR);
78 | textCrude = mTypedArray.getDimension(R.styleable.CirclesProgressBar_textCrude, ProgressDefaults.TEXT_CRUDE);
79 | textColor = mTypedArray.getColor(R.styleable.CirclesProgressBar_textColor, ProgressDefaults.TEXT_COLOR);
80 | textSize = mTypedArray.getDimension(R.styleable.CirclesProgressBar_textSize, ProgressDefaults.TEXT_SIZE);
81 | currentProgress = mTypedArray.getInt(R.styleable.CirclesProgressBar_currentProgress, ProgressDefaults.CURRENT_PROGRESS);
82 | currentProgressColor = mTypedArray.getColor(R.styleable.CirclesProgressBar_currentProgressColor, ProgressDefaults.CURRENT_PROGRESS_COLOR);
83 | isPercent = mTypedArray.getBoolean(R.styleable.CirclesProgressBar_isPercent, ProgressDefaults.IS_PERCENT);
84 | style = mTypedArray.getInt(R.styleable.CirclesProgressBar_style, ProgressDefaults.STYLE);
85 | currentScheduleWidth = mTypedArray.getDimension(R.styleable.CirclesProgressBar_currentScheduleWidth, ProgressDefaults.CURRENT_SCHEDULE_WIDTH);
86 |
87 | mTypedArray.recycle();
88 |
89 | }
90 |
91 |
92 | @Override
93 | protected void onDraw(Canvas canvas) {
94 | super.onDraw(canvas);
95 | int anInt = getWidth() / 2;
96 | int circlesRadius = (int) (anInt - circlesWidth / 2);//半径
97 |
98 |
99 | //圆环
100 | mPaint.setColor(circlesColor);
101 | mPaint.setStyle(Paint.Style.STROKE);
102 | mPaint.setStrokeWidth(circlesWidth);
103 | canvas.drawCircle(anInt, anInt, circlesRadius, mPaint);
104 |
105 | //百分比
106 | if (isPercent && style == STROKE) {
107 | mPaint.setStrokeWidth(textCrude);
108 | mPaint.setColor(textColor);
109 | mPaint.setTextSize(textSize);
110 | mPaint.setTypeface(mTypeface);
111 | int percent = (int) (((float) currentProgress / (float) ProgressDefaults.PROGRESS_BAR_MAX) * 100);
112 | float textWidth = mPaint.measureText(percent + "%");
113 | canvas.drawText(percent + "%", anInt - textWidth / 2, anInt + textSize / 2, mPaint);
114 | }
115 |
116 |
117 | //进度的圆环
118 | mPaint.setColor(currentProgressColor);
119 | mPaint.setStrokeWidth(currentScheduleWidth);
120 | rectF.set(anInt - circlesRadius, anInt - circlesRadius, anInt + circlesRadius, anInt + circlesRadius);
121 | //选择风格
122 | switch (style) {
123 |
124 | case STROKE:
125 | if (currentProgress != 0) {
126 | mPaint.setStyle(Paint.Style.STROKE);
127 | canvas.drawArc(rectF, 0, 360 * currentProgress / ProgressDefaults.PROGRESS_BAR_MAX, false, mPaint);
128 | }
129 | break;
130 | case FILL:
131 | if (currentProgress != 0) {
132 | mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
133 | canvas.drawArc(rectF, 0, 360 * currentProgress / ProgressDefaults.PROGRESS_BAR_MAX, true, mPaint);
134 | }
135 | break;
136 | }
137 | Log.i("onDraw---->", "onDraw current");
138 | }
139 |
140 |
141 | public synchronized void setCurrentProgress(int currentProgress) {
142 | if (currentProgress < ProgressDefaults.CURRENT_PROGRESS) {
143 | currentProgress = ProgressDefaults.CURRENT_PROGRESS;
144 | }
145 | if (currentProgress > ProgressDefaults.PROGRESS_BAR_MAX) {
146 | currentProgress = ProgressDefaults.PROGRESS_BAR_MAX;
147 | }
148 | if (currentProgress <= ProgressDefaults.PROGRESS_BAR_MAX) {
149 | this.currentProgress = currentProgress;
150 | postInvalidate();
151 | }
152 | }
153 |
154 | public synchronized float getCurrentProgress() {
155 | return currentProgress;
156 | }
157 |
158 |
159 | public void setScheduleWidth(float currentScheduleWidth) {
160 | this.currentScheduleWidth = currentScheduleWidth;
161 | }
162 |
163 | public float getScheduleWidth() {
164 | return currentScheduleWidth;
165 | }
166 |
167 | public void setStyle(int style) {
168 | this.style = style;
169 | }
170 |
171 | public int getStyle() {
172 | return style;
173 | }
174 |
175 | public void setPercent(boolean isPercent) {
176 | this.isPercent = isPercent;
177 | }
178 |
179 | public boolean getPercent() {
180 | return isPercent;
181 | }
182 |
183 | public void setCurrentProgressColor(int currentProgressColor) {
184 | if (currentProgressColor < ProgressDefaults.MIN) {
185 | currentProgressColor = ProgressDefaults.CURRENT_PROGRESS_COLOR;
186 | }
187 | this.currentProgressColor = currentProgressColor;
188 | }
189 |
190 | public int getCurrentProgressColor() {
191 | return currentProgressColor;
192 | }
193 |
194 | public void setTypeface(Typeface typeface) {
195 | this.mTypeface = typeface;
196 | }
197 |
198 | public void setCirclesWidth(float circlesWidth) {
199 | if (circlesWidth < ProgressDefaults.MIN) {
200 | circlesWidth = ProgressDefaults.CIRCLES_WIDTH;
201 | }
202 | this.circlesWidth = circlesWidth;
203 | }
204 |
205 | public float getCirclesWidth() {
206 | return circlesWidth;
207 | }
208 |
209 | public void setCirclesColor(int circlesColor) {
210 | if (circlesColor < ProgressDefaults.MIN) {
211 | circlesColor = ProgressDefaults.CIRCLES_COLOR;
212 | }
213 | this.circlesColor = circlesColor;
214 | }
215 |
216 | public int getCirclesColor() {
217 | return circlesColor;
218 | }
219 |
220 | public void setTextCrude(float textCrude) {
221 | if (textCrude < ProgressDefaults.MIN) {
222 | textCrude = ProgressDefaults.TEXT_CRUDE;
223 | }
224 | this.textCrude = textCrude;
225 | }
226 |
227 | public float getTextCrude() {
228 | return textCrude;
229 | }
230 |
231 | public void setTextColor(int textColor) {
232 | if (textColor < ProgressDefaults.MIN) {
233 | textColor = ProgressDefaults.TEXT_COLOR;
234 | }
235 | this.textColor = textColor;
236 | }
237 |
238 | public int getTextColor() {
239 | return textColor;
240 | }
241 |
242 | public void setTextSize(float textSize) {
243 | if (textSize < ProgressDefaults.MIN) {
244 | textSize = ProgressDefaults.TEXT_SIZE;
245 | }
246 | this.textSize = textSize;
247 | }
248 | }
249 |
--------------------------------------------------------------------------------