├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── me
│ │ │ └── wangyuwei
│ │ │ └── bezierloadingview
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── me
│ │ │ └── wangyuwei
│ │ │ └── bezierloadingview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── me
│ │ └── wangyuwei
│ │ └── bezierloadingview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── LoadingiVew
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ └── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── attrs.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── me
│ │ │ └── wangyuwei
│ │ │ └── loadingview
│ │ │ └── LoadingView.java
│ ├── test
│ │ └── java
│ │ │ └── me
│ │ │ └── wangyuwei
│ │ │ └── loadingview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── me
│ │ └── wangyuwei
│ │ └── loadingview
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | BezierLoadingView
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/LoadingiVew/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':LoadingiVew'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BezierLoadingView
3 |
4 |
--------------------------------------------------------------------------------
/LoadingiVew/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LoadingView
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/LoadingiVew/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JeasonWong/BezierLoadingView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LoadingiVew/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #F6B965
5 | #F04D61
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @color/loading_pink
4 | @color/loading_pink
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/LoadingiVew/src/test/java/me/wangyuwei/loadingview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.loadingview;
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 | }
--------------------------------------------------------------------------------
/app/src/test/java/me/wangyuwei/bezierloadingview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.bezierloadingview;
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 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LoadingiVew/src/androidTest/java/me/wangyuwei/loadingview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.loadingview;
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/androidTest/java/me/wangyuwei/bezierloadingview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.bezierloadingview;
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 | }
--------------------------------------------------------------------------------
/LoadingiVew/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/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/wscn/Documents/android-sdk-macosx/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 |
--------------------------------------------------------------------------------
/LoadingiVew/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/wscn/Documents/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/.idea/gradle.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 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "me.wangyuwei.bezierloadingview"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | repositories {
23 | maven {
24 | url 'https://dl.bintray.com/wangyuwei/maven'
25 | }
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 | testCompile 'junit:junit:4.12'
31 | compile 'com.android.support:appcompat-v7:23.4.0'
32 | // compile 'me.wangyuwei:LoadingiVew:1.0.0'
33 | compile project(':LoadingiVew')
34 | }
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## What's BezierLoadingView ?
2 | A cool loading view with Bezier and a smooth circular motion,
3 |
4 | [](https://android-arsenal.com/details/1/3736)
5 |
6 | ## Demo
7 | 
8 |
9 | ## Features
10 | * Bezier
11 | * Circular motion
12 |
13 | ##Attributes
14 |
15 | |name|format|description|
16 | |:---:|:---:|:---:|
17 | | lv_external_radius | dimension |set external circle radius
18 | | lv_internal_radius | dimension |set internal circle radius
19 | | lv_duration | integer |set animation duration
20 | | lv_start_color | color |set start color
21 | | lv_end_color | color |set end color
22 |
23 | ## Import
24 |
25 | ```gradle
26 | dependencies {
27 | compile 'me.wangyuwei:LoadingiVew:1.0.5'
28 | }
29 | ```
30 |
31 | ## Usage
32 | #### Define your banner under your xml :
33 |
34 | ```xml
35 |
44 | ```
45 |
46 |
47 |
48 | ##**Lincense**
49 |
50 | ```lincense
51 | Copyright [2016] [JeasonWong of copyright owner]
52 |
53 | Licensed under the Apache License, Version 2.0 (the "License");
54 | you may not use this file except in compliance with the License.
55 | You may obtain a copy of the License at
56 |
57 | http://www.apache.org/licenses/LICENSE-2.0
58 |
59 | Unless required by applicable law or agreed to in writing, software
60 | distributed under the License is distributed on an "AS IS" BASIS,
61 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62 | See the License for the specific language governing permissions and
63 | limitations under the License.
64 | ```
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wangyuwei/bezierloadingview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.bezierloadingview;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.support.v7.widget.AppCompatSeekBar;
6 | import android.widget.SeekBar;
7 |
8 | import me.wangyuwei.loadingview.LoadingView;
9 |
10 | public class MainActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener {
11 |
12 | private LoadingView mLoadingView;
13 | private AppCompatSeekBar mSbExternalR, mSbInternalR, mSbRate;
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | mLoadingView = (LoadingView) this.findViewById(R.id.loading_view);
21 | mSbExternalR = (AppCompatSeekBar) this.findViewById(R.id.sb_external_r);
22 | mSbInternalR = (AppCompatSeekBar) this.findViewById(R.id.sb_internal_r);
23 | mSbRate = (AppCompatSeekBar) this.findViewById(R.id.sb_rate);
24 | mSbExternalR.setOnSeekBarChangeListener(this);
25 | mSbInternalR.setOnSeekBarChangeListener(this);
26 | mSbRate.setOnSeekBarChangeListener(this);
27 |
28 | mLoadingView.start();
29 | }
30 |
31 | @Override
32 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
33 | if (seekBar == mSbExternalR) {
34 | mLoadingView.setExternalRadius(progress);
35 | } else if (seekBar == mSbInternalR) {
36 | mLoadingView.setInternalRadius(progress);
37 | } else if (seekBar == mSbRate) {
38 | mLoadingView.setDuration(progress);
39 | }
40 | }
41 |
42 | @Override
43 | public void onStartTrackingTouch(SeekBar seekBar) {
44 |
45 | }
46 |
47 | @Override
48 | public void onStopTrackingTouch(SeekBar seekBar) {
49 |
50 | }
51 |
52 | @Override
53 | protected void onDestroy() {
54 | super.onDestroy();
55 | mLoadingView.stop();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/LoadingiVew/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jfrog.bintray'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 | group = 'me.wangyuwei' // Change this to match your package name
6 | version = '1.0.5' // Change this to match your version number
7 |
8 | android {
9 | compileSdkVersion 23
10 | buildToolsVersion "23.0.3"
11 |
12 | defaultConfig {
13 | minSdkVersion 15
14 | targetSdkVersion 23
15 | versionCode 1
16 | versionName "1.0"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.android.support:appcompat-v7:23.4.0'
30 | compile 'io.reactivex:rxandroid:1.2.0'
31 | }
32 |
33 | task generateSourcesJar(type: Jar) {
34 | from android.sourceSets.main.java.srcDirs
35 | classifier 'sources'
36 | }
37 |
38 | task generateJavadocs(type: Javadoc) {
39 | source = android.sourceSets.main.java.srcDirs
40 | classpath += project.files(android.getBootClasspath()
41 | .join(File.pathSeparator))
42 | }
43 |
44 | task generateJavadocsJar(type: Jar) {
45 | from generateJavadocs.destinationDir
46 | classifier 'javadoc'
47 | }
48 |
49 | artifacts {
50 | // archives generateJavaDocsJar
51 | archives generateSourcesJar
52 | }
53 |
54 | Properties properties = new Properties()
55 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
56 | bintray {
57 | user = properties.getProperty("bintray.user")
58 | key = properties.getProperty("bintray.key")
59 | pkg {
60 | repo = 'maven'
61 | name = 'BezierLoadingView'
62 | desc = "A cool loading view with Bezier and a smooth circular motion, "
63 |
64 | version {
65 | name = '1.0.5'
66 | desc = 'A cool loading view with Bezier and a smooth circular motion, '
67 | vcsTag = 'android, loadfing, view'
68 | }
69 |
70 | licenses = ['Apache-2.0']
71 | vcsUrl = 'https://github.com/JeasonWong/BezierLoadingView.git'
72 | websiteUrl = 'https://github.com/JeasonWong/BezierLoadingView'
73 |
74 | labels = ['android']
75 | publish = true
76 | publicDownloadNumbers = true
77 | }
78 | configurations = ['archives']
79 | }
80 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 1.8
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
24 |
25 |
31 |
32 |
38 |
39 |
47 |
48 |
49 |
50 |
57 |
58 |
64 |
65 |
73 |
74 |
75 |
76 |
84 |
85 |
91 |
92 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/LoadingiVew/src/main/java/me/wangyuwei/loadingview/LoadingView.java:
--------------------------------------------------------------------------------
1 | package me.wangyuwei.loadingview;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.content.res.TypedArray;
6 | import android.graphics.Canvas;
7 | import android.graphics.LinearGradient;
8 | import android.graphics.Paint;
9 | import android.graphics.Path;
10 | import android.graphics.PointF;
11 | import android.graphics.Shader;
12 | import android.support.v4.content.ContextCompat;
13 | import android.util.AttributeSet;
14 | import android.view.View;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 | import java.util.concurrent.TimeUnit;
19 |
20 | import rx.Observable;
21 | import rx.Subscription;
22 | import rx.functions.Action1;
23 |
24 | /**
25 | * 作者: 巴掌 on 16/6/14 13:06
26 | */
27 | public class LoadingView extends View {
28 |
29 | private final int DEFAULT_DURATION = 15;
30 | private final int DEFAULT_EXTERNAL_RADIUS = dp2px(82);
31 | private final int DEFAULT_INTERNAL_RADIUS = dp2px(8);
32 | private final int DEFAULT_RADIAN = 45;
33 |
34 | private int mWidth;
35 | private int mHeight;
36 | private Subscription mTimer;
37 | private Paint mPaint;
38 | private Path mPath = new Path();
39 |
40 | //内圆色
41 | int mColors[];
42 |
43 | //外圆角度
44 | int mAngle = 0;
45 |
46 | //圈数
47 | int mCyclic = 0;
48 |
49 | //变大动画圆半径
50 | private float mGetBiggerCircleRadius;
51 |
52 | //移动圆半径
53 | private float mGetSmallerCircleRadius;
54 |
55 | //外圆
56 | private List mPoints;
57 |
58 | //属性动画集
59 | private List mAnimators;
60 |
61 | //外圆圆点
62 | private float x0, y0;
63 |
64 | //点间的弧度
65 | private int mRadian = DEFAULT_RADIAN;
66 |
67 | //时间间隔
68 | private int mDuration;
69 | private final static int MAX_DURATION = 120;
70 | private final static int MIN_DURATION = 1;
71 |
72 | //内圆半径
73 | private float mInternalR;
74 | private final int MAX_INTERNAL_R = dp2px(18);
75 | private final int MIN_INTERNAL_R = dp2px(2);
76 |
77 | //外圆半径
78 | private float mExternalR;
79 | private final int MAX_EXTERNAL_R = dp2px(150);
80 | private final int MIN_EXTERNAL_R = dp2px(25);
81 |
82 | public LoadingView(Context context) {
83 | this(context, null);
84 | }
85 |
86 | public LoadingView(Context context, AttributeSet attrs) {
87 | this(context, attrs, 0);
88 | }
89 |
90 | public LoadingView(Context context, AttributeSet attrs, int defStyleAttr) {
91 | super(context, attrs, defStyleAttr);
92 | init(attrs);
93 | }
94 |
95 | private void init(AttributeSet attrs) {
96 | mAnimators = new ArrayList<>();
97 | mPoints = new ArrayList<>();
98 |
99 | mPaint = new Paint();
100 | mPaint.setAntiAlias(true);
101 | mPaint.setStyle(Paint.Style.FILL);
102 |
103 | TypedArray typeArray = getContext().obtainStyledAttributes(attrs,
104 | R.styleable.BezierLoadingView);
105 | mDuration = typeArray.getInt(R.styleable.BezierLoadingView_lv_duration, DEFAULT_DURATION);
106 | mInternalR = typeArray.getDimension(R.styleable.BezierLoadingView_lv_internal_radius, DEFAULT_INTERNAL_RADIUS);
107 | mExternalR = typeArray.getDimension(R.styleable.BezierLoadingView_lv_external_radius, DEFAULT_EXTERNAL_RADIUS);
108 | int defaultColor = 999999;
109 | int startColor = typeArray.getColor(R.styleable.BezierLoadingView_lv_start_color, defaultColor);
110 | int endColor = typeArray.getColor(R.styleable.BezierLoadingView_lv_end_color, defaultColor);
111 | List colorList = new ArrayList<>();
112 | if (startColor != defaultColor) {
113 | colorList.add(startColor);
114 | }
115 | if (endColor != defaultColor) {
116 | colorList.add(endColor);
117 | }
118 | //needs >= 2 number of colors
119 | if (colorList.size() == 1) {
120 | colorList.add(colorList.get(0));
121 | }
122 |
123 | if (colorList.size() == 0) {
124 | mColors = new int[]{ContextCompat.getColor(getContext(), R.color.loading_yellow), ContextCompat.getColor(getContext(), R.color.loading_pink)};
125 | } else {
126 | mColors = new int[colorList.size()];
127 | for (int i = 0; i < colorList.size(); i++) {
128 | mColors[i] = colorList.get(i);
129 | }
130 | }
131 | typeArray.recycle();
132 |
133 | }
134 |
135 | @Override
136 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
137 | super.onSizeChanged(w, h, oldw, oldh);
138 | mWidth = w;
139 | mHeight = h;
140 | setShader();
141 | resetPoint();
142 | }
143 |
144 | /**
145 | * 设置渐变色
146 | */
147 | private void setShader() {
148 | Shader mLinearGradient = new LinearGradient(mWidth / 2 - mExternalR, mHeight / 2 - mExternalR, mWidth / 2 - mExternalR, mHeight / 2 + mExternalR, mColors, null,
149 | Shader.TileMode.CLAMP);
150 | mPaint.setShader(mLinearGradient);
151 | }
152 |
153 | /**
154 | * 启动定时器
155 | */
156 | public void start() {
157 | if (mTimer == null || mTimer.isUnsubscribed()) {
158 | mTimer = Observable.interval(mDuration, TimeUnit.MILLISECONDS)
159 | .subscribe(new Action1() {
160 | @Override
161 | public void call(Long aLong) {
162 | dealTimerBusiness();
163 | }
164 | }, new Action1() {
165 | @Override
166 | public void call(Throwable throwable) {
167 |
168 | }
169 | });
170 | }
171 | this.setVisibility(VISIBLE);
172 | }
173 |
174 | public void stop() {
175 | if (mTimer != null) {
176 | mTimer.unsubscribe();
177 | }
178 | this.setVisibility(GONE);
179 | }
180 |
181 | /**
182 | * 定时任务
183 | */
184 | private void dealTimerBusiness() {
185 |
186 | setOffset((mAngle % mRadian) / (float) mRadian);
187 |
188 | mAngle++;
189 | if (mAngle == 360) {
190 | mAngle = 0;
191 | mCyclic++;
192 | }
193 | }
194 |
195 | @Override
196 | protected void onDraw(Canvas canvas) {
197 | super.onDraw(canvas);
198 | drawCircle(canvas);
199 | drawBezier(canvas);
200 | }
201 |
202 | /**
203 | * 绘制各点圆
204 | *
205 | * @param canvas
206 | */
207 | private void drawCircle(Canvas canvas) {
208 | for (int i = 0; i < mPoints.size(); i++) {
209 | int index = mAngle / mRadian;
210 | if (isEvenCyclic()) {
211 | if (i == index) {
212 | if (mAngle % mRadian == 0) {
213 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), getMaxInternalRadius(), mPaint);
214 | } else if (mAngle % mRadian > 0) {
215 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), mGetSmallerCircleRadius < mInternalR ? mInternalR : mGetSmallerCircleRadius, mPaint);
216 | }
217 | } else if (i == index + 1) {
218 | if (mAngle % mRadian == 0) {
219 | canvas.drawCircle(mPoints.get(i).x, mPoints.get(i).y, mInternalR, mPaint);
220 | } else {
221 | canvas.drawCircle(mPoints.get(i).x, mPoints.get(i).y, mGetBiggerCircleRadius < mInternalR ? mInternalR : mGetBiggerCircleRadius, mPaint);
222 | }
223 | } else if (i > index + 1) {
224 | canvas.drawCircle(mPoints.get(i).x, mPoints.get(i).y, mInternalR, mPaint);
225 | }
226 | } else {
227 | if (i < index) {
228 | canvas.drawCircle(mPoints.get(i + 1).x, mPoints.get(i + 1).y, mInternalR, mPaint);
229 | } else if (i == index) {
230 | if (mAngle % mRadian == 0) {
231 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), getMaxInternalRadius(), mPaint);
232 | } else {
233 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), mGetSmallerCircleRadius < mInternalR ? mInternalR : mGetSmallerCircleRadius, mPaint);
234 | }
235 | } else if (i == index + 1) {
236 | if (mAngle % mRadian == 0) {
237 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), getMinInternalRadius(), mPaint);
238 | } else if (mAngle % mRadian > 0) {
239 | canvas.drawCircle(getCircleX(mAngle), getCircleY(mAngle), mGetBiggerCircleRadius < mInternalR ? mInternalR : mGetBiggerCircleRadius, mPaint);
240 | }
241 | }
242 | }
243 | }
244 | }
245 |
246 | /**
247 | * 绘制贝赛尔曲线
248 | *
249 | * @param canvas
250 | */
251 | private void drawBezier(Canvas canvas) {
252 |
253 | mPath.reset();
254 |
255 | int circleIndex = mAngle / mRadian;
256 |
257 | float rightX = getCircleX(mAngle);
258 | float rightY = getCircleY(mAngle);
259 |
260 | float leftX, leftY;
261 | if (isEvenCyclic()) {
262 | int index;
263 | index = circleIndex + 1;
264 | leftX = mPoints.get(index >= mPoints.size() ? mPoints.size() - 1 : index).x;
265 | leftY = mPoints.get(index >= mPoints.size() ? mPoints.size() - 1 : index).y;
266 | } else {
267 | int index = circleIndex;
268 | leftX = mPoints.get(index < 0 ? 0 : index).x;
269 | leftY = mPoints.get(index < 0 ? 0 : index).y;
270 | }
271 |
272 | double theta = getTheta(new PointF(leftX, leftY), new PointF(rightX, rightY));
273 | float sinTheta = (float) Math.sin(theta);
274 | float cosTheta = (float) Math.cos(theta);
275 |
276 | PointF pointF1 = new PointF(leftX - mInternalR * sinTheta, leftY + mInternalR * cosTheta);
277 | PointF pointF2 = new PointF(rightX - mInternalR * sinTheta, rightY + mInternalR * cosTheta);
278 | PointF pointF3 = new PointF(rightX + mInternalR * sinTheta, rightY - mInternalR * cosTheta);
279 | PointF pointF4 = new PointF(leftX + mInternalR * sinTheta, leftY - mInternalR * cosTheta);
280 |
281 | if (isEvenCyclic()) {
282 | if (mAngle % mRadian < mRadian / 2) {
283 |
284 | mPath.moveTo(pointF3.x, pointF3.y);
285 | mPath.quadTo(rightX + (leftX - rightX) / (mRadian / 2) * (mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : mAngle % mRadian), rightY + (leftY - rightY) / (mRadian / 2) * (mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : mAngle % mRadian), pointF2.x, pointF2.y);
286 | mPath.lineTo(pointF3.x, pointF3.y);
287 |
288 | mPath.moveTo(pointF4.x, pointF4.y);
289 | mPath.quadTo(leftX + (rightX - leftX) / (mRadian / 2) * (mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : mAngle % mRadian), leftY + (rightY - leftY) / (mRadian / 2) * (mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : mAngle % mRadian), pointF1.x, pointF1.y);
290 | mPath.lineTo(pointF4.x, pointF4.y);
291 |
292 | mPath.close();
293 | canvas.drawPath(mPath, mPaint);
294 | return;
295 | }
296 | } else {
297 | if (circleIndex > 0 && mAngle % mRadian > mRadian / 2) {
298 |
299 | mPath.moveTo(pointF3.x, pointF3.y);
300 | mPath.quadTo(rightX + (leftX - rightX) / (mRadian / 2) * (mRadian - mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : (mRadian - mAngle % mRadian)), rightY + (leftY - rightY) / (mRadian / 2) * (mRadian - mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : (mRadian - mAngle % mRadian)), pointF2.x, pointF2.y);
301 | mPath.lineTo(pointF3.x, pointF3.y);
302 |
303 | mPath.moveTo(pointF4.x, pointF4.y);
304 | mPath.quadTo(leftX + (rightX - leftX) / (mRadian / 2) * (mRadian - mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : (mRadian - mAngle % mRadian)), leftY + (rightY - leftY) / (mRadian / 2) * (mRadian - mAngle % mRadian > (mRadian / 2) ? (mRadian / 2) : (mRadian - mAngle % mRadian)), pointF1.x, pointF1.y);
305 | mPath.lineTo(pointF4.x, pointF4.y);
306 |
307 | mPath.close();
308 | canvas.drawPath(mPath, mPaint);
309 | return;
310 | }
311 | }
312 |
313 | if (circleIndex == 0 && !isEvenCyclic()) return;
314 |
315 | mPath.moveTo(pointF1.x, pointF1.y);
316 | mPath.quadTo((leftX + rightX) / 2, (leftY + rightY) / 2, pointF2.x, pointF2.y);
317 | mPath.lineTo(pointF3.x, pointF3.y);
318 | mPath.quadTo((leftX + rightX) / 2, (leftY + rightY) / 2, pointF4.x, pointF4.y);
319 | mPath.lineTo(pointF1.x, pointF1.y);
320 |
321 | mPath.close();
322 |
323 | canvas.drawPath(mPath, mPaint);
324 | }
325 |
326 | /**
327 | * 创建属性动画
328 | */
329 | private void createAnimator() {
330 |
331 | if (mPoints.isEmpty()) {
332 | return;
333 | }
334 | mAnimators.clear();
335 |
336 | ValueAnimator circleGetSmallerAnimator = ValueAnimator.ofFloat(getMaxInternalRadius(), getMinInternalRadius());
337 | circleGetSmallerAnimator.setDuration(5000L);
338 | circleGetSmallerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
339 | @Override
340 | public void onAnimationUpdate(ValueAnimator animation) {
341 | mGetSmallerCircleRadius = (float) animation.getAnimatedValue();
342 | }
343 | });
344 | mAnimators.add(circleGetSmallerAnimator);
345 |
346 | ValueAnimator circleGetBiggerAnimator = ValueAnimator.ofFloat(getMinInternalRadius(), getMaxInternalRadius());
347 | circleGetBiggerAnimator.setDuration(5000L);
348 | circleGetBiggerAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
349 | @Override
350 | public void onAnimationUpdate(ValueAnimator animation) {
351 | mGetBiggerCircleRadius = (float) animation.getAnimatedValue();
352 | }
353 | });
354 | mAnimators.add(circleGetBiggerAnimator);
355 |
356 | }
357 |
358 | private void seekAnimator(float offset) {
359 | for (ValueAnimator animator : mAnimators) {
360 | animator.setCurrentPlayTime((long) (5000.0F * offset));
361 | }
362 | }
363 |
364 | public void setOffset(float offSet) {
365 | createAnimator();
366 | seekAnimator(offSet);
367 | postInvalidate();
368 | }
369 |
370 | /**
371 | * 重置圆点
372 | */
373 | private void resetPoint() {
374 |
375 | x0 = mWidth / 2;
376 | y0 = mHeight / 2;
377 |
378 | createPoints();
379 |
380 | if (!mPoints.isEmpty()) {
381 | mGetBiggerCircleRadius = getMaxInternalRadius();
382 | mGetSmallerCircleRadius = getMinInternalRadius();
383 | postInvalidate();
384 | }
385 | }
386 |
387 | /**
388 | * 创建圆点
389 | *
390 | * 圆点坐标:(x0,y0)
391 | * 半径:r
392 | * 角度:a0
393 | *
394 | * 则圆上任一点为:(x1,y1)
395 | * x1 = x0 + r * cos(ao * 3.14 /180 )
396 | * y1 = y0 + r * sin(ao * 3.14 /180 )
397 | */
398 | private void createPoints() {
399 | mPoints.clear();
400 | for (int i = 0; i <= 360; i++) {
401 | if (i % mRadian == 0) {
402 | float x1 = getCircleX(i);
403 | float y1 = getCircleY(i);
404 | mPoints.add(new PointF(x1, y1));
405 | }
406 | }
407 | }
408 |
409 | /**
410 | * 是否是偶数圈
411 | *
412 | * @return
413 | */
414 | private boolean isEvenCyclic() {
415 | return mCyclic % 2 == 0;
416 | }
417 |
418 | /**
419 | * 获得以(x0,y0)为圆心的圆y坐标
420 | *
421 | * @param angle 角度
422 | * @return
423 | */
424 | private float getCircleY(int angle) {
425 | return y0 + mExternalR * (float) Math.sin(angle * 3.14 / 180);
426 | }
427 |
428 | /**
429 | * 获得以(x0,y0)为圆心的圆x坐标
430 | *
431 | * @param angle 角度
432 | * @return
433 | */
434 | private float getCircleX(int angle) {
435 | return x0 + mExternalR * (float) Math.cos(angle * 3.14 / 180);
436 | }
437 |
438 | /**
439 | * 获取theta值
440 | *
441 | * @param pointCenterLeft
442 | * @param pointCenterRight
443 | * @return
444 | */
445 | private double getTheta(PointF pointCenterLeft, PointF pointCenterRight) {
446 | double theta = Math.atan((pointCenterRight.y - pointCenterLeft.y) / (pointCenterRight.x - pointCenterLeft.x));
447 | return theta;
448 | }
449 |
450 | /**
451 | * 设置外圆半径
452 | *
453 | * @param progress
454 | */
455 | public void setExternalRadius(int progress) {
456 | int R = (int) ((progress / 100f) * MAX_EXTERNAL_R);
457 | mExternalR = R < MIN_EXTERNAL_R ? MIN_EXTERNAL_R : R;
458 | setShader();
459 | createPoints();
460 | }
461 |
462 | /**
463 | * 设置内圆半径
464 | *
465 | * @param progress
466 | */
467 | public void setInternalRadius(int progress) {
468 | int r = (int) ((progress / 100f) * MAX_INTERNAL_R);
469 | mInternalR = r < MIN_INTERNAL_R ? MIN_INTERNAL_R : r;
470 | }
471 |
472 | /**
473 | * 设置时间间隔
474 | *
475 | * @param progress
476 | */
477 | public void setDuration(int progress) {
478 | stop();
479 | int duration = (int) ((1 - progress / 100f) * MAX_DURATION);
480 | mDuration = duration < MIN_DURATION ? MIN_DURATION : duration;
481 | start();
482 | }
483 |
484 | /**
485 | * 最大内圆半径
486 | *
487 | * @return
488 | */
489 | private float getMaxInternalRadius() {
490 | return mInternalR / 10f * 14f;
491 | }
492 |
493 | /**
494 | * 最小内圆半径
495 | *
496 | * @return
497 | */
498 | private float getMinInternalRadius() {
499 | return mInternalR / 10f;
500 | }
501 |
502 | private int dp2px(float dp) {
503 | final float scale = getContext().getResources().getDisplayMetrics().density;
504 | return (int) (dp * scale + 0.5f);
505 | }
506 |
507 | }
--------------------------------------------------------------------------------