├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── markdown-navigator.xml
├── markdown-navigator
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jiajie
│ │ └── loadingview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jiajie
│ │ │ └── loadingview
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── aa_dialog_bg.xml
│ │ ├── loading.gif
│ │ └── shadow.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── jiajie
│ └── loadingview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── load
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── jiajie
│ │ └── load
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── jiajie
│ │ │ └── load
│ │ │ ├── LoadingDialog.java
│ │ │ ├── LoadingView.java
│ │ │ ├── ShapeLoadingView.java
│ │ │ └── dialog_loading.xml
│ └── res
│ │ ├── drawable
│ │ ├── aa_dialog_bg.xml
│ │ └── shadow.xml
│ │ ├── layout
│ │ ├── dialog_loading.xml
│ │ ├── layout_dialog.xml
│ │ └── load_view.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── jiajie
│ └── load
│ └── ExampleUnitTest.java
└── 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/markdown-navigator.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 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | $USER_HOME$/.subversion
48 |
49 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Android 网络加载以及耗时操作的指示器动画。
2 |
3 | 
4 |
5 | gradle 添加依赖 compile 'cn.jiajie.loading:load:1.0.3'
6 |
7 | maven :
8 |
9 | cn.jiajie.loading
10 | load
11 | 1.0.3
12 | pom
13 |
14 |
15 |
16 | 简单的使用
17 |
18 | new LoadingDialog.Buidler(context).loadtext("needed String").build().show()
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "com.jiajie.loadingview"
8 | minSdkVersion 21
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.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(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'androidx.appcompat:appcompat:1.0.0'
28 | compile 'androidx.constraintlayout:constraintlayout:1.1.3'
29 | testCompile 'junit:junit:4.12'
30 | compile project(':load')
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jiajie/Library/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/jiajie/loadingview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.loadingview;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.jiajie.loadingview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/jiajie/loadingview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.loadingview;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import com.jiajie.load.LoadingDialog;
8 |
9 | public class MainActivity extends Activity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 |
16 | new LoadingDialog.Builder(this)
17 | .loadText("加载中")
18 | .build()
19 | .show();
20 |
21 |
22 | }
23 | public void show(View view){
24 | new LoadingDialog.Builder(this)
25 | .loadText("加载中")
26 | .build()
27 | .show();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/aa_dialog_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/loading.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/drawable/loading.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
8 | //dialog
9 | #aa72d572
10 | #aa738ffe
11 | #aae84e40
12 | #00000000
13 | #25808080
14 | #f5f5f5
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LoadingView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/test/java/com/jiajie/loadingview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.loadingview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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 | maven {
7 | url 'https://maven.google.com/'
8 | name 'Google'
9 | }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.2.0'
13 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | jcenter()
23 | maven {
24 | url 'https://maven.google.com/'
25 | name 'Google'
26 | }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/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 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jiezongnewstar/AndroidLoadingView/24991a151bbadfe3d971dad93677d3fb829f543a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 09 22:18:43 IST 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-4.6-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 |
--------------------------------------------------------------------------------
/load/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/load/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.3"
7 | defaultConfig {
8 | minSdkVersion 21
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "androidx.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('androidx.test.espresso:espresso-core:3.1.0', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'androidx.appcompat:appcompat:1.0.0'
28 | compile "com.nineoldandroids:library:2.4.0"
29 |
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
33 | //jcenter 配置
34 | apply plugin: 'com.github.dcendents.android-maven'
35 | apply plugin: 'com.jfrog.bintray'
36 |
37 | //项目主页
38 | def siteUrl = 'https://github.com/jiezongnewstar/AndroidLoadingView' // project homepage
39 | //项目的版本控制地址
40 | def gitUrl = 'https://github.com/jiezongnewstar/AndroidLoadingView.git' // project git
41 |
42 | //发布到组织名称名字,必须填写
43 | group = "cn.jiajie.loading"
44 | //发布到JCenter上的项目名字,必须填写
45 | def libName = "LoadingView"
46 | // 版本号,下次更新是只需要更改版本号即可
47 | version = "1.0.3"
48 | /** 上面配置后上传至jcenter后的编译路径是这样的: compile 'cn.bluemobi.dylan:sqlitelibrary:1.0' **/
49 |
50 | //生成源文件
51 | task sourcesJar(type: Jar) {
52 | from android.sourceSets.main.java.srcDirs
53 | classifier = 'sources'
54 | }
55 | //生成文档
56 | task javadoc(type: Javadoc) {
57 | source = android.sourceSets.main.java.srcDirs
58 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
59 | options.encoding "UTF-8"
60 | options.charSet 'UTF-8'
61 | options.author true
62 | options.version true
63 | options.links "https://github.com/jiezongnewstar/AndroidLoadingView/tree/master/mylibrary/docs/javadoc"
64 | failOnError false
65 | }
66 |
67 | //文档打包成jar
68 | task javadocJar(type: Jar, dependsOn: javadoc) {
69 | classifier = 'javadoc'
70 | from javadoc.destinationDir
71 | }
72 | //拷贝javadoc文件
73 | task copyDoc(type: Copy) {
74 | from "${buildDir}/docs/"
75 | into "docs"
76 | }
77 |
78 | //上传到jcenter所需要的源码文件
79 | artifacts {
80 | archives javadocJar
81 | archives sourcesJar
82 | }
83 |
84 | // 配置maven库,生成POM.xml文件
85 | install {
86 | repositories.mavenInstaller {
87 | // This generates POM.xml with proper parameters
88 | pom {
89 | project {
90 | packaging 'aar'
91 | name 'This is an Android LoadingView to make waiting more interesting'
92 | url siteUrl
93 | licenses {
94 | license {
95 | name 'This is a LoadingView info'
96 | url 'https://github.com/jiezongnewstar/AndroidLoadingView'
97 | }
98 | }
99 | developers {
100 | developer {
101 | id 'ibossjiajie'
102 | name 'jiajie'
103 | email 'ibossjia@gmail.com'
104 | }
105 | }
106 | scm {
107 | connection gitUrl
108 | developerConnection gitUrl
109 | url siteUrl
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
116 | //上传到jcenter
117 | Properties properties = new Properties()
118 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
119 | bintray {
120 | user = properties.getProperty("bintray.user") //读取 local.properties 文件里面的 bintray.user
121 | key = properties.getProperty("bintray.apikey") //读取 local.properties 文件里面的 bintray.apikey
122 | configurations = ['archives']
123 | pkg {
124 | repo = "LoadingView"
125 | name = libName //发布到JCenter上的项目名字,必须填写
126 | desc = 'This is an Android LoadingView to make waiting more interesting' //项目描述
127 | websiteUrl = siteUrl
128 | vcsUrl = gitUrl
129 | licenses = ["Apache-2.0"]
130 | publish = true
131 | }
132 | }
--------------------------------------------------------------------------------
/load/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jiajie/Library/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/load/src/androidTest/java/com/jiajie/load/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.load;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.jiajie.load.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/load/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/load/src/main/java/com/jiajie/load/LoadingDialog.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.load;
2 | import android.app.Dialog;
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 |
9 | /**
10 | * ┏┓ ┏┓+ +
11 | * ┏┛┻━━━┛┻┓ + +
12 | * ┃ ┃
13 | * ┃ ━ ┃ ++ + + +
14 | * ████━████ ┃+
15 | * ┃ ┃ +
16 | * ┃ ┻ ┃
17 | * iBoosJie. ┃ ┃ + +
18 | * ┗━┓ ┏━┛
19 | * ┃ ┃
20 | * ┃ ┃ + + + +
21 | * ┃ ┃ Code is far away from bug with the animal protecting
22 | * ┃ ┃ + 神兽保佑,代码无bug
23 | * ┃ ┃
24 | * ┃ ┃ +
25 | * ┃ ┗━━━┓ + +
26 | * ┃ ┣┓
27 | * ┃ ┏┛
28 | * ┗┓┓┏━┳┓┏┛ + + + +
29 | * ┃┫┫ ┃┫┫
30 | * ┗┻┛ ┗┻┛+ + + +
31 | * 创建人:贾杰
32 | * 创建日期: 2017/6/19
33 | * 说明:
34 | * 修改:
35 | */
36 | public class LoadingDialog extends Dialog{
37 |
38 | private LoadingView mLoadingView;
39 |
40 | private Builder mBuilder;
41 |
42 | public LoadingDialog(Builder builder) {
43 | super(builder.mContext, R.style.custom_dialog);
44 | mBuilder = builder;
45 | setCancelable(mBuilder.mCancelable);
46 | setCanceledOnTouchOutside(mBuilder.mCanceledOnTouchOutside);
47 | }
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 | setContentView(R.layout.layout_dialog);
53 |
54 | mLoadingView = (LoadingView) findViewById(R.id.loadView);
55 |
56 | mLoadingView.setDelay(mBuilder.mDelay);
57 | mLoadingView.setLoadingText(mBuilder.mLoadText);
58 |
59 | setOnDismissListener(new OnDismissListener() {
60 | @Override
61 | public void onDismiss(DialogInterface dialog) {
62 | mLoadingView.setVisibility(View.GONE);
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | public void show() {
69 | super.show();
70 | mLoadingView.setVisibility(View.VISIBLE);
71 | }
72 |
73 | public Builder getBuilder() {
74 | return mBuilder;
75 | }
76 |
77 | public static class Builder{
78 |
79 | private Context mContext;
80 |
81 | private int mDelay = 80;
82 |
83 | private CharSequence mLoadText;
84 |
85 | private boolean mCancelable = true;
86 |
87 | private boolean mCanceledOnTouchOutside = true;
88 |
89 | public Builder(Context context) {
90 | mContext = context;
91 | }
92 |
93 | public Builder delay(int delay) {
94 | mDelay = delay;
95 | return this;
96 | }
97 |
98 | public Builder loadText(CharSequence loadText) {
99 | mLoadText = loadText;
100 | return this;
101 | }
102 |
103 | public Builder loadText(int resId) {
104 | mLoadText = mContext.getString(resId);
105 | return this;
106 | }
107 |
108 | public Builder cancelable(boolean cancelable) {
109 | mCancelable = cancelable;
110 | mCanceledOnTouchOutside = cancelable;
111 | return this;
112 | }
113 |
114 | public Builder canceledOnTouchOutside(boolean canceledOnTouchOutside) {
115 | mCanceledOnTouchOutside = canceledOnTouchOutside;
116 | return this;
117 | }
118 |
119 | public LoadingDialog build(){
120 | return new LoadingDialog(this);
121 | }
122 |
123 | public LoadingDialog show(){
124 | LoadingDialog dialog = build();
125 | dialog.show();
126 | return dialog;
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/load/src/main/java/com/jiajie/load/LoadingView.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.load;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.os.Build;
7 | import android.text.TextUtils;
8 | import android.util.AttributeSet;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.animation.AccelerateInterpolator;
12 | import android.view.animation.DecelerateInterpolator;
13 | import android.widget.ImageView;
14 | import android.widget.LinearLayout;
15 | import android.widget.TextView;
16 |
17 | import com.nineoldandroids.view.ViewHelper;
18 |
19 |
20 | /**
21 | * ┏┓ ┏┓+ +
22 | * ┏┛┻━━━┛┻┓ + +
23 | * ┃ ┃
24 | * ┃ ━ ┃ ++ + + +
25 | * ████━████ ┃+
26 | * ┃ ┃ +
27 | * ┃ ┻ ┃
28 | * iBoosJie. ┃ ┃ + +
29 | * ┗━┓ ┏━┛
30 | * ┃ ┃
31 | * ┃ ┃ + + + +
32 | * ┃ ┃ Code is far away from bug with the animal protecting
33 | * ┃ ┃ + 神兽保佑,代码无bug
34 | * ┃ ┃
35 | * ┃ ┃ +
36 | * ┃ ┗━━━┓ + +
37 | * ┃ ┣┓
38 | * ┃ ┏┛
39 | * ┗┓┓┏━┳┓┏┛ + + + +
40 | * ┃┫┫ ┃┫┫
41 | * ┗┻┛ ┗┻┛+ + + +
42 | * 创建人:贾杰
43 | * 创建日期: 2017/6/19
44 | * 说明:加载界面
45 | * 修改:
46 | */
47 | public class LoadingView extends LinearLayout {
48 |
49 | private static final int ANIMATION_DURATION = 500;
50 |
51 | private static final float FACTOR = 1.2f;
52 |
53 | private static float mDistance = 200;
54 |
55 | private ShapeLoadingView mShapeLoadingView;
56 |
57 | private ImageView mIndicationIm;
58 |
59 | private TextView mLoadTextView;
60 | private int mTextAppearance;
61 |
62 | private String mLoadText;
63 | private com.nineoldandroids.animation.AnimatorSet mUpAnimatorSet;
64 | private com.nineoldandroids.animation.AnimatorSet mDownAnimatorSet;
65 |
66 | private boolean mStopped = false;
67 |
68 | private int mDelay;
69 |
70 | public LoadingView(Context context) {
71 | super(context);
72 | init(context, null);
73 | }
74 |
75 | public LoadingView(Context context, AttributeSet attrs) {
76 | super(context, attrs);
77 | init(context, attrs);
78 |
79 | }
80 |
81 |
82 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
83 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
84 | super(context, attrs, defStyleAttr);
85 | init(context, attrs);
86 | }
87 |
88 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
89 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
90 | super(context, attrs, defStyleAttr, defStyleRes);
91 | init(context, attrs);
92 | }
93 |
94 | private void init(Context context, AttributeSet attrs) {
95 |
96 | setOrientation(VERTICAL);
97 | mDistance = dip2px(context, 54f);
98 | LayoutInflater.from(context).inflate(R.layout.load_view, this, true);
99 | mShapeLoadingView = (ShapeLoadingView) findViewById(R.id.shapeLoadingView);
100 | mIndicationIm = (ImageView) findViewById(R.id.indication);
101 | mLoadTextView = (TextView) findViewById(R.id.promptTV);
102 | ViewHelper.setScaleX(mIndicationIm, 0.2f);
103 |
104 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LoadingView);
105 | String loadText = typedArray.getString(R.styleable.LoadingView_loadingText);
106 | int textAppearance = typedArray.getResourceId(R.styleable.LoadingView_loadingText, -1);
107 | mDelay = typedArray.getInteger(R.styleable.LoadingView_delay, 80);
108 | typedArray.recycle();
109 |
110 | if (textAppearance != -1) {
111 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
112 | mLoadTextView.setTextAppearance(textAppearance);
113 | } else {
114 | mLoadTextView.setTextAppearance(getContext(), textAppearance);
115 | }
116 | }
117 | setLoadingText(loadText);
118 | }
119 |
120 | private int dip2px(Context context, float dipValue) {
121 | final float scale = context.getResources().getDisplayMetrics().density;
122 | return (int) (dipValue * scale + 0.5f);
123 | }
124 |
125 |
126 | @Override
127 | protected void onFinishInflate() {
128 | super.onFinishInflate();
129 | if (getVisibility() == VISIBLE) {
130 | startLoading(mDelay);
131 | }
132 | }
133 |
134 | private Runnable mFreeFallRunnable = new Runnable() {
135 | @Override
136 | public void run() {
137 | ViewHelper.setRotation(mShapeLoadingView, 180f);
138 | ViewHelper.setTranslationY(mShapeLoadingView, 0f);
139 | ViewHelper.setScaleX(mIndicationIm, 0.2f);
140 | mStopped = false;
141 | freeFall();
142 | }
143 | };
144 |
145 | private void startLoading(long delay) {
146 | if (mDownAnimatorSet != null && mDownAnimatorSet.isRunning()) {
147 | return;
148 | }
149 | this.removeCallbacks(mFreeFallRunnable);
150 | if (delay > 0) {
151 | this.postDelayed(mFreeFallRunnable, delay);
152 | } else {
153 | this.post(mFreeFallRunnable);
154 | }
155 | }
156 |
157 | @Override
158 | protected void onDetachedFromWindow() {
159 | super.onDetachedFromWindow();
160 | stopLoading();
161 | }
162 |
163 | private void stopLoading() {
164 | mStopped = true;
165 | if (mUpAnimatorSet != null) {
166 | if (mUpAnimatorSet.isRunning()) {
167 | mUpAnimatorSet.cancel();
168 | }
169 | mUpAnimatorSet.removeAllListeners();
170 | for (com.nineoldandroids.animation.Animator animator : mUpAnimatorSet.getChildAnimations()) {
171 | animator.removeAllListeners();
172 | }
173 | mUpAnimatorSet = null;
174 | }
175 | if (mDownAnimatorSet != null) {
176 | if (mDownAnimatorSet.isRunning()) {
177 | mDownAnimatorSet.cancel();
178 | }
179 | mDownAnimatorSet.removeAllListeners();
180 | for (com.nineoldandroids.animation.Animator animator : mDownAnimatorSet.getChildAnimations()) {
181 | animator.removeAllListeners();
182 | }
183 | mDownAnimatorSet = null;
184 | }
185 | this.removeCallbacks(mFreeFallRunnable);
186 | }
187 |
188 | @Override
189 | public void setVisibility(int visibility) {
190 | this.setVisibility(visibility, mDelay);
191 | }
192 |
193 | public void setVisibility(int visibility, int delay) {
194 | super.setVisibility(visibility);
195 | if (visibility == View.VISIBLE) {
196 | startLoading(delay);
197 | } else {
198 | stopLoading();
199 | }
200 | }
201 |
202 | public void setDelay(int delay) {
203 | mDelay = delay;
204 | }
205 |
206 | public int getDelay() {
207 | return mDelay;
208 | }
209 |
210 | public void setLoadingText(CharSequence loadingText) {
211 | if (TextUtils.isEmpty(loadingText)) {
212 | mLoadTextView.setVisibility(GONE);
213 | } else {
214 | mLoadTextView.setVisibility(VISIBLE);
215 | }
216 |
217 | mLoadTextView.setText(loadingText);
218 | }
219 |
220 | public CharSequence getLoadingText(){
221 | return mLoadTextView.getText();
222 | }
223 |
224 | /**
225 | * 上抛
226 | */
227 | public void upThrow() {
228 |
229 | if (mUpAnimatorSet == null) {
230 | com.nineoldandroids.animation.ObjectAnimator objectAnimator = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mShapeLoadingView, "translationY", mDistance, 0);
231 | com.nineoldandroids.animation.ObjectAnimator scaleIndication = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mIndicationIm, "scaleX", 1f, 0.2f);
232 |
233 | com.nineoldandroids.animation.ObjectAnimator objectAnimator1 = null;
234 | switch (mShapeLoadingView.getShape()) {
235 | case SHAPE_RECT:
236 |
237 | objectAnimator1 = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
238 |
239 | break;
240 | case SHAPE_CIRCLE:
241 | objectAnimator1 = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
242 |
243 | break;
244 | case SHAPE_TRIANGLE:
245 |
246 | objectAnimator1 = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
247 |
248 | break;
249 | }
250 |
251 | mUpAnimatorSet = new com.nineoldandroids.animation.AnimatorSet();
252 | mUpAnimatorSet.playTogether(objectAnimator, objectAnimator1, scaleIndication);
253 |
254 | mUpAnimatorSet.setDuration(ANIMATION_DURATION);
255 | mUpAnimatorSet.setInterpolator(new DecelerateInterpolator(FACTOR));
256 |
257 | mUpAnimatorSet.addListener(new com.nineoldandroids.animation.Animator.AnimatorListener() {
258 | @Override
259 | public void onAnimationStart(com.nineoldandroids.animation.Animator animation) {
260 |
261 | }
262 |
263 | @Override
264 | public void onAnimationEnd(com.nineoldandroids.animation.Animator animation) {
265 | if (!mStopped) {
266 | freeFall();
267 | }
268 |
269 | }
270 |
271 | @Override
272 | public void onAnimationCancel(com.nineoldandroids.animation.Animator animation) {
273 |
274 | }
275 |
276 | @Override
277 | public void onAnimationRepeat(com.nineoldandroids.animation.Animator animation) {
278 |
279 | }
280 | });
281 | }
282 | mUpAnimatorSet.start();
283 |
284 |
285 | }
286 |
287 | /**
288 | * 下落
289 | */
290 | public void freeFall() {
291 |
292 | if (mDownAnimatorSet == null) {
293 | com.nineoldandroids.animation.ObjectAnimator objectAnimator = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mShapeLoadingView, "translationY", 0, mDistance);
294 | com.nineoldandroids.animation.ObjectAnimator scaleIndication = com.nineoldandroids.animation.ObjectAnimator.ofFloat(mIndicationIm, "scaleX", 0.2f, 1f);
295 |
296 | mDownAnimatorSet = new com.nineoldandroids.animation.AnimatorSet();
297 | mDownAnimatorSet.playTogether(objectAnimator, scaleIndication);
298 | mDownAnimatorSet.setDuration(ANIMATION_DURATION);
299 | mDownAnimatorSet.setInterpolator(new AccelerateInterpolator(FACTOR));
300 | mDownAnimatorSet.addListener(new com.nineoldandroids.animation.Animator.AnimatorListener() {
301 | @Override
302 | public void onAnimationStart(com.nineoldandroids.animation.Animator animation) {
303 |
304 | }
305 |
306 | @Override
307 | public void onAnimationEnd(com.nineoldandroids.animation.Animator animation) {
308 | if (!mStopped) {
309 | mShapeLoadingView.changeShape();
310 | upThrow();
311 | }
312 | }
313 |
314 | @Override
315 | public void onAnimationCancel(com.nineoldandroids.animation.Animator animation) {
316 |
317 | }
318 |
319 | @Override
320 | public void onAnimationRepeat(com.nineoldandroids.animation.Animator animation) {
321 |
322 | }
323 | });
324 | }
325 | mDownAnimatorSet.start();
326 |
327 |
328 | }
329 |
330 | }
331 |
--------------------------------------------------------------------------------
/load/src/main/java/com/jiajie/load/ShapeLoadingView.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.load;
2 |
3 | import android.animation.ArgbEvaluator;
4 | import android.annotation.TargetApi;
5 | import android.content.Context;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.os.Build;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 |
13 | /**
14 | * ┏┓ ┏┓+ +
15 | * ┏┛┻━━━┛┻┓ + +
16 | * ┃ ┃
17 | * ┃ ━ ┃ ++ + + +
18 | * ████━████ ┃+
19 | * ┃ ┃ +
20 | * ┃ ┻ ┃
21 | * iBoosJie. ┃ ┃ + +
22 | * ┗━┓ ┏━┛
23 | * ┃ ┃
24 | * ┃ ┃ + + + +
25 | * ┃ ┃ Code is far away from bug with the animal protecting
26 | * ┃ ┃ + 神兽保佑,代码无bug
27 | * ┃ ┃
28 | * ┃ ┃ +
29 | * ┃ ┗━━━┓ + +
30 | * ┃ ┣┓
31 | * ┃ ┏┛
32 | * ┗┓┓┏━┳┓┏┛ + + + +
33 | * ┃┫┫ ┃┫┫
34 | * ┗┻┛ ┗┻┛+ + + +
35 | * 创建人:贾杰
36 | * 创建日期: 2017/6/19
37 | * 说明:
38 | * 修改:
39 | */
40 | public class ShapeLoadingView extends View {
41 | /**
42 | * 用赛贝尔曲线画圆
43 | */
44 | private static final float mMagicNumber = 0.55228475f;
45 | private static final float genhao3 = 1.7320508075689f;
46 | private static final float mTriangle2Circle =0.25555555f;
47 |
48 | private Shape mShape = Shape.SHAPE_CIRCLE;
49 |
50 | private ArgbEvaluator mArgbEvaluator=new ArgbEvaluator();
51 |
52 | private int mTriangleColor ;
53 | private int mCircleColor ;
54 | private int mRectColor ;
55 |
56 |
57 | public ShapeLoadingView(Context context) {
58 | super(context);
59 | init(context);
60 | }
61 |
62 | public ShapeLoadingView(Context context, AttributeSet attrs) {
63 | super(context, attrs);
64 | init(context);
65 | }
66 |
67 | public ShapeLoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
68 | super(context, attrs, defStyleAttr);
69 | init(context);
70 | }
71 |
72 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
73 | public ShapeLoadingView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
74 | super(context, attrs, defStyleAttr, defStyleRes);
75 | init(context);
76 | }
77 |
78 | private void init(Context context) {
79 | mTriangleColor = getColor(context, R.color.triangle);
80 | mCircleColor =getColor(context, R.color.circle);
81 | mRectColor = getColor(context, R.color.rect);
82 | mPaint = new Paint();
83 | mPaint.setColor(mTriangleColor);
84 | mPaint.setAntiAlias(true);
85 | mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
86 |
87 | }
88 |
89 | public boolean mIsLoading = false;
90 | private Paint mPaint;
91 | private float mControlX = 0;
92 | private float mControlY = 0;
93 | private float mAnimPercent;
94 |
95 |
96 | @Override
97 | protected void onDraw(Canvas canvas) {
98 | super.onDraw(canvas);
99 |
100 | if(getVisibility()==GONE){
101 | return;
102 | }
103 | // FIXME: 15/6/15 动画待优化
104 | switch (mShape) {
105 | case SHAPE_TRIANGLE:
106 |
107 | if (mIsLoading) {
108 | mAnimPercent += 0.1611113;
109 | int color= (int) mArgbEvaluator.evaluate(mAnimPercent,mTriangleColor,mCircleColor);
110 | mPaint.setColor(color);
111 | // triangle to circle
112 | Path path = new Path();
113 | path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));
114 |
115 | if (mAnimPercent >= 1) {
116 | mShape = Shape.SHAPE_CIRCLE;
117 | mIsLoading = false;
118 | mAnimPercent=1;
119 | }
120 | float controlX = mControlX - relativeXFromView(mAnimPercent* mTriangle2Circle)
121 | * genhao3;
122 | float controlY = mControlY - relativeYFromView(mAnimPercent* mTriangle2Circle);
123 | path.quadTo(relativeXFromView(1) - controlX, controlY, relativeXFromView(0.5f + genhao3 / 4), relativeYFromView(0.75f));
124 | path.quadTo(relativeXFromView(0.5f), relativeYFromView(0.75f + 2 * mAnimPercent* mTriangle2Circle), relativeXFromView(0.5f - genhao3 / 4), relativeYFromView(0.75f));
125 | path.quadTo(controlX, controlY, relativeXFromView(0.5f), relativeYFromView(0f));
126 | path.close();
127 | canvas.drawPath(path, mPaint);
128 |
129 | invalidate();
130 |
131 | } else {
132 | Path path = new Path();
133 | mPaint.setColor(mTriangleColor);
134 | path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));
135 | path.lineTo(relativeXFromView(1), relativeYFromView(genhao3 / 2f));
136 | path.lineTo(relativeXFromView(0), relativeYFromView(genhao3/2f));
137 | mControlX = relativeXFromView(0.5f - genhao3 / 8.0f);
138 | mControlY = relativeYFromView(3 / 8.0f);
139 | mAnimPercent = 0;
140 | path.close();
141 | canvas.drawPath(path, mPaint);
142 |
143 | }
144 | break;
145 | case SHAPE_CIRCLE:
146 |
147 |
148 | if (mIsLoading) {
149 | float magicNumber = mMagicNumber + mAnimPercent;
150 | mAnimPercent += 0.12;
151 | if (magicNumber + mAnimPercent >= 1.9f) {
152 | mShape = Shape.SHAPE_RECT;
153 | mIsLoading = false;
154 | }
155 | int color= (int) mArgbEvaluator.evaluate(mAnimPercent,mCircleColor,mRectColor);
156 | mPaint.setColor(color);
157 |
158 | Path path = new Path();
159 |
160 | path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));
161 | path.cubicTo(relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(0f),
162 | relativeXFromView(1), relativeYFromView(0.5f - magicNumber / 2),
163 | relativeXFromView(1f), relativeYFromView(0.5f));
164 | path.cubicTo(
165 | relativeXFromView(1), relativeXFromView(0.5f + magicNumber / 2),
166 | relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(1f),
167 | relativeXFromView(0.5f), relativeYFromView(1f));
168 | path.cubicTo(relativeXFromView(0.5f - magicNumber / 2), relativeXFromView(1f),
169 | relativeXFromView(0), relativeYFromView(0.5f + magicNumber / 2),
170 | relativeXFromView(0f), relativeYFromView(0.5f));
171 | path.cubicTo(relativeXFromView(0f), relativeXFromView(0.5f - magicNumber / 2),
172 | relativeXFromView(0.5f - magicNumber / 2), relativeYFromView(0),
173 | relativeXFromView(0.5f), relativeYFromView(0f));
174 |
175 |
176 | path.close();
177 | canvas.drawPath(path, mPaint);
178 |
179 |
180 | invalidate();
181 | } else {
182 |
183 | mPaint.setColor(mCircleColor);
184 | Path path = new Path();
185 |
186 | float magicNumber = mMagicNumber;
187 | path.moveTo(relativeXFromView(0.5f), relativeYFromView(0f));
188 | path.cubicTo(relativeXFromView(0.5f + magicNumber / 2), 0,
189 | relativeXFromView(1), relativeYFromView(magicNumber / 2),
190 | relativeXFromView(1f), relativeYFromView(0.5f));
191 | path.cubicTo(
192 | relativeXFromView(1), relativeXFromView(0.5f + magicNumber / 2),
193 | relativeXFromView(0.5f + magicNumber / 2), relativeYFromView(1f),
194 | relativeXFromView(0.5f), relativeYFromView(1f));
195 | path.cubicTo(relativeXFromView(0.5f - magicNumber / 2), relativeXFromView(1f),
196 | relativeXFromView(0), relativeYFromView(0.5f + magicNumber / 2),
197 | relativeXFromView(0f), relativeYFromView(0.5f));
198 | path.cubicTo(relativeXFromView(0f), relativeXFromView(0.5f - magicNumber / 2),
199 | relativeXFromView(0.5f - magicNumber / 2), relativeYFromView(0),
200 | relativeXFromView(0.5f), relativeYFromView(0f));
201 | mAnimPercent = 0;
202 |
203 | path.close();
204 | canvas.drawPath(path, mPaint);
205 |
206 |
207 | }
208 |
209 | break;
210 | case SHAPE_RECT:
211 |
212 |
213 | if (mIsLoading) {
214 |
215 |
216 | mAnimPercent += 0.15;
217 | if (mAnimPercent >= 1) {
218 | mShape = Shape.SHAPE_TRIANGLE;
219 | mIsLoading = false;
220 | mAnimPercent = 1;
221 | }
222 | int color= (int) mArgbEvaluator.evaluate(mAnimPercent,mRectColor,mTriangleColor);
223 | mPaint.setColor(color);
224 | Path path = new Path();
225 | path.moveTo(relativeXFromView(0.5f * mAnimPercent), 0);
226 | path.lineTo(relativeYFromView(1 - 0.5f * mAnimPercent), 0);
227 | float distanceX = (mControlX) * mAnimPercent;
228 | float distanceY = (relativeYFromView(1f) - mControlY) * mAnimPercent;
229 |
230 | path.lineTo(relativeXFromView(1f) - distanceX, relativeYFromView(1f) - distanceY);
231 | path.lineTo(relativeXFromView(0f) + distanceX, relativeYFromView(1f) - distanceY);
232 |
233 | path.close();
234 |
235 |
236 | canvas.drawPath(path, mPaint);
237 | invalidate();
238 |
239 | } else {
240 | mPaint.setColor(mRectColor);
241 | mControlX = relativeXFromView(0.5f - genhao3 / 4);
242 | mControlY = relativeYFromView(0.75f);
243 | Path path = new Path();
244 | path.moveTo(relativeXFromView(0f), relativeYFromView(0f));
245 | path.lineTo(relativeXFromView(1f), relativeYFromView(0f));
246 | path.lineTo(relativeXFromView(1f), relativeYFromView(1f));
247 | path.lineTo(relativeXFromView(0f), relativeYFromView(1f));
248 | path.close();
249 | mAnimPercent = 0;
250 | canvas.drawPath(path, mPaint);
251 |
252 | }
253 |
254 |
255 | break;
256 |
257 | }
258 |
259 |
260 | }
261 |
262 |
263 | private float relativeXFromView(float percent) {
264 | return getWidth() * percent;
265 | }
266 |
267 | private float relativeYFromView(float percent) {
268 | return getHeight() * percent;
269 | }
270 |
271 |
272 | public void changeShape() {
273 | mIsLoading = true;
274 | invalidate();
275 | }
276 |
277 | public void setShape(Shape shape){
278 | mIsLoading = true;
279 | mShape = shape;
280 | invalidate();
281 | }
282 |
283 | public enum Shape {
284 | SHAPE_TRIANGLE, SHAPE_RECT, SHAPE_CIRCLE
285 | }
286 |
287 |
288 | @Override
289 | public void setVisibility(int visibility) {
290 | super.setVisibility(visibility);
291 |
292 | if(visibility==VISIBLE){
293 | invalidate();
294 | }
295 | }
296 |
297 | public Shape getShape() {
298 | return mShape;
299 | }
300 |
301 | private int getColor(Context context, int id) {
302 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
303 | return context.getColor(id);
304 | } else {
305 | return context.getResources().getColor(id);
306 | }
307 | }
308 | }
309 |
310 |
--------------------------------------------------------------------------------
/load/src/main/java/com/jiajie/load/dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/load/src/main/res/drawable/aa_dialog_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
--------------------------------------------------------------------------------
/load/src/main/res/drawable/shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/load/src/main/res/layout/dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
--------------------------------------------------------------------------------
/load/src/main/res/layout/layout_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/load/src/main/res/layout/load_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
20 |
21 |
31 |
32 |
--------------------------------------------------------------------------------
/load/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
8 | //dialog
9 | #aa72d572
10 | #aa738ffe
11 | #aae84e40
12 | #00000000
13 | #25808080
14 | #f5f5f5
15 |
16 |
--------------------------------------------------------------------------------
/load/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LoadingView
3 |
4 |
--------------------------------------------------------------------------------
/load/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/load/src/test/java/com/jiajie/load/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.jiajie.load;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':load'
2 |
--------------------------------------------------------------------------------