├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── SpinnerLoading.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── lusfold
│ │ └── spinnerloading
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── sample
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── menu
│ │ └── menu_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── lusfold
│ └── spinnerloading
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── .gitignore
├── build.gradle
├── library.iml
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── lusfold
│ │ └── spinnerloading
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── lusfold
│ │ │ └── spinnerloading
│ │ │ ├── Animation
│ │ │ └── CallbackAnimation.java
│ │ │ ├── Circle.java
│ │ │ ├── SpinnerLoading.java
│ │ │ └── utils
│ │ │ └── SpinnerLoadingUtils.java
│ └── res
│ │ ├── drawable
│ │ └── gradient.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── lusfold
│ └── spinnerloading
│ └── ExampleUnitTest.java
├── preview.gif
├── preview.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | SpinnerLoading
--------------------------------------------------------------------------------
/.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/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
24 |
25 |
--------------------------------------------------------------------------------
/.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 |
48 |
49 |
50 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.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 | #SpinnerLoading
2 |
3 |
4 | [](http://www.android-gems.com/lib/lusfold/SpinnerLoading)
5 |
6 | [](https://bintray.com/lusfold/maven/AWebDB/view)
7 |
8 | [](https://bintray.com/lusfold/maven/SpinnerLoading/view)
9 |
10 | # Quickstart
11 |
12 |
13 |
14 | #### Preview
15 |
16 | 
17 |
18 | 
19 |
20 | Inspired by [spinner-loader-gooey-light-effect](http://www.materialup.com/posts/spinner-loader-gooey-light-effect)
21 |
22 | #### Dependency
23 |
24 | ``` gradle
25 | dependencies {
26 | compile 'com.lusfold.spinnerloading:library:1.0.0'
27 | }
28 | ```
29 |
30 | #### In your layout
31 |
32 | ``` xml
33 |
38 | ```
39 |
40 | #### Customization
41 |
42 | ``` java
43 | SpinnerLoading view = findViewById(R.id.spinner_loading);
44 | view.setPaintMode(1);
45 | view.setCircleRadius(30);
46 | view.setItemCount(8);
47 | ```
48 |
49 |
50 |
51 | ------
52 |
53 | # LICENSE
54 |
55 | Copyright 2014-2015 Lusfold(https://github.com/lusfold)
56 |
57 | Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.
58 |
59 | You may obtain a copy of the License at
60 |
61 | http://www.apache.org/licenses/LICENSE-2.0
62 |
63 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--------------------------------------------------------------------------------
/SpinnerLoading.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
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 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.0"
6 |
7 | defaultConfig {
8 | applicationId "com.lusfold.spinnerloading"
9 | minSdkVersion 14
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:22.2.1'
26 | compile project(':library')
27 | }
28 |
--------------------------------------------------------------------------------
/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/bzh/tools/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/lusfold/spinnerloading/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package sample;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 |
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | }
16 |
17 | @Override
18 | public boolean onCreateOptionsMenu(Menu menu) {
19 | // Inflate the menu; this adds items to the action bar if it is present.
20 | getMenuInflater().inflate(R.menu.menu_main, menu);
21 | return true;
22 | }
23 |
24 | @Override
25 | public boolean onOptionsItemSelected(MenuItem item) {
26 | // Handle action bar item clicks here. The action bar will
27 | // automatically handle clicks on the Home/Up button, so long
28 | // as you specify a parent activity in AndroidManifest.xml.
29 | int id = item.getItemId();
30 |
31 | //noinspection SimplifiableIfStatement
32 | if (id == R.id.action_settings) {
33 | return true;
34 | }
35 |
36 | return super.onOptionsItemSelected(item);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SpinnerLoading
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/test/java/com/lusfold/spinnerloading/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.2.3'
9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 04 12:59:14 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 | // This is the library version used when deploying the artifact
5 | version = "1.0.0"
6 | android {
7 | compileSdkVersion 22
8 | buildToolsVersion "23.0.0"
9 | resourcePrefix "SpinnerLoading" //这个随便填
10 | defaultConfig {
11 | minSdkVersion 14
12 | targetSdkVersion 22
13 | versionCode 1
14 | versionName version
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | }
26 | def siteUrl = 'https://github.com/lusfold/SpinnerLoading' // 项目的主页
27 | def gitUrl = 'https://github.com/lusfold/SpinnerLoading.git' // Git仓库的url
28 | group = "com.lusfold.spinnerloading" // Maven Group ID for the artifact,一般填你唯一的包名
29 | install {
30 | repositories.mavenInstaller {
31 | // This generates POM.xml with proper parameters
32 | pom {
33 | project {
34 | packaging 'aar'
35 | // Add your description here
36 | name 'Android Spinner Loading View' //项目描述
37 | url siteUrl
38 | // Set your license
39 | licenses {
40 | license {
41 | name 'The Apache Software License, Version 2.0'
42 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
43 | }
44 | }
45 | developers {
46 | developer {
47 | id 'lusfold' //填写的一些基本信息
48 | name 'lusfold'
49 | email 'lusfold@gmail.com'
50 | }
51 | }
52 | scm {
53 | connection gitUrl
54 | developerConnection gitUrl
55 | url siteUrl
56 | }
57 | }
58 | }
59 | }
60 | }
61 | task sourcesJar(type: Jar) {
62 | from android.sourceSets.main.java.srcDirs
63 | classifier = 'sources'
64 | }
65 | task javadoc(type: Javadoc) {
66 | source = android.sourceSets.main.java.srcDirs
67 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
68 | }
69 | task javadocJar(type: Jar, dependsOn: javadoc) {
70 | classifier = 'javadoc'
71 | from javadoc.destinationDir
72 | }
73 | artifacts {
74 | archives javadocJar
75 | archives sourcesJar
76 | }
77 | Properties properties = new Properties()
78 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
79 | bintray {
80 | user = properties.getProperty("bintray.user")
81 | key = properties.getProperty("bintray.apikey")
82 | configurations = ['archives']
83 | pkg {
84 | repo = "maven"
85 | name = "SpinnerLoading" //发布到JCenter上的项目名字
86 | websiteUrl = siteUrl
87 | vcsUrl = gitUrl
88 | licenses = ["Apache-2.0"]
89 | publish = true
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/library/library.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
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 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/bzh/tools/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/lusfold/spinnerloading/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/java/com/lusfold/spinnerloading/Animation/CallbackAnimation.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading.Animation;
2 |
3 | import android.view.animation.Animation;
4 | import android.view.animation.Transformation;
5 |
6 | /**
7 | * @author Lusfold
8 | */
9 | public class CallbackAnimation extends Animation {
10 | public interface TransformationListener {
11 | void onApplyTrans(float interpolatedTime);
12 | }
13 |
14 | private TransformationListener mListener;
15 |
16 | public CallbackAnimation(TransformationListener listener) {
17 | mListener = listener;
18 | if (listener == null) {
19 | mListener = listener;
20 | }
21 | }
22 |
23 | @Override
24 | protected void applyTransformation(float interpolatedTime, Transformation t) {
25 | super.applyTransformation(interpolatedTime, t);
26 | mListener.onApplyTrans(interpolatedTime);
27 | }
28 |
29 | public void setListener(TransformationListener listener) {
30 | if (listener == null) {
31 | return;
32 | }
33 | mListener = listener;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/java/com/lusfold/spinnerloading/Circle.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | /**
4 | * @author Lusfold
5 | */
6 | public class Circle {
7 | public float[] center;
8 | public float radius;
9 | }
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/lusfold/spinnerloading/SpinnerLoading.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.graphics.RadialGradient;
10 | import android.graphics.Shader;
11 | import android.util.AttributeSet;
12 | import android.view.View;
13 | import android.view.animation.Animation;
14 | import android.view.animation.LinearInterpolator;
15 |
16 | import com.lusfold.spinnerloading.Animation.CallbackAnimation;
17 | import com.lusfold.spinnerloading.utils.SpinnerLoadingUtils;
18 |
19 | import java.util.ArrayList;
20 |
21 | /**
22 | * @author Lusfold
23 | */
24 | public class SpinnerLoading extends View implements CallbackAnimation.TransformationListener {
25 | public static final int DEFAULT_DURATION = 2000;
26 | public static final int DEFAULT_itemCount = 8;
27 | public static final int DEFAULT_CIRCLE_COLOR = 0xff33A7ff;
28 | public static final int DEFAULT_CIRCLE_COLOR_MOVE = 0xff33A7ff;
29 | public static final float DEFAULT_SCALE_RATE = 0.2f;
30 | public static final int DEFAULT_RADIUS = 20;
31 | public static final int DEFAULT_WIDTH_FACTOR = 14;
32 | public static final int DEFAULT_WIDTH_PADDING_FACTOR = 2;
33 |
34 | private int itemCount = DEFAULT_itemCount;
35 | private Paint paint = new Paint();
36 | private float handle_len_rate = 2f;
37 | private float radius = DEFAULT_RADIUS;
38 | private final float SCALE_RATE = DEFAULT_SCALE_RATE;
39 | private ArrayList circlePaths = new ArrayList<>();
40 | private float mInterpolatedTime;
41 | private CallbackAnimation callbackAnimation;
42 | private int circleColor;
43 | private int circleColorMove;
44 | private float width;
45 | private float preFac1;
46 | private float preFac2;
47 | private float pi2;
48 |
49 | public SpinnerLoading(Context context) {
50 | this(context, null);
51 | }
52 |
53 | public SpinnerLoading(Context context, AttributeSet attrs) {
54 | this(context, attrs,0);
55 | }
56 |
57 | public SpinnerLoading(Context context, AttributeSet attrs, int defStyleAttr) {
58 | super(context, attrs, defStyleAttr);
59 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SpinnerLoading);
60 | circleColor = typedArray.getColor(R.styleable.SpinnerLoading_circle_color, DEFAULT_CIRCLE_COLOR);
61 | circleColorMove = typedArray.getColor(R.styleable.SpinnerLoading_circle_color_move, DEFAULT_CIRCLE_COLOR_MOVE);
62 | init();
63 | }
64 |
65 | @Override
66 | public void onApplyTrans(float interpolatedTime) {
67 | mInterpolatedTime = interpolatedTime;
68 | invalidate();
69 | }
70 |
71 |
72 | private void init() {
73 | pi2 = (float) (Math.PI / 2);
74 |
75 | paint.setColor(circleColor);
76 | paint.setStyle(Paint.Style.FILL);
77 | paint.setAntiAlias(true);
78 |
79 | reMakeFactors();
80 | }
81 |
82 |
83 | private void drawSpinner(Canvas canvas, int j, int i, float v, float handle_len_rate, float maxDistance) {
84 |
85 | final Circle circle1 = circlePaths.get(i);
86 | final Circle circle2 = circlePaths.get(j);
87 |
88 | float[] center1 = circle1.center;
89 | float[] center2 = circle2.center;
90 | float radius1 = circle1.radius;
91 | float radius2 = circle2.radius;
92 |
93 | float d = SpinnerLoadingUtils.getDistance(center1, center2);
94 | if (d < maxDistance) {
95 | float scale2 = 1 + SCALE_RATE * (1 - d / maxDistance);
96 | radius2 *= scale2;
97 | }
98 |
99 | if (radius1 == 0 || radius2 == 0) {
100 | return;
101 | }
102 |
103 | if (j == 1) {
104 | paint.setShader(new RadialGradient(center1[0], center1[1], radius * 2, circleColorMove, Color.TRANSPARENT, Shader.TileMode.CLAMP));
105 | canvas.drawCircle(center1[0], center1[1], radius1 * 3, paint);
106 | paint.setShader(null);
107 | paint.setColor(circleColorMove);
108 | canvas.drawCircle(center1[0], center1[1], radius1, paint);
109 | paint.setColor(circleColor);
110 | }
111 |
112 | canvas.drawCircle(center2[0], center2[1], radius2, paint);
113 |
114 | float u1, u2;
115 |
116 | if (d > maxDistance || d <= Math.abs(radius1 - radius2)) {
117 | return;
118 | } else if (d < radius1 + radius2) {
119 | u1 = (float) Math.acos((radius1 * radius1 + d * d - radius2 * radius2) /
120 | (2 * radius1 * d));
121 | u2 = (float) Math.acos((radius2 * radius2 + d * d - radius1 * radius1) /
122 | (2 * radius2 * d));
123 | } else {
124 | u1 = 0;
125 | u2 = 0;
126 | }
127 | float[] centermin = new float[]{center2[0] - center1[0], center2[1] - center1[1]};
128 |
129 | float angle1 = (float) Math.atan2(centermin[1], centermin[0]);
130 | float angle2 = (float) Math.acos((radius1 - radius2) / d);
131 | float angle1a = angle1 + u1 + (angle2 - u1) * v;
132 | float angle1b = angle1 - u1 - (angle2 - u1) * v;
133 | float angle2a = (float) (angle1 + Math.PI - u2 - (Math.PI - u2 - angle2) * v);
134 | float angle2b = (float) (angle1 - Math.PI + u2 + (Math.PI - u2 - angle2) * v);
135 |
136 | float[] p1a1 = SpinnerLoadingUtils.getVector(angle1a, radius1);
137 | float[] p1b1 = SpinnerLoadingUtils.getVector(angle1b, radius1);
138 | float[] p2a1 = SpinnerLoadingUtils.getVector(angle2a, radius2);
139 | float[] p2b1 = SpinnerLoadingUtils.getVector(angle2b, radius2);
140 |
141 | float[] p1a = new float[]{p1a1[0] + center1[0], p1a1[1] + center1[1]};
142 | float[] p1b = new float[]{p1b1[0] + center1[0], p1b1[1] + center1[1]};
143 | float[] p2a = new float[]{p2a1[0] + center2[0], p2a1[1] + center2[1]};
144 | float[] p2b = new float[]{p2b1[0] + center2[0], p2b1[1] + center2[1]};
145 |
146 |
147 | float[] p1_p2 = new float[]{p1a[0] - p2a[0], p1a[1] - p2a[1]};
148 |
149 | float totalRadius = (radius1 + radius2);
150 | float d2 = Math.min(v * handle_len_rate, SpinnerLoadingUtils.getLength(p1_p2) / totalRadius);
151 | d2 *= Math.min(1, d * 2 / (radius1 + radius2));
152 | radius1 *= d2;
153 | radius2 *= d2;
154 |
155 | float[] sp1 = SpinnerLoadingUtils.getVector(angle1a - pi2, radius1);
156 | float[] sp2 = SpinnerLoadingUtils.getVector(angle2a + pi2, radius2);
157 | float[] sp3 = SpinnerLoadingUtils.getVector(angle2b - pi2, radius2);
158 | float[] sp4 = SpinnerLoadingUtils.getVector(angle1b + pi2, radius1);
159 |
160 | Path path1 = new Path();
161 | path1.moveTo(p1a[0], p1a[1]);
162 | path1.cubicTo(p1a[0] + sp1[0], p1a[1] + sp1[1], p2a[0] + sp2[0], p2a[1] + sp2[1], p2a[0], p2a[1]);
163 | path1.lineTo(p2b[0], p2b[1]);
164 | path1.cubicTo(p2b[0] + sp3[0], p2b[1] + sp3[1], p1b[0] + sp4[0], p1b[1] + sp4[1], p1b[0], p1b[1]);
165 | path1.lineTo(p1a[0], p1a[1]);
166 | path1.close();
167 | canvas.drawPath(path1, paint);
168 | }
169 |
170 |
171 | @Override
172 | protected void onDraw(Canvas canvas) {
173 | super.onDraw(canvas);
174 | circlePaths.get(0).center[0] = (float) (preFac1 + preFac2 * Math.cos(2 * Math.PI * mInterpolatedTime));
175 | circlePaths.get(0).center[1] = (float) (preFac1 + preFac2 * Math.sin(2 * Math.PI * mInterpolatedTime));
176 | for (int i = 1, l = circlePaths.size(); i < l; i++) {
177 | drawSpinner(canvas, i, 0, 0.6f, handle_len_rate, radius * 3f);
178 | }
179 | }
180 |
181 | @Override
182 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
183 | widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (radius * DEFAULT_WIDTH_FACTOR), MeasureSpec.EXACTLY);
184 | heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (radius * DEFAULT_WIDTH_FACTOR), MeasureSpec.EXACTLY);
185 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
186 | }
187 |
188 |
189 | private void stopAnimation() {
190 | this.clearAnimation();
191 | postInvalidate();
192 | }
193 |
194 | private void startAnimation() {
195 | if (callbackAnimation == null) {
196 | callbackAnimation = new CallbackAnimation(this);
197 | callbackAnimation.setDuration(DEFAULT_DURATION);
198 | callbackAnimation.setInterpolator(new LinearInterpolator());
199 | callbackAnimation.setRepeatCount(Animation.INFINITE);
200 | }
201 | startAnimation(callbackAnimation);
202 | }
203 |
204 | @Override
205 | protected void onVisibilityChanged(View changedView, int visibility) {
206 | super.onVisibilityChanged(changedView, visibility);
207 |
208 | if (visibility == GONE || visibility == INVISIBLE) {
209 | stopAnimation();
210 | } else {
211 | startAnimation();
212 | }
213 | }
214 |
215 | @Override
216 | protected void onAttachedToWindow() {
217 | super.onAttachedToWindow();
218 | startAnimation();
219 | }
220 |
221 | @Override
222 | protected void onDetachedFromWindow() {
223 | stopAnimation();
224 | super.onDetachedFromWindow();
225 | }
226 |
227 | /**
228 | * @param itemCount
229 | */
230 | public void setItemCount(int itemCount) {
231 | this.itemCount = itemCount;
232 | }
233 |
234 | /**
235 | * @param radius
236 | */
237 | public void setCircleRadius(int radius) {
238 | this.radius = radius;
239 | reMakeFactors();
240 | }
241 |
242 | /**
243 | * @param mode
244 | */
245 | public void setPaintMode(int mode) {
246 | paint.setStyle(mode == 0 ? Paint.Style.STROKE : Paint.Style.FILL);
247 | }
248 |
249 | private void reMakeFactors() {
250 | circlePaths.clear();
251 | width = radius * DEFAULT_WIDTH_FACTOR;
252 | preFac1 = radius * (DEFAULT_WIDTH_FACTOR / 2);
253 | preFac2 = preFac1 - radius * (DEFAULT_WIDTH_PADDING_FACTOR / 2 + 1);
254 | Circle circlePath = new Circle();
255 | circlePath.center = new float[]{radius * (DEFAULT_WIDTH_FACTOR - DEFAULT_WIDTH_PADDING_FACTOR / 2 - 1), radius * DEFAULT_WIDTH_FACTOR / 2};
256 | circlePath.radius = radius / 4 * 3;
257 | circlePaths.add(circlePath);
258 |
259 | for (int i = 1; i <= itemCount; i++) {
260 | circlePath = new Circle();
261 | circlePath.center = new float[]{(float) (preFac1 + preFac2 * Math.cos(Math.PI * 2 * i / itemCount)), (float) (preFac1 + preFac2 * Math.sin(Math.PI * 2 * i / itemCount))};
262 | circlePath.radius = radius;
263 | circlePaths.add(circlePath);
264 | }
265 | }
266 | }
267 |
--------------------------------------------------------------------------------
/library/src/main/java/com/lusfold/spinnerloading/utils/SpinnerLoadingUtils.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading.utils;
2 |
3 | /**
4 | * @author Lusfold
5 | */
6 | public class SpinnerLoadingUtils {
7 | public static float[] getVector(float radians, float length) {
8 | float x = (float) (Math.cos(radians) * length);
9 | float y = (float) (Math.sin(radians) * length);
10 | return new float[]{
11 | x, y
12 | };
13 | }
14 |
15 | public static float getDistance(float[] b1, float[] b2) {
16 | float x = b1[0] - b2[0];
17 | float y = b1[1] - b2[1];
18 | float d = x * x + y * y;
19 | return (float) Math.sqrt(d);
20 | }
21 |
22 |
23 | public static float getLength(float[] b) {
24 | return (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/gradient.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Library
3 |
4 |
--------------------------------------------------------------------------------
/library/src/test/java/com/lusfold/spinnerloading/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.lusfold.spinnerloading;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/preview.gif
--------------------------------------------------------------------------------
/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lusfold/SpinnerLoading/e8ecab53c22d02dd26adc1695ba2763bf652aa64/preview.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':library'
2 |
--------------------------------------------------------------------------------