├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── xml │ │ │ └── provider_paths.xml │ │ ├── drawable │ │ │ ├── shape_btn.xml │ │ │ ├── ic_successful.xml │ │ │ ├── ic_fail.xml │ │ │ ├── selector_btn.xml │ │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ │ ├── dialog_edit_text.xml │ │ │ ├── dialog_seek_bar.xml │ │ │ └── activity_main.xml │ │ └── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── flod │ │ └── loadingbutton │ │ └── app │ │ ├── Glide4Engine.java │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── Loadingbutton ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ └── values │ │ │ └── attrs.xml │ │ └── java │ │ └── com │ │ └── flod │ │ └── loadingbutton │ │ ├── CircularProgressDrawable.java │ │ └── LoadingButton.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew ├── README_CN.md └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Loadingbutton/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':Loadingbutton' 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LoadingButton 3 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlodCoding/LoadingButton/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlodCoding/LoadingButton/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Loadingbutton/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlodCoding/LoadingButton/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea 5 | !/.idea/codeStyles 6 | !/.idea/dictionaries 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | .cxx -------------------------------------------------------------------------------- /app/src/main/res/xml/provider_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #1E8AE8 4 | #176EB9 5 | #ffff4444 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jun 09 18:50:17 CST 2019 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_successful.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_fail.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_edit_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selector_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Loadingbutton/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | 6 | 7 | defaultConfig { 8 | minSdkVersion 17 9 | targetSdkVersion 29 10 | versionCode 110 11 | versionName "1.1.0" 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | 26 | compileOnly 'androidx.appcompat:appcompat:1.2.0' 27 | api 'com.github.FlodCoding:DrawableTextView:1.0.6' 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | 17 | 18 | -------------------------------------------------------------------------------- /Loadingbutton/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_seek_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.flod.loadingbutton.app" 7 | minSdkVersion 17 8 | targetSdkVersion 28 9 | versionCode 100 10 | versionName "1.0.0" 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation fileTree(dir: 'libs', include: ['*.jar']) 22 | implementation project(':Loadingbutton') 23 | implementation 'androidx.appcompat:appcompat:1.1.0' 24 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 25 | 26 | implementation 'com.zhihu.android:matisse:0.5.2-beta4' 27 | implementation 'com.github.bumptech.glide:glide:4.9.0' 28 | annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' 29 | } 30 | -------------------------------------------------------------------------------- /Loadingbutton/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/flod/loadingbutton/app/Glide4Engine.java: -------------------------------------------------------------------------------- 1 | package com.flod.loadingbutton.app; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.net.Uri; 6 | import android.widget.ImageView; 7 | 8 | import com.bumptech.glide.Glide; 9 | import com.bumptech.glide.Priority; 10 | import com.bumptech.glide.request.RequestOptions; 11 | import com.zhihu.matisse.engine.ImageEngine; 12 | 13 | public class Glide4Engine implements ImageEngine { 14 | @Override 15 | public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { 16 | Glide.with(context) 17 | .asBitmap() // some .jpeg files are actually gif 18 | .load(uri) 19 | .apply(new RequestOptions() 20 | .override(resize, resize) 21 | .placeholder(placeholder) 22 | .centerCrop()) 23 | .into(imageView); 24 | } 25 | 26 | @Override 27 | public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, 28 | Uri uri) { 29 | Glide.with(context) 30 | .asBitmap() // some .jpeg files are actually gif 31 | .load(uri) 32 | .apply(new RequestOptions() 33 | .override(resize, resize) 34 | .placeholder(placeholder) 35 | .centerCrop()) 36 | .into(imageView); 37 | } 38 | 39 | @Override 40 | public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { 41 | Glide.with(context) 42 | .load(uri) 43 | .apply(new RequestOptions() 44 | .override(resizeX, resizeY) 45 | .priority(Priority.HIGH) 46 | .fitCenter()) 47 | .into(imageView); 48 | } 49 | 50 | @Override 51 | public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { 52 | Glide.with(context) 53 | .asGif() 54 | .load(uri) 55 | .apply(new RequestOptions() 56 | .override(resizeX, resizeY) 57 | .priority(Priority.HIGH) 58 | .fitCenter()) 59 | .into(imageView); 60 | } 61 | 62 | @Override 63 | public boolean supportAnimatedGif() { 64 | return true; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 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 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # LoadingButton [![LoadingButton](https://jitpack.io/v/FlodCoding/LoadingButton.svg)](https://jitpack.io/#FlodCoding/LoadingButton) 2 | 3 | 一个小巧灵活的带加载功能的按钮控件,继承自[DrawableTextView](https://github.com/FlodCoding/DrawableTextView),加载动画来自于[CircularProgressDrawable](https://developer.android.google.cn/reference/android/support/v4/widget/CircularProgressDrawable?hl=en) 4 | 5 | ## 特性 6 | * 支持按钮收缩 7 | * 支持加载完成和失败图标显示 8 | * 可设置加载动画颜色、大小、位置 9 | * 自定义圆角 10 | 11 | 12 | ## 如何导入 13 | 14 | 根目录下的build.gradle 15 | ``` 16 | allprojects { 17 | 18 | repositories { 19 | ... 20 | maven { url 'https://jitpack.io' } 21 | 22 | } 23 | } 24 | ``` 25 | 26 | App目录下的build.gradle 27 | #### 注意!从1.1.0开始与以前的版本有较大的变动,请谨慎升级 28 | ``` 29 | dependencies { 30 | //Androidx 31 | implementation 'com.github.FlodCoding:LoadingButton:1.1.0-alpha01' 32 | 33 | } 34 | ``` 35 | Support-appcompat 停止更新 36 | ~~implementation 'com.github.FlodCoding:LoadingButton:1.0.5-support'~~ 37 | 38 | 39 | 40 | 41 | 42 | ## Demo [点我下载](https://github.com/FlodCoding/LoadingButton/releases/download/1.1.0-alpha01/demo-1.1.0-alpha01.apk) 43 | 44 | ![下载.png](https://upload-images.jianshu.io/upload_images/7565394-f96443d70435d4b3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300) 45 | 46 | ### Demo截图 47 | ![1.gif](https://upload-images.jianshu.io/upload_images/7565394-b799c91e14a8f19a.gif?imageMogr2/auto-orient/strip) 48 | ![2.gif](https://upload-images.jianshu.io/upload_images/7565394-018bbbd27694d3b5.gif?imageMogr2/auto-orient/strip) 49 | ![3.gif](https://upload-images.jianshu.io/upload_images/7565394-88becf790d21d7fc.gif?imageMogr2/auto-orient/strip) 50 | ![4.gif](https://upload-images.jianshu.io/upload_images/7565394-f2ad03c89d715afa.gif?imageMogr2/auto-orient/strip) 51 | 52 | ## 基本用法 53 | 54 | ### XML 55 | ``` 56 | 76 | ``` 77 | ### Code 78 | ``` 79 | 80 | loadingBtn.start(); //开始加载 81 | loadingBtn.complete(true); //加载成功 82 | loadingBtn.complete(false); //加载失败 83 | loadingBtn.cancel(); //加载取消 84 | 85 | loadingBtn.setEnableShrink(true) 86 | .setEnableRestore(true) 87 | .setDisableClickOnLoading(true) 88 | .setShrinkDuration(450) 89 | .setLoadingPosition(DrawableTextView.POSITION.START) 90 | .setSuccessDrawable(R.drawable.ic_successful) 91 | .setFailDrawable(R.drawable.ic_fail) 92 | .setEndDrawableKeepDuration(900) 93 | .setLoadingEndDrawableSize((int) (loadingBtn.getTextSize() * 2)); 94 | 95 | loadingBtn.getLoadingDrawable().setStrokeWidth(loadingBtn.getTextSize() * 0.14f); 96 | loadingBtn.getLoadingDrawable().setColorSchemeColors(loadingBtn.getTextColors().getDefaultColor()); 97 | ``` 98 | 99 | ### 状态回调 100 | start --> onShrinking --> onLoadingStart 101 | complete --> onLoadingStop --> onEndDrawableAppear --> onCompleted --> onRestored 102 | 103 | ``` 104 | public static class OnStatusChangedListener { 105 | 106 | public void onShrinking() {} 107 | 108 | public void onLoadingStart() {} 109 | 110 | public void onLoadingStop() {} 111 | 112 | public void onEndDrawableAppear(boolean isSuccess, EndDrawable endDrawable) {} 113 | 114 | public void onRestoring() {} 115 | 116 | public void onRestored() {} 117 | 118 | public void onCompleted(boolean isSuccess) { } 119 | 120 | public void onCanceled() {} 121 | } 122 | ``` 123 | 124 | ## 属性说明 125 | ### XML 126 | 属性名|类型|默认值|说明 127 | ---|:--:|:---:|---: 128 | enableShrink |boolean |true |开始加载时收缩 129 | disableClickOnLoading |boolean |true |加载时禁用点击 130 | enableRestore |boolean |false |完成时,恢复按钮 131 | radius |dimension |0dp |设置按钮的圆角,**(需要SDK>=21)**
(来自([DrawableTextView](https://github.com/FlodCoding/DrawableTextView)) 132 | shrinkDuration |integer |450ms |收缩动画时间 133 | shrinkShape |enum
(Default,Oval) |Oval |收缩后的形状 **(需要SDK>=21)**
(Default:保持原来的形状,Oval:圆形) 134 | loadingEndDrawableSize |dimension |TextSize \*2 |设置LoadingDrawable和EndDrawable大小 135 | loadingDrawableColor |reference |TextColor |设置Loading的颜色 136 | loadingDrawablePosition |enum
(Start,Top,
End,Bottom) |Start |设置Loading的位置 137 | endSuccessDrawable |reference | null |完成时显示的图标 138 | endFailDrawable |reference | null |失败时显示的图标 139 | endDrawableAppearTime |integer | 300ms |完成或失败图标从无到有的时间 140 | endDrawableDuration |integer | 900ms |完成或失败图标停留的时间 141 | 142 | ### Public Func 143 | 方法名|参数说明|默认值|说明 144 | ---|:--:|:---:|---: 145 | start() |- |- |开始加载 146 | complete(boolean isSuccess) |是否成功 |- |完成加载 147 | cancel()
cancel(boolean withRestoreAnim) |是否执行恢复动画 |true |取消 148 | setEnableShrink(boolean enable) |- |true |设置加载时按钮收缩 149 | setEnableRestore(boolean enable) |- |false |设置完成时按钮恢复(形状和文字) 150 | setRadius(@Px int px)
setRadiusDP(int dp) |Px/Dp |0 |设置按钮的圆角
**(需要SDK>=21)**
(来自([DrawableTextView](https://github.com/FlodCoding/DrawableTextView)) 151 | setShrinkShape(@ShrinkShape int shrinkShape) |Default:保持原来的形状,
Oval:圆形 |Oval |收缩后的形状
**(需要SDK>=21)** 152 | setShrinkDuration(long time) |milliseconds |450ms |收缩动画时间 153 | setLoadingEndDrawableSize(@Px int px) |单位Px |TextSize \*2 |设置LoadingDrawable和EndDrawable大小 154 | setLoadingPosition(@POSITION int position) |Start,Top,End,Bottom |Start |设置Loading的位置 155 | setSuccessDrawable(@DrawableRes int drawableRes)
setSuccessDrawable(Drawable drawable) |- | null |成功时显示的图标 156 | setFailDrawable(@DrawableRes int drawableRes)
setFailDrawable(Drawable drawable) |- | null |失败时显示的图标 157 | setEndDrawableAppearDuration(long time) |milliseconds | 300ms |完成或失败图标从无到有的时间 158 | setEndDrawableKeepDuration(long time) |milliseconds | 900ms |完成或失败图标停留的时间 159 | setOnStatusChangedListener
(OnStatusChangedListener listener)|-|null|按钮的各种状态回调 160 | 161 | ### 常见问题 162 | #### 完成加载时,如何自动恢复到之前按钮的状态? 163 | 设置setEnableRestore(true) 164 | 165 | #### 当setEnableRestore(false)时,又想某个时机恢复原来的按钮的状态,要怎么做? 166 | 执行cancel() 167 | 168 | 169 | ## Demo使用的第三方库 170 | 171 | ### [Matisse](https://github.com/zhihu/Matisse) 172 | 173 | ### [Glide](https://github.com/bumptech/glide) 174 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LoadingButton [![LoadingButton](https://jitpack.io/v/FlodCoding/LoadingButton.svg)](https://jitpack.io/#FlodCoding/LoadingButton) 2 | 3 | A small and flexible button control with loading function,Extends from [DrawableTextView](https://github.com/FlodCoding/DrawableTextView),Loading animation comes from [CircularProgressDrawable](https://developer.android.google.cn/reference/android/support/v4/widget/CircularProgressDrawable?hl=en) 4 | 5 | ## Feature 6 | * Support button shrink 7 | * Support loading completion and failure icon 8 | * Can custom loading drawable color, size, position and loading button shape 9 | * Custom radius 10 | 11 | 12 | ## How to install [中文说明](https://github.com/FlodCoding/LoadingButton/blob/master/README_CN.md) 13 | 14 | root directory build.gradle 15 | ``` 16 | allprojects { 17 | 18 | repositories { 19 | ... 20 | maven { url 'https://jitpack.io' } 21 | 22 | } 23 | } 24 | ``` 25 | 26 | App module build.gradle 27 | 28 | ``` 29 | dependencies { 30 | //Androidx 31 | implementation 'com.github.FlodCoding:LoadingButton:1.1.0-alpha01' 32 | 33 | } 34 | ``` 35 | Support-appcompat stop update 36 | ~~implementation 'com.github.FlodCoding:LoadingButton:1.0.5-support'~~ 37 | 38 | 39 | 40 | 41 | 42 | ## Demo [Click me to download the apk](https://github.com/FlodCoding/LoadingButton/releases/download/1.1.0-alpha01/demo-1.1.0-alpha01.apk) 43 | 44 | ![下载.png](https://upload-images.jianshu.io/upload_images/7565394-f96443d70435d4b3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300) 45 | 46 | ### Demo screenshot 47 | ![1.gif](https://upload-images.jianshu.io/upload_images/7565394-b799c91e14a8f19a.gif?imageMogr2/auto-orient/strip) 48 | ![2.gif](https://upload-images.jianshu.io/upload_images/7565394-018bbbd27694d3b5.gif?imageMogr2/auto-orient/strip) 49 | ![3.gif](https://upload-images.jianshu.io/upload_images/7565394-88becf790d21d7fc.gif?imageMogr2/auto-orient/strip) 50 | ![4.gif](https://upload-images.jianshu.io/upload_images/7565394-f2ad03c89d715afa.gif?imageMogr2/auto-orient/strip) 51 | 52 | ## Basic usage 53 | 54 | ### XML 55 | ``` 56 | 76 | ``` 77 | ### Code 78 | ``` 79 | 80 | loadingBtn.start(); //Start loading 81 | loadingBtn.complete(true); //Success 82 | loadingBtn.complete(false); //failed 83 | loadingBtn.cancel(); //Cancel loading 84 | 85 | loadingBtn.setEnableShrink(true) 86 | .setEnableRestore(true) 87 | .setDisableClickOnLoading(true) 88 | .setShrinkDuration(450) 89 | .setLoadingPosition(DrawableTextView.POSITION.START) 90 | .setSuccessDrawable(R.drawable.ic_successful) 91 | .setFailDrawable(R.drawable.ic_fail) 92 | .setEndDrawableKeepDuration(900) 93 | .setLoadingEndDrawableSize((int) (loadingBtn.getTextSize() * 2)); 94 | 95 | loadingBtn.getLoadingDrawable().setStrokeWidth(loadingBtn.getTextSize() * 0.14f); 96 | loadingBtn.getLoadingDrawable().setColorSchemeColors(loadingBtn.getTextColors().getDefaultColor()); 97 | 98 | ``` 99 | 100 | ### State callback 101 | start --> onShrinking --> onLoadingStart 102 | complete --> onLoadingStop --> onEndDrawableAppear --> onCompleted --> onRestored 103 | 104 | ``` 105 | public static class OnStatusChangedListener { 106 | 107 | public void onShrinking() {} 108 | 109 | public void onLoadingStart() {} 110 | 111 | public void onLoadingStop() {} 112 | 113 | public void onEndDrawableAppear(boolean isSuccess, EndDrawable endDrawable) {} 114 | 115 | public void onRestoring() {} 116 | 117 | public void onRestored() {} 118 | 119 | public void onCompleted(boolean isSuccess) { } 120 | 121 | public void onCanceled() {} 122 | } 123 | ``` 124 | 125 | ## Attribute 126 | ### XML 127 | Attribute name|type|Default value|Description 128 | ---|:--:|:---:|---: 129 | enableShrink |boolean |true |Shrink when begin loading 130 | disableClickOnLoading |boolean |true |Disable click on loading 131 | enableRestore |boolean |false |When finished, restore button(shape and text) 132 | radius |dimension |0dp |Set the rounded corners of the button,**(need SDK>=21)**
(from([DrawableTextView](https://github.com/FlodCoding/DrawableTextView)) 133 | shrinkDuration |integer |450ms |Shrink animation duration 134 | shrinkShape |enum
(Default,Oval) |Oval |Shape after shrinking **(need SDK>=21)**
(Default:Keep the original shape,Oval:Round shape) 135 | loadingEndDrawableSize |dimension |TextSize \*2 |Set the size of LoadingDrawable and EndDrawable 136 | loadingDrawableColor |reference |TextColor |Set loading color 137 | loadingDrawablePosition |enum
(Start,Top,
End,Bottom) |Start |Set the loading drawable position 138 | endSuccessDrawable |reference | null |Successful drawable 139 | endFailDrawable |reference | null |failed drawable 140 | endDrawableAppearTime |integer | 300ms |Time for completion or failure icon to emerge from nothing 141 | endDrawableDuration |integer | 900ms |endDrawable keeping time 142 | 143 | ### Public Func 144 | Method name|Parameter description|default value|Description 145 | ---|:--:|:---:|---: 146 | start() |- |- |Start loading 147 | complete(boolean isSuccess) |whether succeed |- |Complete loading 148 | cancel()
cancel(boolean withRestoreAnim) |Whether to perform restore animation |true |Cancel loading 149 | setEnableShrink(boolean enable) |- |true |Shrink when begin loading 150 | setEnableRestore(boolean enable) |- |false |When finished, restore button(shape and text) 151 | setRadius(@Px int px)
setRadiusDP(int dp) |Px/Dp |0 |Set the rounded corners of the button,**(need SDK>=21)**
(from([DrawableTextView](https://github.com/FlodCoding/DrawableTextView)) 152 | setShrinkShape(@ShrinkShape int shrinkShape) |Default:Keep the original shape,Oval:Round shape |Oval |Shape after shrinking **(need SDK>=21)** 153 | setShrinkDuration(long time) |milliseconds |450ms |Shrink animation duration 154 | setLoadingEndDrawableSize(@Px int px) |Px |TextSize \*2 |Set the size of LoadingDrawable and EndDrawable 155 | setLoadingPosition(@POSITION int position) |Start,Top,End,Bottom |Start |Set the loading drawable position 156 | setSuccessDrawable(@DrawableRes int drawableRes)
setSuccessDrawable(Drawable drawable) |- | null |Successful drawable 157 | setFailDrawable(@DrawableRes int drawableRes)
setFailDrawable(Drawable drawable) |- | null |failed drawable 158 | setEndDrawableAppearDuration(long time) |milliseconds | 300ms |Time for completion or failure icon to emerge from nothing 159 | setEndDrawableKeepDuration(long time) |milliseconds | 900ms |endDrawable keeping time 160 | setOnStatusChangedListener
(OnStatusChangedListener listener)|-|null|State callbacks of buttons 161 | 162 | 163 | ## Third-party libraries used by Demo 164 | 165 | ### [Matisse](https://github.com/zhihu/Matisse) 166 | 167 | ### [Glide](https://github.com/bumptech/glide) 168 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 36 | 37 | 43 | 44 |