├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── varun │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── varunest │ │ │ └── loader │ │ │ └── loader │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── varunest │ │ └── loader │ │ └── loader │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── theglowingloader ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── attrs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── varunest │ │ │ └── loader │ │ │ ├── Constants.java │ │ │ ├── particles │ │ │ ├── ParticleView.java │ │ │ ├── Circle.java │ │ │ └── Triangle.java │ │ │ ├── Configuration.java │ │ │ ├── TheGlowingLoader.java │ │ │ └── animators │ │ │ ├── RippleAnimator.java │ │ │ └── LineAnimator.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── varunest │ │ │ └── theglowingloader │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── varunest │ │ └── theglowingloader │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── art ├── default.gif ├── grey_blue.gif └── black_green.gif ├── demo └── app-debug.apk ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── settings.gradle ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /theglowingloader/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /art/default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/art/default.gif -------------------------------------------------------------------------------- /art/grey_blue.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/art/grey_blue.gif -------------------------------------------------------------------------------- /demo/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/demo/app-debug.apk -------------------------------------------------------------------------------- /art/black_green.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/art/black_green.gif -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | The Glowing Loader 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /theglowingloader/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TheGlowingLoader 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/varunest/TheGlowingLoader/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /theglowingloader/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .idea/* 11 | .externalNativeBuild 12 | app/.idea/ 13 | app/local.properties 14 | -------------------------------------------------------------------------------- /theglowingloader/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #fff 4 | #FF5C5C 5 | #FFCA28 6 | #448AFF 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 16 20:49:02 IST 2018 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-7.4.2-bin.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #283593 7 | 8 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/Constants.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader; 2 | 3 | public class Constants { 4 | public static final int DEF_LINE_STROKE_WIDTH = 30; 5 | public static final int INVALID_DEG = 124988984; 6 | public static final float DEF_SHADOW_OPACITY = .23f; 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/particles/ParticleView.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader.particles; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | 6 | public abstract class ParticleView extends View { 7 | 8 | 9 | public ParticleView(Context context) { 10 | super(context); 11 | } 12 | 13 | public abstract void setPaintColor(int color); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/varunest/loader/loader/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.varun.loader; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/varun/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.varun; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.varunest.loader.R; 7 | import com.varunest.loader.TheGlowingLoader; 8 | 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /theglowingloader/src/test/java/com/varunest/theglowingloader/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.varunest.theglowingloader; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /theglowingloader/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /theglowingloader/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 27 5 | 6 | 7 | 8 | defaultConfig { 9 | minSdkVersion 14 10 | targetSdkVersion 27 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | 27 | implementation 'com.android.support:appcompat-v7:27.1.1' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 30 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 31 | } 32 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/varunest/loader/loader/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.varun.loader; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.varun.theglowingloader", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /theglowingloader/src/androidTest/java/com/varunest/theglowingloader/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.varunest.theglowingloader; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.varunest.theglowingloader.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /theglowingloader/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 27 7 | defaultConfig { 8 | applicationId "com.example.varun.theglowingloader" 9 | minSdkVersion 21 10 | targetSdkVersion 30 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(include: ['*.jar'], dir: 'libs') 25 | implementation 'com.android.support:appcompat-v7:27.1.1' 26 | implementation 'com.android.support.constraint:constraint-layout:1.1.2' 27 | testImplementation 'junit:junit:4.12' 28 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 30 | //implementation project(':theglowingloader') 31 | implementation 'com.github.varunest:TheGlowingLoader:1.0.7' 32 | } 33 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/particles/Circle.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader.particles; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.view.View; 8 | 9 | public class Circle extends ParticleView { 10 | private int w; 11 | private int h; 12 | private Paint paint; 13 | 14 | public Circle(Context context) { 15 | super(context); 16 | init(); 17 | } 18 | 19 | @Override 20 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 21 | super.onSizeChanged(w, h, oldw, oldh); 22 | this.w = w; 23 | this.h = h; 24 | } 25 | 26 | private void init() { 27 | paint = new Paint(Paint.ANTI_ALIAS_FLAG); 28 | paint.setStrokeCap(Paint.Cap.ROUND); 29 | paint.setStyle(Paint.Style.FILL); 30 | } 31 | 32 | @Override 33 | protected void onDraw(Canvas canvas) { 34 | super.onDraw(canvas); 35 | canvas.drawCircle(w / 2, h / 2, w / 2, paint); 36 | } 37 | 38 | public void setPaintColor(int paintColor) { 39 | paint.setColor(paintColor); 40 | invalidate(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/particles/Triangle.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader.particles; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | import android.graphics.Path; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.content.ContextCompat; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.widget.FrameLayout; 12 | 13 | import com.varunest.theglowingloader.R; 14 | 15 | public class Triangle extends ParticleView { 16 | private int w; 17 | private int h; 18 | private Paint paint; 19 | 20 | public Triangle(Context context) { 21 | super(context); 22 | init(); 23 | } 24 | 25 | @Override 26 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 27 | super.onSizeChanged(w, h, oldw, oldh); 28 | this.w = w; 29 | this.h = h; 30 | } 31 | 32 | private void init() { 33 | paint = new Paint(Paint.ANTI_ALIAS_FLAG); 34 | paint.setStrokeCap(Paint.Cap.ROUND); 35 | paint.setStyle(Paint.Style.FILL); 36 | } 37 | 38 | @Override 39 | protected void onDraw(Canvas canvas) { 40 | super.onDraw(canvas); 41 | Path path = new Path(); 42 | path.moveTo(w / 2, 0); 43 | path.lineTo(w, h); 44 | path.lineTo(0, h); 45 | path.lineTo(w / 2, 0); 46 | 47 | canvas.drawPath(path, paint); 48 | } 49 | 50 | public void setPaintColor(int paintColor) { 51 | paint.setColor(paintColor); 52 | invalidate(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | 3 | /** 4 | * The pluginManagement {repositories {...}} block configures the 5 | * repositories Gradle uses to search or download the Gradle plugins and 6 | * their transitive dependencies. Gradle pre-configures support for remote 7 | * repositories such as JCenter, Maven Central, and Ivy. You can also use 8 | * local repositories or define your own remote repositories. The code below 9 | * defines the Gradle Plugin Portal, Google's Maven repository, 10 | * and the Maven Central Repository as the repositories Gradle should use to look for its dependencies. 11 | */ 12 | 13 | repositories { 14 | gradlePluginPortal() 15 | google() 16 | mavenCentral() 17 | maven { url 'https://jitpack.io' } 18 | } 19 | } 20 | dependencyResolutionManagement { 21 | 22 | /** 23 | * The dependencyResolutionManagement { repositories {...}} 24 | * block is where you configure the repositories and dependencies used by 25 | * all modules in your project, such as libraries that you are using to 26 | * create your application. However, you should configure module-specific 27 | * dependencies in each module-level build.gradle file. For new projects, 28 | * Android Studio includes Google's Maven repository 29 | * and the Maven Central Repository by 30 | * default, but it does not configure any dependencies (unless you select a 31 | * template that requires some). 32 | */ 33 | 34 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 35 | repositories { 36 | google() 37 | mavenCentral() 38 | maven { url 'https://jitpack.io' } 39 | } 40 | } 41 | include ':app', ':theglowingloader' 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![platform](https://img.shields.io/badge/platform-Android-yellow.svg)](https://www.android.com) 2 | [![API](https://img.shields.io/badge/API-14%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=14) 3 | [![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?style=flat-square)](https://www.apache.org/licenses/LICENSE-2.0.html) 4 | [![](https://jitpack.io/v/varunest/TheGlowingLoader.svg)](https://jitpack.io/#varunest/TheGlowingLoader) 5 | 6 | 7 | # TheGlowingLoader 8 | Android Library which is the implementation of [The Glowing Loader](https://www.uplabs.com/posts/loader-fe7378f9-894d-4e6e-8340-968f41da9fa8) created by [Shashank Sahay](https://www.uplabs.com/shashanksahay). 9 | 10 | I have made it so that it can be easily customized. You can change line stroke width, line colors, particle colors, disable several effects etc. 11 | 12 | Library supports OS on API 14 and above. 13 | 14 | **[Download Demo Apk](demo/app-debug.apk)** 15 | 16 | **[Demo Video](https://www.youtube.com/watch?v=lSBTyfGWYAU)** 17 | 18 | #### Here is how the loader looks by default: 19 | ![Showcase Video](art/default.gif) 20 | 21 | #### But you can also tweak it according to your need: 22 | | Example A | Example B| 23 | | ------------- | ------------- | 24 | | ![Customized One](art/black_green.gif) | ![Customized Two](art/grey_blue.gif) | 25 | 26 | ## Dependency 27 | 28 | Add it in your root build.gradle at the end of repositories: 29 | 30 | ```groovy 31 | allprojects { 32 | repositories { 33 | ... 34 | maven { url 'https://jitpack.io' } 35 | } 36 | } 37 | ``` 38 | 39 | and then add dependency 40 | 41 | ```groovy 42 | dependencies { 43 | implementation 'com.github.varunest:TheGlowingLoader:1.0.7' 44 | } 45 | ``` 46 | 47 | ## Usage 48 | 49 | ```xml 50 | 57 | ``` 58 | 59 | ### Attributes 60 | 61 | ```xml 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ``` 73 | 74 | You can also access and modify all these attributes at runtime by getting the reference of `TheGlowingLoader` and calling its `setConfiguration` method. 75 | 76 | ## Inspiration 77 | This library was a result of challenge hosted by [Uplabs](https://www.uplabs.com/) 78 | 79 | ## Contribution 80 | Any contributions, large or small,features, bug fixes are welcomed and appreciated. Use pull requests, they will be thoroughly reviewed and discussed. 81 | 82 | ## License 83 | Library falls under [Apache 2.0](LICENSE.md) 84 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/Configuration.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader; 2 | 3 | import android.content.Context; 4 | import android.support.v4.content.ContextCompat; 5 | 6 | import com.varunest.theglowingloader.R; 7 | 8 | 9 | public class Configuration { 10 | private int line1Color; 11 | private int line2Color; 12 | private int rippleColor; 13 | private int particle1Color; 14 | private int particle2Color; 15 | private int particle3Color; 16 | private int lineStrokeWidth; 17 | private boolean disableShadows; 18 | private boolean disableRipple; 19 | private float shadowOpacity; 20 | 21 | Configuration() { 22 | 23 | } 24 | 25 | public Configuration(Context context) { 26 | disableShadows = false; 27 | disableRipple = false; 28 | shadowOpacity = Constants.DEF_SHADOW_OPACITY; 29 | line1Color = ContextCompat.getColor(context, R.color.white); 30 | line2Color = ContextCompat.getColor(context, R.color.red); 31 | lineStrokeWidth = Constants.DEF_LINE_STROKE_WIDTH; 32 | rippleColor = ContextCompat.getColor(context, R.color.white); 33 | particle1Color = ContextCompat.getColor(context, R.color.yellow); 34 | particle2Color = ContextCompat.getColor(context, R.color.white); 35 | particle3Color = ContextCompat.getColor(context, R.color.blue); 36 | } 37 | 38 | public int getLine1Color() { 39 | return line1Color; 40 | } 41 | 42 | public void setLine1Color(int line1Color) { 43 | this.line1Color = line1Color; 44 | } 45 | 46 | public int getLine2Color() { 47 | return line2Color; 48 | } 49 | 50 | public void setLine2Color(int line2Color) { 51 | this.line2Color = line2Color; 52 | } 53 | 54 | public int getRippleColor() { 55 | return rippleColor; 56 | } 57 | 58 | public void setRippleColor(int rippleColor) { 59 | this.rippleColor = rippleColor; 60 | } 61 | 62 | public int getParticle1Color() { 63 | return particle1Color; 64 | } 65 | 66 | public void setParticle1Color(int particle1Color) { 67 | this.particle1Color = particle1Color; 68 | } 69 | 70 | public int getParticle2Color() { 71 | return particle2Color; 72 | } 73 | 74 | public void setParticle2Color(int particle2Color) { 75 | this.particle2Color = particle2Color; 76 | } 77 | 78 | public int getParticle3Color() { 79 | return particle3Color; 80 | } 81 | 82 | public void setParticle3Color(int particle3Color) { 83 | this.particle3Color = particle3Color; 84 | } 85 | 86 | public int getLineStrokeWidth() { 87 | return lineStrokeWidth; 88 | } 89 | 90 | public void setLineStrokeWidth(int lineStrokeWidth) { 91 | this.lineStrokeWidth = lineStrokeWidth; 92 | } 93 | 94 | public boolean isDisableShadows() { 95 | return disableShadows; 96 | } 97 | 98 | public void setDisableShadows(boolean disableShadows) { 99 | this.disableShadows = disableShadows; 100 | } 101 | 102 | public boolean isDisableRipple() { 103 | return disableRipple; 104 | } 105 | 106 | public void setDisableRipple(boolean disableRipple) { 107 | this.disableRipple = disableRipple; 108 | } 109 | 110 | public float getShadowOpacity() { 111 | return shadowOpacity; 112 | } 113 | 114 | public void setShadowOpacity(float shadowOpacity) { 115 | if (shadowOpacity < 0.0f) { 116 | shadowOpacity = 0f; 117 | } else if (shadowOpacity > 1f) { 118 | shadowOpacity = 1f; 119 | } 120 | this.shadowOpacity = shadowOpacity; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/TheGlowingLoader.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Paint; 7 | import android.os.Build; 8 | import android.support.annotation.Nullable; 9 | import android.support.annotation.RequiresApi; 10 | import android.support.v4.content.ContextCompat; 11 | import android.util.AttributeSet; 12 | import android.widget.FrameLayout; 13 | 14 | import com.varunest.loader.animators.RippleAnimator; 15 | import com.varunest.loader.animators.LineAnimator; 16 | import com.varunest.theglowingloader.R; 17 | 18 | public class TheGlowingLoader extends FrameLayout { 19 | private Paint paint; 20 | private LineAnimator lineAnimator; 21 | private RippleAnimator rippleAnimator1, rippleAnimator2; 22 | private Configuration configuration; 23 | 24 | public TheGlowingLoader(Context context) { 25 | super(context); 26 | init(); 27 | } 28 | 29 | public TheGlowingLoader(Context context, @Nullable AttributeSet attrs) { 30 | super(context, attrs); 31 | getStuffFromXML(attrs); 32 | init(); 33 | } 34 | 35 | public TheGlowingLoader(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | getStuffFromXML(attrs); 38 | init(); 39 | } 40 | 41 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 42 | public TheGlowingLoader(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { 43 | super(context, attrs, defStyleAttr, defStyleRes); 44 | getStuffFromXML(attrs); 45 | init(); 46 | } 47 | 48 | private void getStuffFromXML(AttributeSet attrs) { 49 | configuration = new Configuration(); 50 | TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TheGlowingLoader); 51 | configuration.setLine1Color(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_line_1_color, R.color.white))); 52 | configuration.setLine2Color(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_line_2_color, R.color.red))); 53 | configuration.setRippleColor(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_ripple_color, R.color.white))); 54 | configuration.setParticle1Color(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_particle_1_color, R.color.yellow))); 55 | configuration.setParticle2Color(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_particle_2_color, R.color.white))); 56 | configuration.setParticle3Color(ContextCompat.getColor(getContext(), a.getResourceId(R.styleable.TheGlowingLoader_theglowingloader_particle_3_color, R.color.blue))); 57 | configuration.setLineStrokeWidth(a.getInt(R.styleable.TheGlowingLoader_theglowingloader_line_stroke_width, Constants.DEF_LINE_STROKE_WIDTH)); 58 | configuration.setDisableShadows(a.getBoolean(R.styleable.TheGlowingLoader_theglowingloader_disable_shadows, false)); 59 | configuration.setDisableRipple(a.getBoolean(R.styleable.TheGlowingLoader_theglowingloader_disable_ripple, false)); 60 | configuration.setShadowOpacity(a.getFloat(R.styleable.TheGlowingLoader_theglowingloader_shadow_opacity, Constants.DEF_SHADOW_OPACITY)); 61 | } 62 | 63 | public void setConfiguration(Configuration configuration) { 64 | this.configuration = configuration; 65 | init(); 66 | } 67 | 68 | private void init() { 69 | if (configuration == null) { 70 | configuration = new Configuration(getContext()); 71 | } 72 | setWillNotDraw(false); 73 | rippleAnimator1 = new RippleAnimator(TheGlowingLoader.this, configuration); 74 | rippleAnimator2 = new RippleAnimator(TheGlowingLoader.this, configuration); 75 | lineAnimator = new LineAnimator(TheGlowingLoader.this, configuration); 76 | paint = new Paint(Paint.ANTI_ALIAS_FLAG); 77 | paint.setStrokeCap(Paint.Cap.ROUND); 78 | } 79 | 80 | private void startAnimation() { 81 | lineAnimator.start(new LineAnimator.Callback() { 82 | @Override 83 | public void onValueUpdated() { 84 | invalidate(); 85 | } 86 | 87 | @Override 88 | public void startFirstCircleAnimation(float x, float y) { 89 | if (!configuration.isDisableRipple()) { 90 | rippleAnimator1.setCircleCenter(x, y); 91 | rippleAnimator1.start(new RippleAnimator.Callback() { 92 | @Override 93 | public void onValueUpdated() { 94 | invalidate(); 95 | } 96 | }, 60, 150, 270); 97 | } 98 | } 99 | 100 | @Override 101 | public void startSecondCircleAnimation(float x, float y) { 102 | if (!configuration.isDisableRipple()) { 103 | rippleAnimator2.setCircleCenter(x, y); 104 | rippleAnimator2.start(new RippleAnimator.Callback() { 105 | @Override 106 | public void onValueUpdated() { 107 | invalidate(); 108 | } 109 | }, -60, 0, Constants.INVALID_DEG); 110 | } 111 | 112 | } 113 | }); 114 | } 115 | 116 | @Override 117 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 118 | super.onSizeChanged(w, h, oldw, oldh); 119 | float offset = 0; 120 | float x1, x2, x3, x4, y1, y2, y3, y4; 121 | 122 | if (w > h) { 123 | offset = (w - h) * 80 / 100; 124 | } 125 | 126 | w = w - (int) offset; 127 | x1 = .05f * w + offset / 2; 128 | y1 = h / 2 + .15f * w; 129 | x2 = .30f * w + offset / 2; 130 | y2 = h / 2 + -.12f * w; 131 | x3 = .70f * w + offset / 2; 132 | y3 = h / 2 + .27f * w; 133 | x4 = .95f * w + offset / 2; 134 | y4 = h / 2 - .02f * w; 135 | 136 | float circleMaxRadius = (x4 - x1) * .18f; 137 | rippleAnimator2.setCircleMaxRadius(circleMaxRadius); 138 | rippleAnimator1.setCircleMaxRadius(circleMaxRadius); 139 | lineAnimator.updateEdgeCoordinates(x1, x2, x3, x4, y1, y2, y3, y4); 140 | startAnimation(); 141 | } 142 | 143 | @Override 144 | protected void onDraw(Canvas canvas) { 145 | super.onDraw(canvas); 146 | rippleAnimator1.draw(canvas, paint); 147 | rippleAnimator2.draw(canvas, paint); 148 | lineAnimator.draw(canvas, paint); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/animators/RippleAnimator.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader.animators; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.PropertyValuesHolder; 6 | import android.animation.ValueAnimator; 7 | import android.graphics.BlurMaskFilter; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.graphics.Path; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.view.animation.AccelerateInterpolator; 15 | import android.widget.FrameLayout; 16 | 17 | import com.varunest.loader.Configuration; 18 | import com.varunest.loader.Constants; 19 | import com.varunest.loader.particles.Circle; 20 | import com.varunest.loader.particles.ParticleView; 21 | import com.varunest.loader.particles.Triangle; 22 | 23 | public class RippleAnimator { 24 | private final static int PARTICLE_TYPE_TRIANGLE = 0; 25 | private final static int PARTICLE_TYPE_CIRCLE = 1; 26 | 27 | private float circleMaxRadius; 28 | private float circleRadius, circleRadius2; 29 | private int circleStroke, circleStroke2; 30 | private float circleAlpha, circleAlpha2; 31 | private float cX, cY; 32 | private FrameLayout view; 33 | private Configuration configuration; 34 | 35 | public RippleAnimator(FrameLayout v, Configuration configuration) { 36 | view = v; 37 | this.configuration = configuration; 38 | } 39 | 40 | public void setCircleMaxRadius(float r) { 41 | this.circleMaxRadius = r; 42 | } 43 | 44 | public void setCircleCenter(float x, float y) { 45 | cX = x; 46 | cY = y; 47 | } 48 | 49 | public void startCircleMajor(final Callback callback) { 50 | PropertyValuesHolder rp = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius); 51 | PropertyValuesHolder ap = PropertyValuesHolder.ofFloat("alpha", 1, 0); 52 | PropertyValuesHolder sp = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .15f), 0); 53 | 54 | ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(rp, ap, sp); 55 | va.setInterpolator(new AccelerateInterpolator(.4f)); 56 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 57 | @Override 58 | public void onAnimationUpdate(ValueAnimator animation) { 59 | circleRadius = (float) animation.getAnimatedValue("radius"); 60 | circleAlpha = (float) animation.getAnimatedValue("alpha"); 61 | circleStroke = (int) animation.getAnimatedValue("stroke"); 62 | callback.onValueUpdated(); 63 | } 64 | }); 65 | va.setDuration(450); 66 | va.start(); 67 | } 68 | 69 | public void startCircleMinor(final Callback callback) { 70 | PropertyValuesHolder rp2 = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius * .60f); 71 | PropertyValuesHolder ap2 = PropertyValuesHolder.ofFloat("alpha", 1, 0); 72 | PropertyValuesHolder sp2 = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .06f), 0); 73 | 74 | ValueAnimator va2 = ValueAnimator.ofPropertyValuesHolder(rp2, ap2, sp2); 75 | va2.setInterpolator(new AccelerateInterpolator(.4f)); 76 | va2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 77 | @Override 78 | public void onAnimationUpdate(ValueAnimator animation) { 79 | circleRadius2 = (float) animation.getAnimatedValue("radius"); 80 | circleAlpha2 = (float) animation.getAnimatedValue("alpha"); 81 | circleStroke2 = (int) animation.getAnimatedValue("stroke"); 82 | callback.onValueUpdated(); 83 | } 84 | }); 85 | va2.setDuration(380); 86 | va2.start(); 87 | } 88 | 89 | public void startParticleAnimation(float degree, int particleType, int particleColor) { 90 | float length = 2 * circleMaxRadius; 91 | float x = (float) (cX + length * Math.cos(Math.toRadians(degree))); 92 | float y = (float) (cY - length * Math.sin(Math.toRadians(degree))); 93 | final ParticleView particleView; 94 | switch (particleType) { 95 | case PARTICLE_TYPE_CIRCLE: 96 | particleView = new Circle(view.getContext()); 97 | break; 98 | case PARTICLE_TYPE_TRIANGLE: 99 | particleView = new Triangle(view.getContext()); 100 | break; 101 | default: 102 | particleView = new Circle(view.getContext()); 103 | } 104 | int size = (int) (circleMaxRadius * .3f); 105 | particleView.setLayoutParams(new ViewGroup.LayoutParams(size, size)); 106 | particleView.setPaintColor(particleColor); 107 | view.addView(particleView); 108 | 109 | PropertyValuesHolder sP = PropertyValuesHolder.ofFloat("scale", 0, 1); 110 | PropertyValuesHolder rP = PropertyValuesHolder.ofFloat("rotation", 0, 360); 111 | PropertyValuesHolder aP = PropertyValuesHolder.ofFloat("alpha", 1, 0); 112 | PropertyValuesHolder xP = PropertyValuesHolder.ofFloat("x", cX, x); 113 | PropertyValuesHolder yP = PropertyValuesHolder.ofFloat("y", cY, y); 114 | ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(xP, yP, sP, aP, rP); 115 | va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 116 | @Override 117 | public void onAnimationUpdate(ValueAnimator animation) { 118 | float x = (float) animation.getAnimatedValue("x"); 119 | float y = (float) animation.getAnimatedValue("y"); 120 | float scale = (float) animation.getAnimatedValue("scale"); 121 | float alpha = (float) animation.getAnimatedValue("alpha"); 122 | float rotation = (float) animation.getAnimatedValue("rotation"); 123 | particleView.setX(x); 124 | particleView.setY(y); 125 | particleView.setRotation(rotation); 126 | particleView.setScaleX(scale); 127 | particleView.setScaleY(scale); 128 | particleView.setAlpha(alpha); 129 | } 130 | }); 131 | va.setInterpolator(new AccelerateInterpolator(.4f)); 132 | va.setDuration(550); 133 | va.start(); 134 | 135 | va.addListener(new AnimatorListenerAdapter() { 136 | @Override 137 | public void onAnimationEnd(Animator animation) { 138 | super.onAnimationEnd(animation); 139 | view.removeView(particleView); 140 | } 141 | }); 142 | } 143 | 144 | public void start(final Callback callback, float degree1, float degree2, float degree3) { 145 | startCircleMajor(callback); 146 | startCircleMinor(callback); 147 | if (degree1 != Constants.INVALID_DEG) 148 | startParticleAnimation(degree1, PARTICLE_TYPE_TRIANGLE, configuration.getParticle1Color()); 149 | if (degree2 != Constants.INVALID_DEG) 150 | startParticleAnimation(degree2, PARTICLE_TYPE_CIRCLE, configuration.getParticle2Color()); 151 | if (degree3 != Constants.INVALID_DEG) 152 | startParticleAnimation(degree3, PARTICLE_TYPE_TRIANGLE, configuration.getParticle3Color()); 153 | } 154 | 155 | public void draw(Canvas canvas, Paint paint) { 156 | paint.setMaskFilter(null); 157 | paint.setStyle(Paint.Style.STROKE); 158 | 159 | paint.setColor(configuration.getRippleColor()); 160 | paint.setStrokeWidth(circleStroke); 161 | paint.setAlpha((int) (255 * circleAlpha)); 162 | canvas.drawCircle(cX, cY, circleRadius, paint); 163 | 164 | if (!configuration.isDisableShadows()) { 165 | paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.NORMAL)); 166 | paint.setStrokeWidth(.28f * circleRadius); 167 | paint.setAlpha((int) (255 * circleAlpha * configuration.getShadowOpacity())); 168 | canvas.drawCircle(cX, cY + 100, circleRadius, paint); 169 | } 170 | 171 | 172 | paint.setMaskFilter(null); 173 | paint.setColor(configuration.getRippleColor()); 174 | paint.setStrokeWidth(circleStroke2); 175 | paint.setAlpha((int) (255 * circleAlpha2)); 176 | canvas.drawCircle(cX, cY, circleRadius2, paint); 177 | } 178 | 179 | public interface Callback { 180 | void onValueUpdated(); 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /theglowingloader/src/main/java/com/varunest/loader/animators/LineAnimator.java: -------------------------------------------------------------------------------- 1 | package com.varunest.loader.animators; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorListenerAdapter; 5 | import android.animation.PropertyValuesHolder; 6 | import android.animation.ValueAnimator; 7 | import android.graphics.BlurMaskFilter; 8 | import android.graphics.Canvas; 9 | import android.graphics.Color; 10 | import android.graphics.Paint; 11 | import android.view.View; 12 | import android.view.animation.AccelerateInterpolator; 13 | import android.view.animation.DecelerateInterpolator; 14 | 15 | import com.varunest.loader.Configuration; 16 | 17 | public class LineAnimator { 18 | private View view; 19 | private Configuration configuration; 20 | private float x1, x2, x3, x4, y1, y2, y3, y4; 21 | private float wxa11, wxa12, wya11, wya12, wxa21, wya21, wxa22, wya22, wxa31, wya31, wxa32, wya32; 22 | private float rxa11, rxa12, rya11, rya12, rxa21, rya21, rxa22, rya22, rxa31, rya31, rxa32, rya32; 23 | 24 | public LineAnimator(View view, Configuration configuration) { 25 | this.view = view; 26 | this.configuration = configuration; 27 | } 28 | 29 | public void updateEdgeCoordinates(float x1, float x2, float x3, float x4, float y1, float y2, float y3, float y4) { 30 | this.x1 = x1; 31 | this.x2 = x2; 32 | this.x3 = x3; 33 | this.x4 = x4; 34 | this.y1 = y1; 35 | this.y2 = y2; 36 | this.y3 = y3; 37 | this.y4 = y4; 38 | } 39 | 40 | private void initLineCoordinates(boolean forward) { 41 | if (forward) { 42 | wxa11 = wxa12 = rxa11 = rxa12 = x1; 43 | wxa21 = wxa22 = rxa21 = rxa22 = x2; 44 | wya11 = wya12 = rya11 = rya12 = y1; 45 | wya21 = wya22 = rya21 = rya22 = y2; 46 | wxa31 = wxa32 = rxa31 = rxa32 = x3; 47 | wya31 = wya32 = rya31 = rya32 = y3; 48 | } else { 49 | wxa11 = wxa12 = rxa11 = rxa12 = x2; 50 | wxa21 = wxa22 = rxa21 = rxa22 = x3; 51 | wya11 = wya12 = rya11 = rya12 = y2; 52 | wya21 = wya22 = rya21 = rya22 = y3; 53 | wxa31 = wxa32 = rxa31 = rxa32 = x4; 54 | wya31 = wya32 = rya31 = rya32 = y4; 55 | } 56 | } 57 | 58 | public void draw(Canvas canvas, Paint paint) { 59 | paint.setStyle(Paint.Style.STROKE); 60 | paint.setMaskFilter(null); 61 | paint.setStrokeWidth(configuration.getLineStrokeWidth()); 62 | 63 | paint.setColor(configuration.getLine1Color()); 64 | if (wxa11 != wxa12 && wya11 != wya12) 65 | canvas.drawLine(wxa11, wya11, wxa12, wya12, paint); 66 | if (wxa21 != wxa22 && wya21 != wya22) 67 | canvas.drawLine(wxa21, wya21, wxa22, wya22, paint); 68 | if (wxa31 != wxa32 && wya31 != wya32) 69 | canvas.drawLine(wxa31, wya31, wxa32, wya32, paint); 70 | 71 | paint.setColor(configuration.getLine2Color()); 72 | if (rxa11 != rxa12 && rya11 != rya12) 73 | canvas.drawLine(rxa11, rya11, rxa12, rya12, paint); 74 | if (rxa21 != rxa22 && rya21 != rya22) 75 | canvas.drawLine(rxa21, rya21, rxa22, rya22, paint); 76 | if (rxa31 != rxa32 && rya31 != rya32) 77 | canvas.drawLine(rxa31, rya31, rxa32, rya32, paint); 78 | 79 | 80 | if (!configuration.isDisableShadows()) { 81 | paint.setMaskFilter(new BlurMaskFilter(70, BlurMaskFilter.Blur.NORMAL)); 82 | paint.setStrokeWidth(2.666f * configuration.getLineStrokeWidth()); 83 | paint.setColor(configuration.getLine1Color()); 84 | paint.setAlpha((int) (255 * configuration.getShadowOpacity())); 85 | if (wxa11 != wxa12 && wya11 != wya12) 86 | canvas.drawLine(wxa11, wya11 + 100, wxa12, wya12 + 100, paint); 87 | if (wxa21 != wxa22 && wya21 != wya22) 88 | canvas.drawLine(wxa21, wya21 + 100, wxa22, wya22 + 100, paint); 89 | if (wxa31 != wxa32 && wya31 != wya32) 90 | canvas.drawLine(wxa31, wya31 + 100, wxa32, wya32 + 100, paint); 91 | 92 | paint.setColor(configuration.getLine2Color()); 93 | paint.setAlpha((int) (255 * configuration.getShadowOpacity())); 94 | if (rxa11 != rxa12 && rya11 != rya12) 95 | canvas.drawLine(rxa11, rya11 + 100, rxa12, rya12 + 100, paint); 96 | if (rxa21 != rxa22 && rya21 != rya22) 97 | canvas.drawLine(rxa21, rya21 + 100, rxa22, rya22 + 100, paint); 98 | if (rxa31 != rxa32 && rya31 != rya32) 99 | canvas.drawLine(rxa31, rya31 + 100, rxa32, rya32 + 100, paint); 100 | } 101 | } 102 | 103 | public void start(final Callback callback) { 104 | playForwardAnimation(new LocalCallback() { 105 | @Override 106 | public void onValueUpdated() { 107 | callback.onValueUpdated(); 108 | } 109 | 110 | @Override 111 | public void startFirstCircleAnimation(float x, float y) { 112 | callback.startFirstCircleAnimation(x, y); 113 | } 114 | 115 | @Override 116 | public void startSecondCircleAnimation(float x, float y) { 117 | callback.startSecondCircleAnimation(x, y); 118 | } 119 | 120 | @Override 121 | public void onComplete() { 122 | 123 | } 124 | }); 125 | } 126 | 127 | private void playForwardAnimation(final LocalCallback callback) { 128 | playWhiteLineForward(new LocalCallback() { 129 | @Override 130 | public void onValueUpdated() { 131 | callback.onValueUpdated(); 132 | } 133 | 134 | @Override 135 | public void startFirstCircleAnimation(float x, float y) { 136 | callback.startFirstCircleAnimation(x, y); 137 | } 138 | 139 | @Override 140 | public void startSecondCircleAnimation(float x, float y) { 141 | callback.startSecondCircleAnimation(x, y); 142 | } 143 | 144 | 145 | @Override 146 | public void onComplete() { 147 | 148 | } 149 | }); 150 | 151 | view.postDelayed(new Runnable() { 152 | @Override 153 | public void run() { 154 | playRedLineForward(new LocalCallback() { 155 | @Override 156 | public void onValueUpdated() { 157 | callback.onValueUpdated(); 158 | } 159 | 160 | @Override 161 | public void startFirstCircleAnimation(float x, float y) { 162 | callback.startFirstCircleAnimation(x, y); 163 | } 164 | 165 | @Override 166 | public void startSecondCircleAnimation(float x, float y) { 167 | callback.startSecondCircleAnimation(x, y); 168 | } 169 | 170 | @Override 171 | public void onComplete() { 172 | playBackwardAnimation(callback); 173 | } 174 | }); 175 | } 176 | }, 183); 177 | } 178 | 179 | private void playBackwardAnimation(final LocalCallback callback) { 180 | playWhiteLineBackward(new LocalCallback() { 181 | @Override 182 | public void onValueUpdated() { 183 | callback.onValueUpdated(); 184 | } 185 | 186 | @Override 187 | public void startFirstCircleAnimation(float x, float y) { 188 | callback.startFirstCircleAnimation(x, y); 189 | } 190 | 191 | @Override 192 | public void startSecondCircleAnimation(float x, float y) { 193 | callback.startSecondCircleAnimation(x, y); 194 | } 195 | 196 | @Override 197 | public void onComplete() { 198 | 199 | } 200 | }); 201 | 202 | view.postDelayed(new Runnable() { 203 | @Override 204 | public void run() { 205 | playRedLineBackward(new LocalCallback() { 206 | @Override 207 | public void onValueUpdated() { 208 | callback.onValueUpdated(); 209 | } 210 | 211 | @Override 212 | public void startFirstCircleAnimation(float x, float y) { 213 | callback.startFirstCircleAnimation(x, y); 214 | } 215 | 216 | @Override 217 | public void startSecondCircleAnimation(float x, float y) { 218 | callback.startSecondCircleAnimation(x, y); 219 | } 220 | 221 | @Override 222 | public void onComplete() { 223 | playForwardAnimation(callback); 224 | } 225 | }); 226 | } 227 | }, 183); 228 | } 229 | 230 | private void playWhiteLineForward(final LocalCallback callback) { 231 | initLineCoordinates(true); 232 | ValueAnimator va11, va12, va21, va22, va31, va32; 233 | PropertyValuesHolder px1 = PropertyValuesHolder.ofFloat("X", x1, x2); 234 | PropertyValuesHolder py1 = PropertyValuesHolder.ofFloat("Y", y1, y2); 235 | PropertyValuesHolder px2 = PropertyValuesHolder.ofFloat("X", x2, x3); 236 | PropertyValuesHolder py2 = PropertyValuesHolder.ofFloat("Y", y2, y3); 237 | PropertyValuesHolder px3 = PropertyValuesHolder.ofFloat("X", x3, x4); 238 | PropertyValuesHolder py3 = PropertyValuesHolder.ofFloat("Y", y3, y4); 239 | 240 | va11 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 241 | va11.setInterpolator(new AccelerateInterpolator(1.8f)); 242 | va11.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 243 | @Override 244 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 245 | wxa12 = (float) valueAnimator.getAnimatedValue("X"); 246 | wya12 = (float) valueAnimator.getAnimatedValue("Y"); 247 | callback.onValueUpdated(); 248 | } 249 | }); 250 | 251 | va12 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 252 | va12.setInterpolator(new AccelerateInterpolator(1.8f)); 253 | va12.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 254 | @Override 255 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 256 | wxa11 = (float) valueAnimator.getAnimatedValue("X"); 257 | wya11 = (float) valueAnimator.getAnimatedValue("Y"); 258 | callback.onValueUpdated(); 259 | } 260 | }); 261 | 262 | 263 | va21 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 264 | va21.setInterpolator(new AccelerateInterpolator(1.8f)); 265 | va21.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 266 | @Override 267 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 268 | wxa22 = (float) valueAnimator.getAnimatedValue("X"); 269 | wya22 = (float) valueAnimator.getAnimatedValue("Y"); 270 | callback.onValueUpdated(); 271 | } 272 | }); 273 | 274 | va22 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 275 | va22.setInterpolator(new AccelerateInterpolator(1.8f)); 276 | va22.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 277 | @Override 278 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 279 | wxa21 = (float) valueAnimator.getAnimatedValue("X"); 280 | wya21 = (float) valueAnimator.getAnimatedValue("Y"); 281 | callback.onValueUpdated(); 282 | } 283 | }); 284 | 285 | va31 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 286 | va31.setInterpolator(new DecelerateInterpolator(1.8f)); 287 | va31.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 288 | @Override 289 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 290 | wxa32 = (float) valueAnimator.getAnimatedValue("X"); 291 | wya32 = (float) valueAnimator.getAnimatedValue("Y"); 292 | callback.onValueUpdated(); 293 | } 294 | }); 295 | 296 | va32 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 297 | va32.setInterpolator(new DecelerateInterpolator(1.8f)); 298 | va32.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 299 | @Override 300 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 301 | wxa31 = (float) valueAnimator.getAnimatedValue("X"); 302 | wya31 = (float) valueAnimator.getAnimatedValue("Y"); 303 | callback.onValueUpdated(); 304 | } 305 | }); 306 | 307 | int tw11 = 450; 308 | int tw21 = 143; 309 | int tw31 = 510; 310 | va11.setDuration(tw11); 311 | va21.setDuration(tw21); 312 | va31.setDuration(tw31); 313 | 314 | va21.setStartDelay(tw11); 315 | va31.setStartDelay(tw11 + tw21); 316 | 317 | int tw12 = 510; 318 | int tw22 = 165; 319 | int tw32 = 433; 320 | va12.setDuration(tw12); 321 | va22.setDuration(tw22); 322 | va32.setDuration(tw32); 323 | 324 | 325 | va22.setStartDelay(tw12); 326 | va32.setStartDelay(tw12 + tw22); 327 | 328 | va11.start(); 329 | va12.start(); 330 | va21.start(); 331 | va22.start(); 332 | va31.start(); 333 | va32.start(); 334 | 335 | va12.addListener(new AnimatorListenerAdapter() { 336 | @Override 337 | public void onAnimationEnd(Animator animation) { 338 | super.onAnimationEnd(animation); 339 | callback.startFirstCircleAnimation(x2, y2); 340 | } 341 | }); 342 | 343 | va22.addListener(new AnimatorListenerAdapter() { 344 | @Override 345 | public void onAnimationEnd(Animator animation) { 346 | super.onAnimationEnd(animation); 347 | callback.startSecondCircleAnimation(x3, y3); 348 | } 349 | }); 350 | 351 | va32.addListener(new AnimatorListenerAdapter() { 352 | @Override 353 | public void onAnimationEnd(Animator animation) { 354 | super.onAnimationEnd(animation); 355 | callback.onComplete(); 356 | } 357 | }); 358 | } 359 | 360 | private void playWhiteLineBackward(final LocalCallback callback) { 361 | initLineCoordinates(false); 362 | ValueAnimator va11, va12, va21, va22, va31, va32; 363 | PropertyValuesHolder px1 = PropertyValuesHolder.ofFloat("X", x4, x3); 364 | PropertyValuesHolder py1 = PropertyValuesHolder.ofFloat("Y", y4, y3); 365 | PropertyValuesHolder px2 = PropertyValuesHolder.ofFloat("X", x3, x2); 366 | PropertyValuesHolder py2 = PropertyValuesHolder.ofFloat("Y", y3, y2); 367 | PropertyValuesHolder px3 = PropertyValuesHolder.ofFloat("X", x2, x1); 368 | PropertyValuesHolder py3 = PropertyValuesHolder.ofFloat("Y", y2, y1); 369 | 370 | va11 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 371 | va11.setInterpolator(new AccelerateInterpolator(1.8f)); 372 | va11.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 373 | @Override 374 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 375 | wxa32 = (float) valueAnimator.getAnimatedValue("X"); 376 | wya32 = (float) valueAnimator.getAnimatedValue("Y"); 377 | callback.onValueUpdated(); 378 | } 379 | }); 380 | 381 | va12 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 382 | va12.setInterpolator(new AccelerateInterpolator(1.8f)); 383 | va12.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 384 | @Override 385 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 386 | wxa31 = (float) valueAnimator.getAnimatedValue("X"); 387 | wya31 = (float) valueAnimator.getAnimatedValue("Y"); 388 | callback.onValueUpdated(); 389 | } 390 | }); 391 | 392 | va21 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 393 | va21.setInterpolator(new AccelerateInterpolator(1.8f)); 394 | va21.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 395 | @Override 396 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 397 | wxa22 = (float) valueAnimator.getAnimatedValue("X"); 398 | wya22 = (float) valueAnimator.getAnimatedValue("Y"); 399 | callback.onValueUpdated(); 400 | } 401 | }); 402 | 403 | va22 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 404 | va22.setInterpolator(new AccelerateInterpolator(1.8f)); 405 | va22.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 406 | @Override 407 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 408 | wxa21 = (float) valueAnimator.getAnimatedValue("X"); 409 | wya21 = (float) valueAnimator.getAnimatedValue("Y"); 410 | callback.onValueUpdated(); 411 | } 412 | }); 413 | 414 | va31 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 415 | va31.setInterpolator(new DecelerateInterpolator(1.8f)); 416 | va31.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 417 | @Override 418 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 419 | wxa12 = (float) valueAnimator.getAnimatedValue("X"); 420 | wya12 = (float) valueAnimator.getAnimatedValue("Y"); 421 | callback.onValueUpdated(); 422 | } 423 | }); 424 | 425 | va32 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 426 | va32.setInterpolator(new DecelerateInterpolator(1.8f)); 427 | va32.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 428 | @Override 429 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 430 | wxa11 = (float) valueAnimator.getAnimatedValue("X"); 431 | wya11 = (float) valueAnimator.getAnimatedValue("Y"); 432 | callback.onValueUpdated(); 433 | } 434 | }); 435 | 436 | int tw11 = 450; 437 | int tw21 = 143; 438 | int tw31 = 510; 439 | va11.setDuration(tw11); 440 | va21.setDuration(tw21); 441 | va31.setDuration(tw31); 442 | 443 | va21.setStartDelay(tw11); 444 | va31.setStartDelay(tw11 + tw21); 445 | 446 | int tw12 = 510; 447 | int tw22 = 165; 448 | int tw32 = 433; 449 | va12.setDuration(tw12); 450 | va22.setDuration(tw22); 451 | va32.setDuration(tw32); 452 | 453 | 454 | va22.setStartDelay(tw12); 455 | va32.setStartDelay(tw12 + tw22); 456 | 457 | va11.start(); 458 | va21.start(); 459 | va31.start(); 460 | 461 | va12.start(); 462 | va22.start(); 463 | va32.start(); 464 | 465 | 466 | va12.addListener(new AnimatorListenerAdapter() { 467 | @Override 468 | public void onAnimationEnd(Animator animation) { 469 | super.onAnimationEnd(animation); 470 | callback.startSecondCircleAnimation(x3, y3); 471 | } 472 | }); 473 | 474 | va22.addListener(new AnimatorListenerAdapter() { 475 | @Override 476 | public void onAnimationEnd(Animator animation) { 477 | super.onAnimationEnd(animation); 478 | callback.startFirstCircleAnimation(x2, y2); 479 | } 480 | }); 481 | 482 | va32.addListener(new AnimatorListenerAdapter() { 483 | @Override 484 | public void onAnimationEnd(Animator animation) { 485 | super.onAnimationEnd(animation); 486 | callback.onComplete(); 487 | } 488 | }); 489 | } 490 | 491 | private void playRedLineForward(final LocalCallback callback) { 492 | initLineCoordinates(true); 493 | ValueAnimator va11, va12, va21, va22, va31, va32; 494 | PropertyValuesHolder px1 = PropertyValuesHolder.ofFloat("X", x1, x2); 495 | PropertyValuesHolder py1 = PropertyValuesHolder.ofFloat("Y", y1, y2); 496 | PropertyValuesHolder px2 = PropertyValuesHolder.ofFloat("X", x2, x3); 497 | PropertyValuesHolder py2 = PropertyValuesHolder.ofFloat("Y", y2, y3); 498 | PropertyValuesHolder px3 = PropertyValuesHolder.ofFloat("X", x3, x4); 499 | PropertyValuesHolder py3 = PropertyValuesHolder.ofFloat("Y", y3, y4); 500 | 501 | va11 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 502 | va11.setInterpolator(new AccelerateInterpolator(1.8f)); 503 | va11.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 504 | @Override 505 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 506 | rxa12 = (float) valueAnimator.getAnimatedValue("X"); 507 | rya12 = (float) valueAnimator.getAnimatedValue("Y"); 508 | callback.onValueUpdated(); 509 | } 510 | }); 511 | 512 | va12 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 513 | va12.setInterpolator(new AccelerateInterpolator(1.8f)); 514 | va12.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 515 | @Override 516 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 517 | rxa11 = (float) valueAnimator.getAnimatedValue("X"); 518 | rya11 = (float) valueAnimator.getAnimatedValue("Y"); 519 | callback.onValueUpdated(); 520 | } 521 | }); 522 | 523 | va21 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 524 | va21.setInterpolator(new AccelerateInterpolator(1.8f)); 525 | va21.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 526 | @Override 527 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 528 | rxa22 = (float) valueAnimator.getAnimatedValue("X"); 529 | rya22 = (float) valueAnimator.getAnimatedValue("Y"); 530 | callback.onValueUpdated(); 531 | } 532 | }); 533 | 534 | va22 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 535 | va22.setInterpolator(new AccelerateInterpolator(1.8f)); 536 | va22.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 537 | @Override 538 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 539 | rxa21 = (float) valueAnimator.getAnimatedValue("X"); 540 | rya21 = (float) valueAnimator.getAnimatedValue("Y"); 541 | callback.onValueUpdated(); 542 | } 543 | }); 544 | 545 | va31 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 546 | va31.setInterpolator(new DecelerateInterpolator(1.8f)); 547 | va31.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 548 | @Override 549 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 550 | rxa32 = (float) valueAnimator.getAnimatedValue("X"); 551 | rya32 = (float) valueAnimator.getAnimatedValue("Y"); 552 | callback.onValueUpdated(); 553 | } 554 | }); 555 | 556 | va32 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 557 | va32.setInterpolator(new DecelerateInterpolator(1.8f)); 558 | va32.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 559 | @Override 560 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 561 | rxa31 = (float) valueAnimator.getAnimatedValue("X"); 562 | rya31 = (float) valueAnimator.getAnimatedValue("Y"); 563 | callback.onValueUpdated(); 564 | } 565 | }); 566 | 567 | 568 | int tw11 = 450; 569 | int tw21 = 143; 570 | int tw31 = 510; 571 | va11.setDuration(tw11); 572 | va21.setDuration(tw21); 573 | va31.setDuration(tw31); 574 | 575 | va21.setStartDelay(tw11); 576 | va31.setStartDelay(tw11 + tw21); 577 | 578 | int tw12 = 510; 579 | int tw22 = 165; 580 | int tw32 = 433; 581 | va12.setDuration(tw12); 582 | va22.setDuration(tw22); 583 | va32.setDuration(tw32); 584 | 585 | 586 | va22.setStartDelay(tw12); 587 | va32.setStartDelay(tw12 + tw22); 588 | 589 | va11.start(); 590 | va12.start(); 591 | va21.start(); 592 | va22.start(); 593 | va31.start(); 594 | va32.start(); 595 | 596 | va32.addListener(new AnimatorListenerAdapter() { 597 | @Override 598 | public void onAnimationEnd(Animator animation) { 599 | super.onAnimationEnd(animation); 600 | callback.onComplete(); 601 | } 602 | }); 603 | } 604 | 605 | private void playRedLineBackward(final LocalCallback callback) { 606 | initLineCoordinates(false); 607 | ValueAnimator va11, va12, va21, va22, va31, va32; 608 | PropertyValuesHolder px1 = PropertyValuesHolder.ofFloat("X", x4, x3); 609 | PropertyValuesHolder py1 = PropertyValuesHolder.ofFloat("Y", y4, y3); 610 | PropertyValuesHolder px2 = PropertyValuesHolder.ofFloat("X", x3, x2); 611 | PropertyValuesHolder py2 = PropertyValuesHolder.ofFloat("Y", y3, y2); 612 | PropertyValuesHolder px3 = PropertyValuesHolder.ofFloat("X", x2, x1); 613 | PropertyValuesHolder py3 = PropertyValuesHolder.ofFloat("Y", y2, y1); 614 | 615 | va11 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 616 | va11.setInterpolator(new AccelerateInterpolator(1.8f)); 617 | va11.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 618 | @Override 619 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 620 | rxa32 = (float) valueAnimator.getAnimatedValue("X"); 621 | rya32 = (float) valueAnimator.getAnimatedValue("Y"); 622 | callback.onValueUpdated(); 623 | } 624 | }); 625 | 626 | va12 = ValueAnimator.ofPropertyValuesHolder(px1, py1); 627 | va12.setInterpolator(new AccelerateInterpolator(1.8f)); 628 | va12.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 629 | @Override 630 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 631 | rxa31 = (float) valueAnimator.getAnimatedValue("X"); 632 | rya31 = (float) valueAnimator.getAnimatedValue("Y"); 633 | callback.onValueUpdated(); 634 | } 635 | }); 636 | 637 | va21 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 638 | va21.setInterpolator(new AccelerateInterpolator(1.8f)); 639 | va21.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 640 | @Override 641 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 642 | rxa22 = (float) valueAnimator.getAnimatedValue("X"); 643 | rya22 = (float) valueAnimator.getAnimatedValue("Y"); 644 | callback.onValueUpdated(); 645 | } 646 | }); 647 | 648 | va22 = ValueAnimator.ofPropertyValuesHolder(px2, py2); 649 | va22.setInterpolator(new AccelerateInterpolator(1.8f)); 650 | va22.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 651 | @Override 652 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 653 | rxa21 = (float) valueAnimator.getAnimatedValue("X"); 654 | rya21 = (float) valueAnimator.getAnimatedValue("Y"); 655 | callback.onValueUpdated(); 656 | } 657 | }); 658 | 659 | va31 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 660 | va31.setInterpolator(new DecelerateInterpolator(1.8f)); 661 | va31.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 662 | @Override 663 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 664 | rxa12 = (float) valueAnimator.getAnimatedValue("X"); 665 | rya12 = (float) valueAnimator.getAnimatedValue("Y"); 666 | callback.onValueUpdated(); 667 | } 668 | }); 669 | 670 | va32 = ValueAnimator.ofPropertyValuesHolder(px3, py3); 671 | va32.setInterpolator(new DecelerateInterpolator(1.8f)); 672 | va32.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 673 | @Override 674 | public void onAnimationUpdate(ValueAnimator valueAnimator) { 675 | rxa11 = (float) valueAnimator.getAnimatedValue("X"); 676 | rya11 = (float) valueAnimator.getAnimatedValue("Y"); 677 | callback.onValueUpdated(); 678 | } 679 | }); 680 | 681 | int tw11 = 450; 682 | int tw21 = 143; 683 | int tw31 = 510; 684 | va11.setDuration(tw11); 685 | va21.setDuration(tw21); 686 | va31.setDuration(tw31); 687 | 688 | va21.setStartDelay(tw11); 689 | va31.setStartDelay(tw11 + tw21); 690 | 691 | int tw12 = 510; 692 | int tw22 = 165; 693 | int tw32 = 433; 694 | va12.setDuration(tw12); 695 | va22.setDuration(tw22); 696 | va32.setDuration(tw32); 697 | 698 | 699 | va22.setStartDelay(tw12); 700 | va32.setStartDelay(tw12 + tw22); 701 | 702 | va11.start(); 703 | va12.start(); 704 | va21.start(); 705 | va22.start(); 706 | va31.start(); 707 | va32.start(); 708 | 709 | va32.addListener(new AnimatorListenerAdapter() { 710 | @Override 711 | public void onAnimationEnd(Animator animation) { 712 | super.onAnimationEnd(animation); 713 | callback.onComplete(); 714 | } 715 | }); 716 | } 717 | 718 | private interface LocalCallback { 719 | void onValueUpdated(); 720 | 721 | void startFirstCircleAnimation(float x, float y); 722 | 723 | void startSecondCircleAnimation(float x, float y); 724 | 725 | void onComplete(); 726 | } 727 | 728 | public interface Callback { 729 | void onValueUpdated(); 730 | 731 | void startFirstCircleAnimation(float x, float y); 732 | 733 | void startSecondCircleAnimation(float x, float y); 734 | } 735 | } 736 | --------------------------------------------------------------------------------