├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── simon │ │ │ └── core │ │ │ └── animationtools │ │ │ ├── animator │ │ │ ├── AnimUtils.java │ │ │ ├── AnimatorBuilder.java │ │ │ ├── ArgbEvaluator.java │ │ │ ├── DrawableAnimatorBuilder.java │ │ │ ├── FloatProperty.java │ │ │ ├── IntProperty.java │ │ │ ├── ViewAnimatorBuilder.java │ │ │ └── interpolator │ │ │ │ ├── Ease.java │ │ │ │ ├── KeyFrameInterpolator.java │ │ │ │ ├── PathInterpolatorCompat.java │ │ │ │ ├── PathInterpolatorCompatApi21.java │ │ │ │ ├── PathInterpolatorCompatBase.java │ │ │ │ └── PathInterpolatorDonut.java │ │ │ ├── drawable │ │ │ ├── AnimDrawableContainer.java │ │ │ ├── AnimationDrawable.java │ │ │ ├── container │ │ │ │ ├── ChasingDots.java │ │ │ │ ├── CubeGrid.java │ │ │ │ ├── DoubleCircleBounce.java │ │ │ │ ├── FoldingCube.java │ │ │ │ ├── MultiplePulse.java │ │ │ │ ├── RotatingDots.java │ │ │ │ ├── RotatingDots2.java │ │ │ │ ├── ThreeBounce.java │ │ │ │ ├── WanderingCubes.java │ │ │ │ └── WavingBars.java │ │ │ └── shape │ │ │ │ ├── CircleAnimDrawable.java │ │ │ │ ├── Pulse.java │ │ │ │ ├── RectAnimDrawable.java │ │ │ │ ├── RotatingPlane.java │ │ │ │ └── ShapeAnimDrawable.java │ │ │ ├── utils │ │ │ └── ShapeUtils.java │ │ │ └── view │ │ │ └── InterpolatorCanvas.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── simon │ └── core │ └── animationtools │ └── ExampleUnitTest.java ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── simon │ │ └── animationtools │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── simon │ │ │ └── animationtools │ │ │ ├── Assets.java │ │ │ ├── DetailActivity.java │ │ │ ├── MainActivity.java │ │ │ └── SquareFrameLayout.java │ └── res │ │ ├── layout │ │ ├── activity_detail.xml │ │ ├── activity_main.xml │ │ ├── item_list.xml │ │ └── item_pager.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── simon │ └── animationtools │ └── ExampleUnitTest.java ├── screen_record.gif ├── settings.gradle └── wavingbars_sample.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android动画工具箱 2 | ### 预览 3 | 4 | 5 | 6 | ### 使用方法 7 | 8 | #### 导入  9 | 10 | > Step 1. 添加JitPack repository到你的主项目build.gradle文件 11 | 12 | ``` 13 | allprojects { 14 | repositories { 15 | ... 16 | maven { url 'https://jitpack.io' } 17 | } 18 | } 19 | ``` 20 | > Step 2. 添加依赖 21 | 22 | ``` 23 | dependencies { 24 | compile 'com.github.liuwei1993:AndroidAnimationTools:1.0' 25 | } 26 | ``` 27 | #### 示例: 28 | 29 | - [WavingBars](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/WavingBars.java) 30 | - [WanderingCubes](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/WanderingCubes.java) 31 | - [FoldingCube](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/FoldingCube.java) 32 | - [CubeGrid](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/CubeGrid.java) 33 | - [RotatingPlane](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/RotatingPlane.java) 34 | - [RotatingDots](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/RotatingDots.java) 35 | - [RotatingDots2](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/RotatingDots2.java) 36 | - [DoubleCircleBounce](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/DoubleCircleBounce.java) 37 | - [MultiplePulse](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/MultiplePulse.java) 38 | - [ThreeBounce](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/ThreeBounce.java) 39 | - [ChasingDots](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/container/ChasingDots.java) 40 | 41 | #### 示例使用: 42 | java中: 43 | ``` 44 | ImageView imageView = (ImageView) itemView.findViewById(R.id.image); 45 | AnimationDrawable drawable = new WavingBars(); 46 | imageView.setImageDrawable(drawable); 47 | drawable.start(); 48 | ``` 49 | layout中: 50 | ``` 51 | 52 | 56 | 57 | 63 | 64 | 65 | ``` 66 | 效果: 67 | 68 | 69 | 70 | ### 实现原理 71 | 72 | #### 核心类: 73 | 74 | > 该库主要有两个重要部分组成一个是drawable系列,用于绘制图形,一个是animator系列,用于方便的构造Animator. 75 | 76 | drawable包下 77 | - [AnimationDrawable](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/AnimationDrawable.java) 78 | - [AnimDrawableContainer](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/drawable/AnimDrawableContainer.java) 79 | 80 | animator包下 81 | - [DrawableAnimatorBuilder](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/animator/DrawableAnimatorBuilder.java) 82 | - [ViewAnimatorBuilder](https://github.com/liuwei1993/AndroidAnimationTools/blob/master/library/src/main/java/com/simon/core/animationtools/animator/ViewAnimatorBuilder.java) 83 | 84 | > 继承AnimatonDrawable类后使用DrawableAnimatorBuilder可以使Drawable具备动画效果,而AnimDrawableContainer自身继承于AnimationDrawable并且可以管理多个AnimatonDrawable从而实现复杂动画效果. 85 | > 而interpolator包下的工具类可以帮助我们高效的创建复杂的Interpolator. 86 | > 使用者可参考示例代码来自定义各种复杂动画效果. 87 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | maven { url 'https://jitpack.io' } 19 | jcenter() 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 18 18:58:09 CST 2017 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-3.3-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group = 'com.github.liuwei1993' 4 | version = '1.0' 5 | android { 6 | compileSdkVersion 25 7 | buildToolsVersion "25.0.2" 8 | 9 | defaultConfig { 10 | minSdkVersion 15 11 | targetSdkVersion 25 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 29 | exclude group: 'com.android.support', module: 'support-annotations' 30 | }) 31 | compile 'com.android.support:appcompat-v7:25.2.0' 32 | testCompile 'junit:junit:4.12' 33 | } 34 | 35 | // 指定编码 36 | tasks.withType(JavaCompile) { 37 | options.encoding = "UTF-8" 38 | } 39 | 40 | // 打包源码 41 | task sourcesJar(type: Jar) { 42 | from android.sourceSets.main.java.srcDirs 43 | classifier = 'sources' 44 | } 45 | 46 | task javadoc(type: Javadoc) { 47 | failOnError false 48 | source = android.sourceSets.main.java.sourceFiles 49 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 50 | classpath += configurations.compile 51 | } 52 | 53 | // 制作文档(Javadoc) 54 | task javadocJar(type: Jar, dependsOn: javadoc) { 55 | classifier = 'javadoc' 56 | from javadoc.destinationDir 57 | } 58 | 59 | artifacts { 60 | archives sourcesJar 61 | archives javadocJar 62 | } 63 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/simon/developer/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/AnimUtils.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ValueAnimator; 5 | import android.graphics.drawable.Animatable; 6 | import android.graphics.drawable.Drawable; 7 | 8 | 9 | public class AnimUtils { 10 | 11 | public static void start(Animator animator) { 12 | if (animator != null && !animator.isStarted()) { 13 | animator.start(); 14 | } 15 | } 16 | 17 | public static void stop(Animator animator) { 18 | if (animator != null && !animator.isRunning()) { 19 | animator.end(); 20 | } 21 | } 22 | 23 | public static void start(Drawable... animList) { 24 | for (Drawable drawable : animList) { 25 | if(drawable instanceof Animatable) { 26 | ((Animatable) drawable).start(); 27 | } 28 | } 29 | } 30 | 31 | public static void stop(Drawable... animList) { 32 | for (Drawable drawable : animList) { 33 | if(drawable instanceof Animatable) { 34 | ((Animatable) drawable).stop(); 35 | } 36 | } 37 | } 38 | 39 | public static boolean isRunning(Drawable... animList) { 40 | for (Drawable drawable : animList) { 41 | if (drawable instanceof Animatable && ((Animatable) drawable).isRunning()) { 42 | return true; 43 | } 44 | } 45 | return false; 46 | } 47 | 48 | public static boolean isRunning(ValueAnimator animator) { 49 | return animator != null && animator.isRunning(); 50 | } 51 | 52 | public static boolean isStarted(ValueAnimator animator) { 53 | return animator != null && animator.isStarted(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/AnimatorBuilder.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.animation.Keyframe; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.PropertyValuesHolder; 6 | import android.util.Log; 7 | import android.util.Property; 8 | import android.view.animation.Animation; 9 | import android.view.animation.Interpolator; 10 | 11 | import com.simon.core.animationtools.animator.interpolator.KeyFrameInterpolator; 12 | 13 | import java.util.HashMap; 14 | import java.util.Locale; 15 | import java.util.Map; 16 | 17 | 18 | /** 19 | * 20 | * Created by simon on 17-6-7. 21 | */ 22 | 23 | public abstract class AnimatorBuilder { 24 | 25 | 26 | private static final String TAG = "AnimatorBuilder"; 27 | private Object target; 28 | private Interpolator interpolator; 29 | private int repeatCount = Animation.INFINITE; 30 | private long duration = 2000; 31 | private int startFrame = 0; 32 | private Map fds = new HashMap<>(); 33 | 34 | 35 | class FrameData { 36 | FrameData(float[] fractions, Property property, T[] values) { 37 | this.fractions = fractions; 38 | this.property = property; 39 | this.values = values; 40 | } 41 | 42 | float[] fractions; 43 | Property property; 44 | T[] values; 45 | } 46 | 47 | private class IntFrameData extends FrameData { 48 | 49 | IntFrameData(float[] fractions, Property property, Integer[] values) { 50 | super(fractions, property, values); 51 | } 52 | } 53 | 54 | private class FloatFrameData extends FrameData { 55 | 56 | FloatFrameData(float[] fractions, Property property, Float[] values) { 57 | super(fractions, property, values); 58 | } 59 | } 60 | 61 | public AnimatorBuilder(Object target) { 62 | this.target = target; 63 | } 64 | 65 | protected abstract Property getScaleProperty(); 66 | 67 | public AnimatorBuilder scale(float fractions[], Float... scale) { 68 | holder(fractions, getScaleProperty(), scale); 69 | return this; 70 | } 71 | protected abstract Property getAlphaProperty(); 72 | 73 | 74 | public AnimatorBuilder alpha(float fractions[], Float... alpha) { 75 | holder(fractions, getAlphaProperty(), alpha); 76 | return this; 77 | } 78 | 79 | protected abstract Property getScaleXProperty(); 80 | 81 | @SuppressWarnings("unused") 82 | public AnimatorBuilder scaleX(float fractions[], Float... scaleX) { 83 | holder(fractions, getScaleXProperty(), scaleX); 84 | return this; 85 | } 86 | 87 | protected abstract Property getScaleYProperty(); 88 | 89 | public AnimatorBuilder scaleY(float fractions[], Float... scaleY) { 90 | holder(fractions, getScaleYProperty(), scaleY); 91 | return this; 92 | } 93 | 94 | protected abstract Property getRotateXProperty(); 95 | 96 | public AnimatorBuilder rotateX(float fractions[], Float... rotateX) { 97 | holder(fractions, getRotateXProperty(), rotateX); 98 | return this; 99 | } 100 | 101 | protected abstract Property getRotateYProperty(); 102 | 103 | public AnimatorBuilder rotateY(float fractions[], Float... rotateY) { 104 | holder(fractions, getRotateYProperty(), rotateY); 105 | return this; 106 | } 107 | 108 | protected abstract Property getTranslateXProperty(); 109 | 110 | @SuppressWarnings("unused") 111 | public AnimatorBuilder translateX(float fractions[], Float... translateX) { 112 | holder(fractions, getTranslateXProperty(), translateX); 113 | return this; 114 | } 115 | 116 | protected abstract Property getTranslateYProperty(); 117 | 118 | @SuppressWarnings("unused") 119 | public AnimatorBuilder translateY(float fractions[], Float... translateY) { 120 | holder(fractions, getTranslateYProperty(), translateY); 121 | return this; 122 | } 123 | 124 | protected abstract Property getRotateProperty(); 125 | 126 | public AnimatorBuilder rotate(float fractions[], Float... rotate) { 127 | holder(fractions, getRotateProperty(), rotate); 128 | return this; 129 | } 130 | 131 | protected abstract Property getTranslateXPercentageProperty(); 132 | 133 | public AnimatorBuilder translateXPercentage(float fractions[], Float... translateXPercentage) { 134 | holder(fractions, getTranslateXPercentageProperty(), translateXPercentage); 135 | return this; 136 | } 137 | 138 | protected abstract Property getTranslateYPercentageProperty(); 139 | 140 | public AnimatorBuilder translateYPercentage(float[] fractions, Float... translateYPercentage) { 141 | holder(fractions, getTranslateYPercentageProperty(), translateYPercentage); 142 | return this; 143 | } 144 | 145 | private void holder(float[] fractions, Property property, Float[] values) { 146 | ensurePair(fractions.length, values.length); 147 | fds.put(property.getName(), new FloatFrameData(fractions, property, values)); 148 | } 149 | 150 | 151 | private void holder(float[] fractions, Property property, Integer[] values) { 152 | ensurePair(fractions.length, values.length); 153 | fds.put(property.getName(), new IntFrameData(fractions, property, values)); 154 | } 155 | 156 | private void ensurePair(int fractionsLength, int valuesLength) { 157 | if (fractionsLength != valuesLength) { 158 | throw new IllegalStateException(String.format( 159 | Locale.getDefault(), 160 | "The fractions.length must equal values.length, " + 161 | "fraction.length[%d], values.length[%d]", 162 | fractionsLength, 163 | valuesLength)); 164 | } 165 | } 166 | 167 | 168 | public AnimatorBuilder interpolator(Interpolator interpolator) { 169 | this.interpolator = interpolator; 170 | return this; 171 | } 172 | 173 | public AnimatorBuilder easeInOut(float... fractions) { 174 | interpolator(KeyFrameInterpolator.easeInOut( 175 | fractions 176 | )); 177 | return this; 178 | } 179 | 180 | 181 | public AnimatorBuilder duration(long duration) { 182 | this.duration = duration; 183 | return this; 184 | } 185 | 186 | @SuppressWarnings("unused") 187 | public AnimatorBuilder repeatCount(int repeatCount) { 188 | this.repeatCount = repeatCount; 189 | return this; 190 | } 191 | 192 | public AnimatorBuilder startFrame(int startFrame) { 193 | if (startFrame < 0) { 194 | Log.w(TAG, "startFrame should always be non-negative"); 195 | startFrame = 0; 196 | } 197 | this.startFrame = startFrame; 198 | return this; 199 | } 200 | 201 | public ObjectAnimator build() { 202 | 203 | PropertyValuesHolder[] holders = new PropertyValuesHolder[fds.size()]; 204 | int i = 0; 205 | for (Map.Entry fd : fds.entrySet()) { 206 | FrameData data = fd.getValue(); 207 | Keyframe[] keyframes = new Keyframe[data.fractions.length]; 208 | float[] fractions = data.fractions; 209 | float startF = fractions[startFrame]; 210 | for (int j = startFrame; j < (startFrame + data.values.length); j++) { 211 | int key = j - startFrame; 212 | int vk = j % data.values.length; 213 | float fraction = fractions[vk] - startF; 214 | if (fraction < 0) { 215 | fraction = fractions[fractions.length - 1] + fraction; 216 | } 217 | if (data instanceof IntFrameData) { 218 | keyframes[key] = Keyframe.ofInt(fraction, (Integer) data.values[vk]); 219 | } else if (data instanceof FloatFrameData) { 220 | keyframes[key] = Keyframe.ofFloat(fraction, (Float) data.values[vk]); 221 | } else { 222 | keyframes[key] = Keyframe.ofObject(fraction, data.values[vk]); 223 | } 224 | } 225 | holders[i] = PropertyValuesHolder.ofKeyframe(data.property, keyframes); 226 | i++; 227 | } 228 | 229 | ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, 230 | holders); 231 | animator.setDuration(duration); 232 | animator.setRepeatCount(repeatCount); 233 | animator.setInterpolator(interpolator); 234 | return animator; 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/ArgbEvaluator.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.animation.TypeEvaluator; 4 | 5 | public class ArgbEvaluator implements TypeEvaluator { 6 | private static final ArgbEvaluator sInstance = new ArgbEvaluator(); 7 | 8 | public static ArgbEvaluator getInstance() { 9 | return sInstance; 10 | } 11 | 12 | /** 13 | * This function returns the calculated in-between value for a color 14 | * given integers that represent the start and end values in the four 15 | * bytes of the 32-bit int. Each channel is separately linearly interpolated 16 | * and the resulting calculated values are recombined into the return value. 17 | * 18 | * @param fraction The fraction from the starting to the ending values 19 | * @param startValue A 32-bit int value representing colors in the 20 | * separate bytes of the parameter 21 | * @param endValue A 32-bit int value representing colors in the 22 | * separate bytes of the parameter 23 | * @return A value that is calculated to be the linearly interpolated 24 | * result, derived by separating the start and end values into separate 25 | * color channels and interpolating each one separately, recombining the 26 | * resulting values in the same way. 27 | */ 28 | public Object evaluate(float fraction, Object startValue, Object endValue) { 29 | int startInt = (Integer) startValue; 30 | int startA = (startInt >> 24) & 0xff; 31 | int startR = (startInt >> 16) & 0xff; 32 | int startG = (startInt >> 8) & 0xff; 33 | int startB = startInt & 0xff; 34 | 35 | int endInt = (Integer) endValue; 36 | int endA = (endInt >> 24) & 0xff; 37 | int endR = (endInt >> 16) & 0xff; 38 | int endG = (endInt >> 8) & 0xff; 39 | int endB = endInt & 0xff; 40 | 41 | return (int)((startA + (int)(fraction * (endA - startA))) << 24) | 42 | (int)((startR + (int)(fraction * (endR - startR))) << 16) | 43 | (int)((startG + (int)(fraction * (endG - startG))) << 8) | 44 | (int)((startB + (int)(fraction * (endB - startB)))); 45 | } 46 | } -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/DrawableAnimatorBuilder.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.support.annotation.FloatRange; 4 | import android.util.Property; 5 | 6 | import com.simon.core.animationtools.drawable.AnimationDrawable; 7 | 8 | /** 9 | * 10 | * Created by simon on 17-6-7. 11 | */ 12 | 13 | public class DrawableAnimatorBuilder extends AnimatorBuilder { 14 | 15 | public DrawableAnimatorBuilder(AnimationDrawable target) { 16 | super(target); 17 | } 18 | 19 | public static final Property ROTATE_X = new FloatProperty("rotateX") { 20 | @Override 21 | public void setValue(AnimationDrawable target, float value) { 22 | target.setRotationX(value); 23 | } 24 | 25 | @Override 26 | public Float get(AnimationDrawable target) { 27 | return target.getRotationX(); 28 | } 29 | }; 30 | 31 | public static final Property ROTATE = new FloatProperty("rotate") { 32 | @Override 33 | public void setValue(AnimationDrawable target, float value) { 34 | target.setRotation(value); 35 | } 36 | 37 | @Override 38 | public Float get(AnimationDrawable target) { 39 | return target.getRotation(); 40 | } 41 | }; 42 | 43 | public static final Property ROTATE_Y = new FloatProperty("rotateY") { 44 | @Override 45 | public void setValue(AnimationDrawable target, float value) { 46 | target.setRotationY((int) value); 47 | } 48 | 49 | @Override 50 | public Float get(AnimationDrawable target) { 51 | return target.getRotationY(); 52 | } 53 | }; 54 | 55 | @SuppressWarnings("unused") 56 | public static final Property TRANSLATE_X = new FloatProperty("translateX") { 57 | @Override 58 | public void setValue(AnimationDrawable target, float value) { 59 | target.setTranslationX(value); 60 | } 61 | 62 | @Override 63 | public Float get(AnimationDrawable target) { 64 | return target.getTranslationX(); 65 | } 66 | }; 67 | 68 | @SuppressWarnings("unused") 69 | public static final Property TRANSLATE_Y = new FloatProperty("translateY") { 70 | @Override 71 | public void setValue(AnimationDrawable target, float value) { 72 | target.setTranslationY(value); 73 | } 74 | 75 | @Override 76 | public Float get(AnimationDrawable target) { 77 | return target.getTranslationY(); 78 | } 79 | }; 80 | 81 | public static final Property TRANSLATE_X_PERCENTAGE = new FloatProperty("translateXPercentage") { 82 | @Override 83 | public void setValue(AnimationDrawable target, @FloatRange(from = 0f,to = 1f) float value) { 84 | target.setTranslationXPercentage(value); 85 | } 86 | 87 | @Override 88 | public Float get(AnimationDrawable target) { 89 | return target.getTranslationXPercentage(); 90 | } 91 | }; 92 | 93 | public static final Property TRANSLATE_Y_PERCENTAGE = new FloatProperty("translateYPercentage") { 94 | 95 | @Override 96 | public void setValue(AnimationDrawable target, @FloatRange(from = 0f,to = 1f) float value) { 97 | target.setTranslationYPercentage(value); 98 | } 99 | 100 | @Override 101 | public Float get(AnimationDrawable target) { 102 | return target.getTranslationYPercentage(); 103 | } 104 | }; 105 | 106 | @SuppressWarnings("unused") 107 | public static final Property SCALE_X = new FloatProperty("scaleX") { 108 | @Override 109 | public void setValue(AnimationDrawable target, float value) { 110 | target.setScaleX(value); 111 | } 112 | 113 | @Override 114 | public Float get(AnimationDrawable target) { 115 | return target.getScaleX(); 116 | } 117 | }; 118 | 119 | public static final Property SCALE_Y = new FloatProperty("scaleY") { 120 | @Override 121 | public void setValue(AnimationDrawable target, float value) { 122 | target.setScaleY(value); 123 | } 124 | 125 | @Override 126 | public Float get(AnimationDrawable target) { 127 | return target.getScaleY(); 128 | } 129 | }; 130 | 131 | public static final Property SCALE = new FloatProperty("scale") { 132 | @Override 133 | public void setValue(AnimationDrawable target, float value) { 134 | target.setScaleX(value); 135 | target.setScaleY(value); 136 | } 137 | 138 | @Override 139 | public Float get(AnimationDrawable target) { 140 | return target.getScaleX(); 141 | } 142 | }; 143 | 144 | public static final Property ALPHA = new FloatProperty("alpha") { 145 | @Override 146 | public void setValue(AnimationDrawable target, float value) { 147 | target.setAlpha((int) (value * 255)); 148 | } 149 | 150 | @Override 151 | public Float get(AnimationDrawable target) { 152 | return target.getAlpha() / 255f; 153 | } 154 | }; 155 | 156 | @Override 157 | protected Property getScaleProperty() { 158 | return SCALE; 159 | } 160 | 161 | @Override 162 | protected Property getAlphaProperty() { 163 | return ALPHA; 164 | } 165 | 166 | @Override 167 | protected Property getScaleXProperty() { 168 | return SCALE_X; 169 | } 170 | 171 | @Override 172 | protected Property getScaleYProperty() { 173 | return SCALE_Y; 174 | } 175 | 176 | @Override 177 | protected Property getRotateXProperty() { 178 | return ROTATE_X; 179 | } 180 | 181 | @Override 182 | protected Property getRotateYProperty() { 183 | return ROTATE_Y; 184 | } 185 | 186 | @Override 187 | protected Property getTranslateXProperty() { 188 | return TRANSLATE_X; 189 | } 190 | 191 | @Override 192 | protected Property getTranslateYProperty() { 193 | return TRANSLATE_Y; 194 | } 195 | 196 | @Override 197 | protected Property getRotateProperty() { 198 | return ROTATE; 199 | } 200 | 201 | @Override 202 | protected Property getTranslateXPercentageProperty() { 203 | return TRANSLATE_X_PERCENTAGE; 204 | } 205 | 206 | @Override 207 | protected Property getTranslateYPercentageProperty() { 208 | return TRANSLATE_Y_PERCENTAGE; 209 | } 210 | 211 | 212 | } 213 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/FloatProperty.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.util.Property; 4 | 5 | /** 6 | * Created by simon on 17-6-2. 7 | */ 8 | 9 | public abstract class FloatProperty extends Property { 10 | 11 | public FloatProperty(String name) { 12 | super(Float.class, name); 13 | } 14 | 15 | /** 16 | * A type-specific variant of {@link #set(Object, Float)} that is faster when dealing 17 | * with fields of type float. 18 | */ 19 | public abstract void setValue(T object, float value); 20 | 21 | @Override 22 | final public void set(T object, Float value) { 23 | setValue(object, value); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/IntProperty.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.util.Property; 4 | 5 | /** 6 | * Created by simon on 17-6-2. 7 | */ 8 | 9 | public abstract class IntProperty extends Property { 10 | 11 | public IntProperty(String name) { 12 | super(Integer.class, name); 13 | } 14 | 15 | /** 16 | * A type-specific variant of {@link #set(Object, Integer)} that is faster when dealing 17 | * with fields of type int. 18 | */ 19 | public abstract void setValue(T object, int value); 20 | 21 | @Override 22 | final public void set(T object, Integer value) { 23 | setValue(object, value.intValue()); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/ViewAnimatorBuilder.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator; 2 | 3 | import android.support.annotation.FloatRange; 4 | import android.util.Property; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by simon liu. 9 | */ 10 | public class ViewAnimatorBuilder extends AnimatorBuilder { 11 | 12 | public ViewAnimatorBuilder(View target) { 13 | super(target); 14 | } 15 | 16 | public static final Property ROTATE_X = new FloatProperty("rotateX") { 17 | @Override 18 | public void setValue(View target, float value) { 19 | target.setRotationX(value); 20 | } 21 | 22 | @Override 23 | public Float get(View target) { 24 | return target.getRotationX(); 25 | } 26 | }; 27 | 28 | public static final Property ROTATE = new FloatProperty("rotate") { 29 | @Override 30 | public void setValue(View target, float value) { 31 | target.setRotation(value); 32 | } 33 | 34 | @Override 35 | public Float get(View target) { 36 | return target.getRotation(); 37 | } 38 | }; 39 | 40 | public static final Property ROTATE_Y = new FloatProperty("rotateY") { 41 | @Override 42 | public void setValue(View target, float value) { 43 | target.setRotationY(value); 44 | } 45 | 46 | @Override 47 | public Float get(View target) { 48 | return target.getRotationY(); 49 | } 50 | }; 51 | 52 | @SuppressWarnings("unused") 53 | public static final Property TRANSLATE_X = new FloatProperty("translateX") { 54 | @Override 55 | public void setValue(View target, float value) { 56 | target.setTranslationX(value); 57 | } 58 | 59 | @Override 60 | public Float get(View target) { 61 | return target.getTranslationX(); 62 | } 63 | }; 64 | 65 | @SuppressWarnings("unused") 66 | public static final Property TRANSLATE_Y = new FloatProperty("translateY") { 67 | @Override 68 | public void setValue(View target, float value) { 69 | target.setTranslationY(value); 70 | } 71 | 72 | @Override 73 | public Float get(View target) { 74 | return target.getTranslationY(); 75 | } 76 | }; 77 | 78 | public static final Property TRANSLATE_X_PERCENTAGE = new FloatProperty("translateXPercentage") { 79 | @Override 80 | public void setValue(View target, @FloatRange(from = 0f,to = 1f) float value) { 81 | int width = target.getWidth(); 82 | target.setTranslationX(value * width); 83 | } 84 | 85 | @Override 86 | public Float get(View target) { 87 | float translationX = target.getTranslationX(); 88 | return translationX / target.getWidth(); 89 | } 90 | }; 91 | 92 | public static final Property TRANSLATE_Y_PERCENTAGE = new FloatProperty("translateYPercentage") { 93 | 94 | @Override 95 | public void setValue(View target, @FloatRange(from = 0f,to = 1f) float value) { 96 | int width = target.getHeight(); 97 | target.setTranslationY(value * width); 98 | } 99 | 100 | @Override 101 | public Float get(View target) { 102 | return target.getTranslationY() / target.getHeight(); 103 | } 104 | }; 105 | 106 | @SuppressWarnings("unused") 107 | public static final Property SCALE_X = new FloatProperty("scaleX") { 108 | @Override 109 | public void setValue(View target, float value) { 110 | target.setScaleX(value); 111 | } 112 | 113 | @Override 114 | public Float get(View target) { 115 | return target.getScaleX(); 116 | } 117 | }; 118 | 119 | public static final Property SCALE_Y = new FloatProperty("scaleY") { 120 | @Override 121 | public void setValue(View target, float value) { 122 | target.setScaleY(value); 123 | } 124 | 125 | @Override 126 | public Float get(View target) { 127 | return target.getScaleY(); 128 | } 129 | }; 130 | 131 | public static final Property SCALE = new FloatProperty("scale") { 132 | @Override 133 | public void setValue(View target, float value) { 134 | target.setScaleX(value); 135 | target.setScaleY(value); 136 | } 137 | 138 | @Override 139 | public Float get(View target) { 140 | return target.getScaleX(); 141 | } 142 | }; 143 | 144 | public static final Property ALPHA = new FloatProperty("alpha") { 145 | @Override 146 | public void setValue(View target, float value) { 147 | target.setAlpha(value); 148 | } 149 | 150 | @Override 151 | public Float get(View target) { 152 | return target.getAlpha(); 153 | } 154 | }; 155 | 156 | @Override 157 | protected Property getScaleProperty() { 158 | return SCALE; 159 | } 160 | 161 | @Override 162 | protected Property getAlphaProperty() { 163 | return ALPHA; 164 | } 165 | 166 | @Override 167 | protected Property getScaleXProperty() { 168 | return SCALE_X; 169 | } 170 | 171 | @Override 172 | protected Property getScaleYProperty() { 173 | return SCALE_Y; 174 | } 175 | 176 | @Override 177 | protected Property getRotateXProperty() { 178 | return ROTATE_X; 179 | } 180 | 181 | @Override 182 | protected Property getRotateYProperty() { 183 | return ROTATE_Y; 184 | } 185 | 186 | @Override 187 | protected Property getTranslateXProperty() { 188 | return TRANSLATE_X; 189 | } 190 | 191 | @Override 192 | protected Property getTranslateYProperty() { 193 | return TRANSLATE_Y; 194 | } 195 | 196 | @Override 197 | protected Property getRotateProperty() { 198 | return ROTATE; 199 | } 200 | 201 | @Override 202 | protected Property getTranslateXPercentageProperty() { 203 | return TRANSLATE_X_PERCENTAGE; 204 | } 205 | 206 | @Override 207 | protected Property getTranslateYPercentageProperty() { 208 | return TRANSLATE_Y_PERCENTAGE; 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/Ease.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator.interpolator; 2 | 3 | import android.view.animation.Interpolator; 4 | 5 | /** 6 | * Created by simon liu. 7 | */ 8 | public class Ease { 9 | public static Interpolator inOut() { 10 | return PathInterpolatorCompat.create(0.42f, 0f, 0.58f, 1f); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/KeyFrameInterpolator.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.animator.interpolator; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.view.animation.Interpolator; 5 | 6 | /** 7 | * Created by simon liu. 8 | */ 9 | public class KeyFrameInterpolator implements Interpolator { 10 | 11 | private TimeInterpolator interpolator; 12 | private float[] fractions; 13 | 14 | 15 | public static KeyFrameInterpolator easeInOut(float... fractions) { 16 | KeyFrameInterpolator interpolator = new KeyFrameInterpolator(Ease.inOut()); 17 | interpolator.setFractions(fractions); 18 | return interpolator; 19 | } 20 | 21 | public static KeyFrameInterpolator pathInterpolator(float controlX1, float controlY1, 22 | float controlX2, float controlY2, 23 | float... fractions) { 24 | KeyFrameInterpolator interpolator = new KeyFrameInterpolator(PathInterpolatorCompat.create(controlX1, controlY1, controlX2, controlY2)); 25 | interpolator.setFractions(fractions); 26 | return interpolator; 27 | } 28 | 29 | public KeyFrameInterpolator(TimeInterpolator interpolator, float... fractions) { 30 | this.interpolator = interpolator; 31 | this.fractions = fractions; 32 | } 33 | 34 | public void setFractions(float... fractions) { 35 | this.fractions = fractions; 36 | } 37 | 38 | @Override 39 | public synchronized float getInterpolation(float input) { 40 | if (fractions.length > 1) { 41 | for (int i = 0; i < fractions.length - 1; i++) { 42 | float start = fractions[i]; 43 | float end = fractions[i + 1]; 44 | float duration = end - start; 45 | if (input >= start && input <= end) { 46 | input = (input - start) / duration; 47 | return start + (interpolator.getInterpolation(input) 48 | * duration); 49 | } 50 | } 51 | } 52 | return interpolator.getInterpolation(input); 53 | } 54 | } -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/PathInterpolatorCompat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.simon.core.animationtools.animator.interpolator; 18 | 19 | import android.graphics.Path; 20 | import android.os.Build; 21 | import android.view.animation.Interpolator; 22 | 23 | /** 24 | * Helper for creating path-based {@link Interpolator} instances. On API 21 or newer, the 25 | * platform implementation will be used and on older platforms a compatible alternative 26 | * implementation will be used. 27 | */ 28 | public class PathInterpolatorCompat { 29 | 30 | private PathInterpolatorCompat() { 31 | // prevent instantiation 32 | } 33 | 34 | /** 35 | * Create an {@link Interpolator} for an arbitrary {@link Path}. The {@link Path} 36 | * must begin at {@code (0, 0)} and end at {@code (1, 1)}. The x-coordinate along the 37 | * {@link Path} is the input value and the output is the y coordinate of the line at that 38 | * point. This means that the Path must conform to a function {@code y = f(x)}. 39 | *

40 | * The {@link Path} must not have gaps in the x direction and must not 41 | * loop back on itself such that there can be two points sharing the same x coordinate. 42 | * 43 | * @param path the {@link Path} to use to make the line representing the {@link Interpolator} 44 | * @return the {@link Interpolator} representing the {@link Path} 45 | */ 46 | @SuppressWarnings("unused") 47 | public static Interpolator create(Path path) { 48 | if (Build.VERSION.SDK_INT >= 21) { 49 | return PathInterpolatorCompatApi21.create(path); 50 | } 51 | return PathInterpolatorCompatBase.create(path); 52 | } 53 | 54 | /** 55 | * Create an {@link Interpolator} for a quadratic Bezier curve. The end points 56 | * {@code (0, 0)} and {@code (1, 1)} are assumed. 57 | * 58 | * @param controlX the x coordinate of the quadratic Bezier control point 59 | * @param controlY the y coordinate of the quadratic Bezier control point 60 | * @return the {@link Interpolator} representing the quadratic Bezier curve 61 | */ 62 | @SuppressWarnings("unused") 63 | public static Interpolator create(float controlX, float controlY) { 64 | if (Build.VERSION.SDK_INT >= 21) { 65 | return PathInterpolatorCompatApi21.create(controlX, controlY); 66 | } 67 | return PathInterpolatorCompatBase.create(controlX, controlY); 68 | } 69 | 70 | /** 71 | * Create an {@link Interpolator} for a cubic Bezier curve. The end points 72 | * {@code (0, 0)} and {@code (1, 1)} are assumed. 73 | * 74 | * @param controlX1 the x coordinate of the first control point of the cubic Bezier 75 | * @param controlY1 the y coordinate of the first control point of the cubic Bezier 76 | * @param controlX2 the x coordinate of the second control point of the cubic Bezier 77 | * @param controlY2 the y coordinate of the second control point of the cubic Bezier 78 | * @return the {@link Interpolator} representing the cubic Bezier curve 79 | */ 80 | public static Interpolator create(float controlX1, float controlY1, 81 | float controlX2, float controlY2) { 82 | if (Build.VERSION.SDK_INT >= 21) { 83 | return PathInterpolatorCompatApi21.create(controlX1, controlY1, controlX2, controlY2); 84 | } 85 | return PathInterpolatorCompatBase.create(controlX1, controlY1, controlX2, controlY2); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/PathInterpolatorCompatApi21.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.simon.core.animationtools.animator.interpolator; 18 | 19 | import android.annotation.TargetApi; 20 | import android.graphics.Path; 21 | import android.os.Build; 22 | import android.view.animation.Interpolator; 23 | import android.view.animation.PathInterpolator; 24 | 25 | /** 26 | * API 21+ implementation for path interpolator compatibility. 27 | */ 28 | class PathInterpolatorCompatApi21 { 29 | 30 | private PathInterpolatorCompatApi21() { 31 | // prevent instantiation 32 | } 33 | 34 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 35 | public static Interpolator create(Path path) { 36 | return new PathInterpolator(path); 37 | } 38 | 39 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 40 | public static Interpolator create(float controlX, float controlY) { 41 | return new PathInterpolator(controlX, controlY); 42 | } 43 | 44 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 45 | public static Interpolator create(float controlX1, float controlY1, 46 | float controlX2, float controlY2) { 47 | return new PathInterpolator(controlX1, controlY1, controlX2, controlY2); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/PathInterpolatorCompatBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.simon.core.animationtools.animator.interpolator; 18 | 19 | import android.graphics.Path; 20 | import android.view.animation.Interpolator; 21 | 22 | /** 23 | * Base implementation for path interpolator compatibility. 24 | */ 25 | class PathInterpolatorCompatBase { 26 | 27 | private PathInterpolatorCompatBase() { 28 | // prevent instantiation 29 | } 30 | 31 | public static Interpolator create(Path path) { 32 | return new PathInterpolatorDonut(path); 33 | } 34 | 35 | public static Interpolator create(float controlX, float controlY) { 36 | return new PathInterpolatorDonut(controlX, controlY); 37 | } 38 | 39 | public static Interpolator create(float controlX1, float controlY1, 40 | float controlX2, float controlY2) { 41 | return new PathInterpolatorDonut(controlX1, controlY1, controlX2, controlY2); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/animator/interpolator/PathInterpolatorDonut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.simon.core.animationtools.animator.interpolator; 17 | 18 | import android.graphics.Path; 19 | import android.graphics.PathMeasure; 20 | import android.view.animation.Interpolator; 21 | 22 | /** 23 | * A path interpolator implementation compatible with API 4+. 24 | */ 25 | class PathInterpolatorDonut implements Interpolator { 26 | 27 | /** 28 | * Governs the accuracy of the approximation of the {@link Path}. 29 | */ 30 | private static final float PRECISION = 0.002f; 31 | 32 | private final float[] mX; 33 | private final float[] mY; 34 | 35 | public PathInterpolatorDonut(Path path) { 36 | final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */); 37 | 38 | final float pathLength = pathMeasure.getLength(); 39 | final int numPoints = (int) (pathLength / PRECISION) + 1; 40 | 41 | mX = new float[numPoints]; 42 | mY = new float[numPoints]; 43 | 44 | final float[] position = new float[2]; 45 | for (int i = 0; i < numPoints; ++i) { 46 | final float distance = (i * pathLength) / (numPoints - 1); 47 | pathMeasure.getPosTan(distance, position, null /* tangent */); 48 | 49 | mX[i] = position[0]; 50 | mY[i] = position[1]; 51 | } 52 | } 53 | 54 | public PathInterpolatorDonut(float controlX, float controlY) { 55 | this(createQuad(controlX, controlY)); 56 | } 57 | 58 | public PathInterpolatorDonut(float controlX1, float controlY1, 59 | float controlX2, float controlY2) { 60 | this(createCubic(controlX1, controlY1, controlX2, controlY2)); 61 | } 62 | 63 | @Override 64 | public float getInterpolation(float t) { 65 | if (t <= 0.0f) { 66 | return 0.0f; 67 | } else if (t >= 1.0f) { 68 | return 1.0f; 69 | } 70 | 71 | // Do a binary search for the correct x to interpolate between. 72 | int startIndex = 0; 73 | int endIndex = mX.length - 1; 74 | while (endIndex - startIndex > 1) { 75 | int midIndex = (startIndex + endIndex) / 2; 76 | if (t < mX[midIndex]) { 77 | endIndex = midIndex; 78 | } else { 79 | startIndex = midIndex; 80 | } 81 | } 82 | 83 | final float xRange = mX[endIndex] - mX[startIndex]; 84 | if (xRange == 0) { 85 | return mY[startIndex]; 86 | } 87 | 88 | final float tInRange = t - mX[startIndex]; 89 | final float fraction = tInRange / xRange; 90 | 91 | final float startY = mY[startIndex]; 92 | final float endY = mY[endIndex]; 93 | 94 | return startY + (fraction * (endY - startY)); 95 | } 96 | 97 | private static Path createQuad(float controlX, float controlY) { 98 | final Path path = new Path(); 99 | path.moveTo(0.0f, 0.0f); 100 | path.quadTo(controlX, controlY, 1.0f, 1.0f); 101 | return path; 102 | } 103 | 104 | private static Path createCubic(float controlX1, float controlY1, 105 | float controlX2, float controlY2) { 106 | final Path path = new Path(); 107 | path.moveTo(0.0f, 0.0f); 108 | path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0f, 1.0f); 109 | return path; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/AnimDrawableContainer.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Canvas; 5 | import android.graphics.ColorFilter; 6 | import android.graphics.Paint; 7 | import android.graphics.PixelFormat; 8 | import android.graphics.Rect; 9 | import android.graphics.drawable.Drawable; 10 | import android.support.annotation.ColorInt; 11 | import android.support.annotation.IntRange; 12 | import android.support.annotation.NonNull; 13 | import android.support.annotation.Nullable; 14 | 15 | import com.simon.core.animationtools.animator.AnimUtils; 16 | 17 | /** 18 | * 19 | * Created by simon on 17-6-7. 20 | */ 21 | 22 | public abstract class AnimDrawableContainer extends AnimationDrawable{ 23 | 24 | protected final @NonNull Drawable[] children; 25 | 26 | private Paint bgPaint; 27 | 28 | private @ColorInt int bgColor = -1; 29 | 30 | public AnimDrawableContainer() { 31 | children = createChildren(); 32 | bgPaint = new Paint(); 33 | bgPaint.setAntiAlias(true); 34 | initCallback(); 35 | } 36 | 37 | public abstract @NonNull Drawable[] createChildren(); 38 | 39 | private void initCallback() { 40 | for (Drawable child : children) { 41 | child.setCallback(this); 42 | } 43 | } 44 | 45 | @Override 46 | public void invalidateDrawable(@NonNull Drawable who) { 47 | invalidateSelf(); 48 | } 49 | 50 | @Override 51 | public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) { 52 | 53 | } 54 | 55 | @Override 56 | public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) { 57 | 58 | } 59 | 60 | @Override 61 | public void draw(@NonNull Canvas canvas) { 62 | super.draw(canvas); 63 | drawChildren(canvas); 64 | } 65 | 66 | @Override 67 | protected void drawSelf(@NonNull Canvas canvas) { 68 | if(bgColor != -1) { 69 | int count = canvas.save(); 70 | bgPaint.setColor(bgColor); 71 | canvas.drawRect(getBounds(), bgPaint); 72 | canvas.restoreToCount(count); 73 | } 74 | } 75 | 76 | protected void drawChildren(@NonNull Canvas canvas) { 77 | for (Drawable child : children) { 78 | int count = canvas.save(); 79 | child.draw(canvas); 80 | canvas.restoreToCount(count); 81 | } 82 | } 83 | 84 | @Override 85 | public ValueAnimator createAnimator() { 86 | return null; 87 | } 88 | 89 | @Override 90 | protected void onBoundsChange(Rect bounds) { 91 | super.onBoundsChange(bounds); 92 | for (Drawable child : children) { 93 | child.setBounds(bounds); 94 | } 95 | } 96 | 97 | public int getChildCount() { 98 | return children.length; 99 | } 100 | 101 | public Drawable getChildAt(int index) { 102 | return children[index]; 103 | } 104 | 105 | @Override 106 | public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { 107 | for (Drawable child : children) { 108 | child.setAlpha(alpha); 109 | } 110 | } 111 | 112 | @Override 113 | public void setColorFilter(@Nullable ColorFilter colorFilter) { 114 | 115 | } 116 | 117 | public void setBgColor(int bgColor) { 118 | this.bgColor = bgColor; 119 | } 120 | 121 | @Override 122 | public int getOpacity() { 123 | return PixelFormat.TRANSLUCENT; 124 | } 125 | 126 | @Override 127 | public void start() { 128 | super.start(); 129 | AnimUtils.start(children); 130 | } 131 | 132 | @Override 133 | public void stop() { 134 | super.stop(); 135 | AnimUtils.stop(children); 136 | } 137 | 138 | @Override 139 | public boolean isRunning() { 140 | return AnimUtils.isRunning(children); 141 | } 142 | 143 | 144 | } 145 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/AnimationDrawable.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Camera; 5 | import android.graphics.Canvas; 6 | import android.graphics.ColorFilter; 7 | import android.graphics.Matrix; 8 | import android.graphics.PixelFormat; 9 | import android.graphics.Rect; 10 | import android.graphics.drawable.Animatable; 11 | import android.graphics.drawable.Drawable; 12 | import android.support.annotation.IntRange; 13 | import android.support.annotation.NonNull; 14 | import android.support.annotation.Nullable; 15 | 16 | import com.simon.core.animationtools.animator.AnimUtils; 17 | 18 | /** 19 | * 20 | * Created by simon on 17-6-5. 21 | */ 22 | 23 | public abstract class AnimationDrawable extends Drawable implements 24 | ValueAnimator.AnimatorUpdateListener, 25 | Animatable, Drawable.Callback { 26 | 27 | private static final Rect ZERO_BOUNDS_RECT = new Rect(); 28 | 29 | private ValueAnimator animator; 30 | 31 | private Camera mCamera; 32 | 33 | private Matrix mMatrix; 34 | 35 | private float scale = 1; 36 | private float scaleX = 1; 37 | private float scaleY = 1; 38 | private float pivotX; 39 | private float pivotY; 40 | private int animationDelay; 41 | private float rotationX; 42 | private float rotationY; 43 | private float translationX; 44 | private float translationY; 45 | private float rotation; 46 | private float translationXPercentage; 47 | private float translationYPercentage; 48 | private @IntRange(from = 0, to = 255) int alpha = 255; 49 | protected Rect drawBounds = ZERO_BOUNDS_RECT; 50 | 51 | 52 | @Override 53 | public int getAlpha() { 54 | return alpha; 55 | } 56 | 57 | public AnimationDrawable() { 58 | mCamera = new Camera(); 59 | mMatrix = new Matrix(); 60 | } 61 | 62 | public abstract ValueAnimator createAnimator(); 63 | 64 | protected abstract void drawSelf(@NonNull Canvas canvas); 65 | 66 | @Override 67 | public void draw(@NonNull Canvas canvas) { 68 | float tx = getTranslationX(); 69 | tx = tx == 0 ? (int) (getBounds().width() * getTranslationXPercentage()) : tx; 70 | float ty = getTranslationY(); 71 | ty = ty == 0 ? (int) (getBounds().height() * getTranslationYPercentage()) : ty; 72 | canvas.translate(tx, ty); 73 | canvas.scale(getScaleX(), getScaleY(), getPivotX(), getPivotY()); 74 | canvas.rotate(getRotation(), getPivotX(), getPivotY()); 75 | 76 | if (getRotationX() != 0 || getRotationY() != 0) { 77 | mCamera.save(); 78 | mCamera.rotateX(getRotationX()); 79 | mCamera.rotateY(getRotationY()); 80 | mCamera.getMatrix(mMatrix); 81 | mMatrix.preTranslate(-getPivotX(), -getPivotY()); 82 | mMatrix.postTranslate(getPivotX(), getPivotY()); 83 | mCamera.restore(); 84 | canvas.concat(mMatrix); 85 | } 86 | drawSelf(canvas); 87 | } 88 | 89 | @Override 90 | public void setAlpha(@IntRange(from = 0, to = 255) int alpha) { 91 | this.alpha = alpha; 92 | } 93 | 94 | @Override 95 | public void setColorFilter(@Nullable ColorFilter colorFilter) { 96 | //do nothing 97 | } 98 | 99 | @Override 100 | public int getOpacity() { 101 | return PixelFormat.TRANSLUCENT; 102 | } 103 | 104 | @Override 105 | public void invalidateDrawable(@NonNull Drawable who) { 106 | invalidateSelf(); 107 | } 108 | 109 | @Override 110 | public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) { 111 | scheduleSelf(what,when); 112 | } 113 | 114 | @Override 115 | public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) { 116 | unscheduleSelf(what); 117 | } 118 | 119 | @Override 120 | public void onAnimationUpdate(ValueAnimator animation) { 121 | final Callback callback = getCallback(); 122 | if (callback != null) { 123 | callback.invalidateDrawable(this); 124 | } 125 | } 126 | 127 | public void reset() { 128 | scale = 1; 129 | rotationX = 0; 130 | rotationY = 0; 131 | translationX = 0; 132 | translationY = 0; 133 | rotation = 0; 134 | translationXPercentage = 0f; 135 | translationYPercentage = 0f; 136 | } 137 | 138 | @Override 139 | public void start() { 140 | animator = createAnimator(); 141 | if(animator != null) { 142 | animator.addUpdateListener(this); 143 | animator.setStartDelay(getAnimationDelay()); 144 | AnimUtils.start(animator); 145 | } 146 | } 147 | 148 | @Override 149 | public void stop() { 150 | AnimUtils.stop(animator); 151 | reset(); 152 | if(animator != null) { 153 | animator.removeUpdateListener(this); 154 | animator = null; 155 | } 156 | } 157 | 158 | @Override 159 | public boolean isRunning() { 160 | return AnimUtils.isRunning(animator); 161 | } 162 | 163 | //getters and setters 164 | 165 | 166 | public float getScale() { 167 | return scale; 168 | } 169 | 170 | public void setScale(float scale) { 171 | this.scale = scale; 172 | } 173 | 174 | public float getScaleX() { 175 | return scaleX; 176 | } 177 | 178 | public void setScaleX(float scaleX) { 179 | this.scaleX = scaleX; 180 | } 181 | 182 | public float getScaleY() { 183 | return scaleY; 184 | } 185 | 186 | public void setScaleY(float scaleY) { 187 | this.scaleY = scaleY; 188 | } 189 | 190 | public float getPivotX() { 191 | return pivotX; 192 | } 193 | 194 | public float getPivotY() { 195 | return pivotY; 196 | } 197 | 198 | public int getAnimationDelay() { 199 | return animationDelay; 200 | } 201 | 202 | public void setAnimationDelay(int animationDelay) { 203 | this.animationDelay = animationDelay; 204 | } 205 | 206 | public float getRotationX() { 207 | return rotationX; 208 | } 209 | 210 | public void setRotationX(float rotationX) { 211 | this.rotationX = rotationX; 212 | } 213 | 214 | public float getRotationY() { 215 | return rotationY; 216 | } 217 | 218 | public void setRotationY(float rotateY) { 219 | this.rotationY = rotateY; 220 | } 221 | 222 | public float getTranslationX() { 223 | return translationX; 224 | } 225 | 226 | public void setTranslationX(float translationX) { 227 | this.translationX = translationX; 228 | } 229 | 230 | public float getTranslationY() { 231 | return translationY; 232 | } 233 | 234 | public void setTranslationY(float translationY) { 235 | this.translationY = translationY; 236 | } 237 | 238 | public float getRotation() { 239 | return rotation; 240 | } 241 | 242 | public void setRotation(float rotate) { 243 | this.rotation = rotate; 244 | } 245 | 246 | public float getTranslationXPercentage() { 247 | return translationXPercentage; 248 | } 249 | 250 | public void setTranslationXPercentage(float translationXPercentage) { 251 | this.translationXPercentage = translationXPercentage; 252 | } 253 | 254 | public float getTranslationYPercentage() { 255 | return translationYPercentage; 256 | } 257 | 258 | public void setTranslationYPercentage(float translationYPercentage) { 259 | this.translationYPercentage = translationYPercentage; 260 | } 261 | 262 | public void setPivotX(float pivotX) { 263 | this.pivotX = pivotX; 264 | } 265 | 266 | public void setPivotY(float pivotY) { 267 | this.pivotY = pivotY; 268 | } 269 | 270 | public Rect getDrawBounds() { 271 | return drawBounds; 272 | } 273 | 274 | @Override 275 | protected void onBoundsChange(Rect bounds) { 276 | super.onBoundsChange(bounds); 277 | this.setDrawBounds(bounds); 278 | } 279 | 280 | public void setDrawBounds(@NonNull Rect drawBounds) { 281 | setDrawBounds(drawBounds.left, drawBounds.top, drawBounds.right, drawBounds.bottom); 282 | } 283 | 284 | public void setDrawBounds(int left, int top, int right, int bottom) { 285 | this.drawBounds = new Rect(left, top, right, bottom); 286 | pivotX = drawBounds.centerX(); 287 | pivotY = drawBounds.centerY(); 288 | } 289 | 290 | } 291 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/ChasingDots.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Rect; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.Build; 7 | import android.support.annotation.NonNull; 8 | import android.view.animation.LinearInterpolator; 9 | 10 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 11 | import com.simon.core.animationtools.drawable.AnimationDrawable; 12 | import com.simon.core.animationtools.drawable.shape.CircleAnimDrawable; 13 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 14 | 15 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 16 | 17 | /** 18 | * ChasingDots 19 | * Created by simon on 17-6-8. 20 | */ 21 | 22 | public class ChasingDots extends AnimDrawableContainer { 23 | 24 | @NonNull 25 | @Override 26 | public Drawable[] createChildren() { 27 | Dot[] dots = { 28 | new Dot(), 29 | new Dot() 30 | }; 31 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 32 | dots[1].setAnimationDelay(1000); 33 | } else { 34 | dots[1].setAnimationDelay(-1000); 35 | } 36 | return dots; 37 | } 38 | 39 | @Override 40 | public ValueAnimator createAnimator() { 41 | float fractions[] = new float[]{0f, 1f}; 42 | return new DrawableAnimatorBuilder(this). 43 | rotate(fractions, 0f, 360f). 44 | duration(2000). 45 | interpolator(new LinearInterpolator()). 46 | build(); 47 | } 48 | 49 | @Override 50 | protected void onBoundsChange(Rect bounds) { 51 | super.onBoundsChange(bounds); 52 | bounds = clipSquare(bounds); 53 | int drawW = (int) (bounds.width() * 0.6f); 54 | ((AnimationDrawable) getChildAt(0)).setDrawBounds( 55 | bounds.right - drawW, 56 | bounds.top, 57 | bounds.right 58 | , bounds.top + drawW 59 | ); 60 | ((AnimationDrawable) getChildAt(1)).setDrawBounds( 61 | bounds.right - drawW, 62 | bounds.bottom - drawW, 63 | bounds.right, 64 | bounds.bottom 65 | ); 66 | } 67 | 68 | private class Dot extends CircleAnimDrawable { 69 | 70 | Dot() { 71 | setScale(0f); 72 | setAlpha(170); 73 | } 74 | 75 | @Override 76 | public ValueAnimator createAnimator() { 77 | float fractions[] = new float[]{0f, 0.5f, 1f}; 78 | return new DrawableAnimatorBuilder(this). 79 | scale(fractions, 0f, 1f, 0f). 80 | duration(2000). 81 | easeInOut(fractions) 82 | .build(); 83 | } 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/CubeGrid.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Rect; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.annotation.NonNull; 7 | 8 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 9 | import com.simon.core.animationtools.drawable.shape.RectAnimDrawable; 10 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 11 | 12 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 13 | 14 | 15 | /** 16 | * Created by simon on 17-6-8. 17 | */ 18 | 19 | public class CubeGrid extends AnimDrawableContainer { 20 | 21 | @NonNull 22 | @Override 23 | public Drawable[] createChildren() { 24 | int delays[] = new int[]{ 25 | 200, 300, 400 26 | , 100, 200, 300 27 | , 0, 100, 200 28 | }; 29 | GridItem[] gridItems = new GridItem[9]; 30 | for (int i = 0; i < gridItems.length; i++) { 31 | gridItems[i] = new GridItem(); 32 | gridItems[i].setAnimationDelay(delays[i]); 33 | } 34 | return gridItems; 35 | } 36 | 37 | @Override 38 | public GridItem getChildAt(int index) { 39 | return ((GridItem) super.getChildAt(index)); 40 | } 41 | 42 | @Override 43 | protected void onBoundsChange(Rect bounds) { 44 | super.onBoundsChange(bounds); 45 | bounds = clipSquare(bounds); 46 | int width = (int) (bounds.width() * 0.33f); 47 | int height = (int) (bounds.height() * 0.33f); 48 | for (int i = 0; i < getChildCount(); i++) { 49 | int x = i % 3; 50 | int y = i / 3; 51 | int l = bounds.left + x * width; 52 | int t = bounds.top + y * height; 53 | GridItem sprite = getChildAt(i); 54 | sprite.setDrawBounds(l, t, l + width, t + height); 55 | } 56 | } 57 | 58 | private class GridItem extends RectAnimDrawable { 59 | @Override 60 | public ValueAnimator createAnimator() { 61 | float fractions[] = new float[]{0f, 0.35f, 0.7f, 1f}; 62 | return new DrawableAnimatorBuilder(this). 63 | scale(fractions, 1f, 0f, 1f, 1f). 64 | duration(1300). 65 | easeInOut(fractions) 66 | .build(); 67 | } 68 | } 69 | 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/DoubleCircleBounce.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Color; 5 | import android.support.annotation.NonNull; 6 | 7 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 8 | import com.simon.core.animationtools.drawable.AnimationDrawable; 9 | import com.simon.core.animationtools.drawable.shape.CircleAnimDrawable; 10 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 11 | 12 | /** 13 | * DoubleCircleBounce 14 | * Created by simon on 17-6-7. 15 | */ 16 | 17 | public class DoubleCircleBounce extends AnimDrawableContainer { 18 | 19 | @NonNull 20 | @Override 21 | public AnimationDrawable[] createChildren() { 22 | AnimationDrawable[] children = new AnimationDrawable[]{new Bounce(Color.WHITE), new Bounce(Color.WHITE)}; 23 | children[1].setAnimationDelay(-1000); 24 | return children; 25 | } 26 | 27 | private static class Bounce extends CircleAnimDrawable { 28 | 29 | private Bounce(int color) { 30 | setAlpha(153); 31 | setScale(0f); 32 | setColor(color); 33 | } 34 | 35 | @Override 36 | public ValueAnimator createAnimator() { 37 | float fractions[] = new float[]{0f, 0.5f, 1f}; 38 | return new DrawableAnimatorBuilder(this).scale(fractions, 0f, 1f, 0f). 39 | duration(2000). 40 | easeInOut(fractions) 41 | .build(); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/FoldingCube.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Canvas; 5 | import android.graphics.Rect; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.support.annotation.NonNull; 9 | import android.view.animation.LinearInterpolator; 10 | 11 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 12 | import com.simon.core.animationtools.drawable.shape.RectAnimDrawable; 13 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 14 | 15 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 16 | 17 | /** 18 | * FoldingCube 19 | * Created by simon on 17-6-8. 20 | */ 21 | 22 | public class FoldingCube extends AnimDrawableContainer { 23 | 24 | @NonNull 25 | @Override 26 | public Drawable[] createChildren() { 27 | Cube[] cubes 28 | = new Cube[4]; 29 | for (int i = 0; i < cubes.length; i++) { 30 | cubes[i] = new Cube(); 31 | 32 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 33 | cubes[i].setAnimationDelay(300 * i); 34 | } else { 35 | cubes[i].setAnimationDelay(300 * i - 1200); 36 | } 37 | } 38 | return cubes; 39 | } 40 | 41 | @Override 42 | protected void onBoundsChange(Rect bounds) { 43 | super.onBoundsChange(bounds); 44 | bounds = clipSquare(bounds); 45 | int size = Math.min(bounds.width(), bounds.height()); 46 | size = (int) Math.sqrt( 47 | (size 48 | * size) / 2); 49 | int oW = (bounds.width() - size) / 2; 50 | int oH = (bounds.height() - size) / 2; 51 | bounds = new Rect( 52 | bounds.left + oW, 53 | bounds.top + oH, 54 | bounds.right - oW, 55 | bounds.bottom - oH 56 | ); 57 | int px = bounds.left + size / 2 + 1; 58 | int py = bounds.top + size / 2 + 1; 59 | for (int i = 0; i < getChildCount(); i++) { 60 | Cube cube = getChildAt(i); 61 | cube.setDrawBounds( 62 | bounds.left, 63 | bounds.top, 64 | px, 65 | py 66 | ); 67 | cube.setPivotX(cube.getDrawBounds().right); 68 | cube.setPivotY(cube.getDrawBounds().bottom); 69 | } 70 | } 71 | 72 | @Override 73 | public Cube getChildAt(int index) { 74 | return ((Cube) super.getChildAt(index)); 75 | } 76 | 77 | @Override 78 | public void drawChildren(@NonNull Canvas canvas) { 79 | 80 | Rect bounds = clipSquare(getBounds()); 81 | for (int i = 0; i < getChildCount(); i++) { 82 | int count = canvas.save(); 83 | canvas.rotate(45 + i * 90, bounds.centerX(), bounds.centerY()); 84 | Cube cube = getChildAt(i); 85 | cube.draw(canvas); 86 | canvas.restoreToCount(count); 87 | } 88 | } 89 | 90 | private class Cube extends RectAnimDrawable { 91 | 92 | Cube() { 93 | setAlpha(0); 94 | setRotationX(-180); 95 | } 96 | 97 | @Override 98 | public ValueAnimator createAnimator() { 99 | float fractions[] = new float[]{0f, 0.1f, 0.25f, 0.75f, 0.9f, 1f}; 100 | return new DrawableAnimatorBuilder(this) 101 | .alpha(fractions, 0f, 0f, 1f, 1f, 0f, 0f) 102 | .rotateX(fractions, -180f, -180f, 0f, 0f, 0f, 0f) 103 | .rotateY(fractions, 0f, 0f, 0f, 0f, 180f, 180f) 104 | .duration(2400) 105 | .interpolator(new LinearInterpolator()) 106 | .build(); 107 | } 108 | } 109 | 110 | 111 | } 112 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/MultiplePulse.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.graphics.drawable.Drawable; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 7 | import com.simon.core.animationtools.drawable.shape.Pulse; 8 | 9 | /** 10 | * MultiplePulse 11 | * Created by simon on 17-6-8. 12 | */ 13 | 14 | public class MultiplePulse extends AnimDrawableContainer { 15 | 16 | @NonNull 17 | @Override 18 | public Drawable[] createChildren() { 19 | Pulse[] children = { 20 | new Pulse(), 21 | new Pulse(), 22 | new Pulse(), 23 | }; 24 | for (int i = 0; i < children.length; i++) { 25 | children[i].setAnimationDelay(200 * (i + 1)); 26 | } 27 | return children; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/RotatingDots.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Canvas; 5 | import android.graphics.Rect; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.support.annotation.NonNull; 9 | 10 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 11 | import com.simon.core.animationtools.drawable.shape.CircleAnimDrawable; 12 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 13 | 14 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 15 | 16 | /** 17 | * RotatingDots 18 | * Created by simon on 17-6-8. 19 | */ 20 | 21 | public class RotatingDots extends AnimDrawableContainer { 22 | 23 | 24 | @Override 25 | public void drawChildren(@NonNull Canvas canvas) { 26 | for (int i = 0; i < getChildCount(); i++) { 27 | Dot dot = getChildAt(i); 28 | int count = canvas.save(); 29 | canvas.rotate(i * 360 / getChildCount(), 30 | getBounds().centerX(), 31 | getBounds().centerY()); 32 | dot.draw(canvas); 33 | canvas.restoreToCount(count); 34 | } 35 | } 36 | 37 | @Override 38 | protected void onBoundsChange(Rect bounds) { 39 | super.onBoundsChange(bounds); 40 | bounds = clipSquare(bounds); 41 | int radius = (int) (bounds.width() * Math.PI / 3f / getChildCount()); 42 | int left = bounds.centerX() - radius; 43 | int right = bounds.centerX() + radius; 44 | for (int i = 0; i < getChildCount(); i++) { 45 | Dot dot = getChildAt(i); 46 | dot.setDrawBounds(left, bounds.top, right, bounds.top + radius * 2); 47 | } 48 | } 49 | 50 | @Override 51 | public Dot getChildAt(int index) { 52 | return ((Dot) super.getChildAt(index)); 53 | } 54 | 55 | @NonNull 56 | @Override 57 | public Drawable[] createChildren() { 58 | Dot[] dots = new Dot[12]; 59 | for (int i = 0; i < dots.length; i++) { 60 | dots[i] = new Dot(); 61 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 62 | dots[i].setAnimationDelay(1200 / 12 * i); 63 | } else { 64 | dots[i].setAnimationDelay(1200 / 12 * i + -1200); 65 | } 66 | } 67 | return dots; 68 | } 69 | 70 | 71 | private class Dot extends CircleAnimDrawable { 72 | 73 | Dot() { 74 | setScale(0f); 75 | } 76 | 77 | @Override 78 | public ValueAnimator createAnimator() { 79 | float fractions[] = new float[]{0f, 0.5f, 1f}; 80 | return new DrawableAnimatorBuilder(this). 81 | scale(fractions, 0f, 1f, 0f). 82 | duration(1200). 83 | easeInOut(fractions) 84 | .build(); 85 | } 86 | } 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/RotatingDots2.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Canvas; 5 | import android.graphics.Rect; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.support.annotation.NonNull; 9 | 10 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 11 | import com.simon.core.animationtools.drawable.shape.CircleAnimDrawable; 12 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 13 | 14 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 15 | 16 | /** 17 | * 18 | * Created by simon on 17-6-8. 19 | */ 20 | 21 | public class RotatingDots2 extends AnimDrawableContainer { 22 | 23 | 24 | @Override 25 | public void drawChildren(@NonNull Canvas canvas) { 26 | for (int i = 0; i < getChildCount(); i++) { 27 | Dot dot = getChildAt(i); 28 | int count = canvas.save(); 29 | canvas.rotate(i * 360 / getChildCount(), 30 | getBounds().centerX(), 31 | getBounds().centerY()); 32 | dot.draw(canvas); 33 | canvas.restoreToCount(count); 34 | } 35 | } 36 | 37 | @Override 38 | protected void onBoundsChange(Rect bounds) { 39 | super.onBoundsChange(bounds); 40 | bounds = clipSquare(bounds); 41 | int radius = (int) (bounds.width() * Math.PI / 3f / getChildCount()); 42 | int left = bounds.centerX() - radius; 43 | int right = bounds.centerX() + radius; 44 | for (int i = 0; i < getChildCount(); i++) { 45 | Dot dot = getChildAt(i); 46 | dot.setDrawBounds(left, bounds.top, right, bounds.top + radius * 2); 47 | } 48 | } 49 | 50 | @Override 51 | public Dot getChildAt(int index) { 52 | return ((Dot) super.getChildAt(index)); 53 | } 54 | 55 | @NonNull 56 | @Override 57 | public Drawable[] createChildren() { 58 | Dot[] dots = new Dot[12]; 59 | for (int i = 0; i < dots.length; i++) { 60 | dots[i] = new Dot(); 61 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 62 | dots[i].setAnimationDelay(1200 / 12 * i); 63 | } else { 64 | dots[i].setAnimationDelay(1200 / 12 * i + -1200); 65 | } 66 | } 67 | return dots; 68 | } 69 | 70 | 71 | private class Dot extends CircleAnimDrawable { 72 | 73 | Dot() { 74 | setAlpha(0); 75 | } 76 | 77 | @Override 78 | public ValueAnimator createAnimator() { 79 | float fractions[] = new float[]{0f, 0.39f, 0.4f, 1f}; 80 | return new DrawableAnimatorBuilder(this) 81 | .alpha(fractions, 0f, 0f, 1f, 0f) 82 | .duration(1200) 83 | .easeInOut(fractions) 84 | .build(); 85 | } 86 | } 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/ThreeBounce.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Rect; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.annotation.NonNull; 7 | 8 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 9 | import com.simon.core.animationtools.drawable.shape.CircleAnimDrawable; 10 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 11 | 12 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 13 | 14 | /** 15 | * ThreeBounce 16 | * Created by simon on 17-6-8. 17 | */ 18 | 19 | public class ThreeBounce extends AnimDrawableContainer{ 20 | 21 | @NonNull 22 | @Override 23 | public Drawable[] createChildren() { 24 | Bounce[] bounces = { 25 | new Bounce(), 26 | new Bounce(), 27 | new Bounce() 28 | }; 29 | bounces[1].setAnimationDelay(160); 30 | bounces[2].setAnimationDelay(320); 31 | return bounces; 32 | } 33 | 34 | @Override 35 | public Bounce getChildAt(int index) { 36 | return ((Bounce) super.getChildAt(index)); 37 | } 38 | 39 | @Override 40 | protected void onBoundsChange(Rect bounds) { 41 | super.onBoundsChange(bounds); 42 | bounds = clipSquare(bounds); 43 | int radius = bounds.width() / 6; 44 | int top = bounds.centerY() - radius; 45 | int bottom = bounds.centerY() + radius; 46 | 47 | for (int i = 0; i < getChildCount(); i++) { 48 | int center = bounds.width() * (i + 1) / 4 49 | + bounds.left; 50 | getChildAt(i).setDrawBounds( 51 | center - radius, top, center + radius, bottom 52 | ); 53 | } 54 | } 55 | 56 | private class Bounce extends CircleAnimDrawable { 57 | 58 | Bounce() { 59 | setScale(0f); 60 | } 61 | 62 | @Override 63 | public ValueAnimator createAnimator() { 64 | float fractions[] = new float[]{0f, 0.4f, 0.8f, 1f}; 65 | return new DrawableAnimatorBuilder(this).scale(fractions, 0f, 1f, 0f, 0f). 66 | duration(1400). 67 | easeInOut(fractions) 68 | .build(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/WanderingCubes.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Color; 5 | import android.graphics.Rect; 6 | import android.graphics.drawable.Drawable; 7 | import android.support.annotation.NonNull; 8 | 9 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 10 | import com.simon.core.animationtools.drawable.AnimationDrawable; 11 | import com.simon.core.animationtools.drawable.shape.RectAnimDrawable; 12 | import com.simon.core.animationtools.animator.AnimatorBuilder; 13 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 14 | 15 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 16 | 17 | /** 18 | * Wandering cubes 19 | * Created by simon on 17-6-8. 20 | */ 21 | 22 | public class WanderingCubes extends AnimDrawableContainer { 23 | 24 | 25 | @NonNull 26 | @Override 27 | public Drawable[] createChildren() { 28 | return new AnimationDrawable[]{ 29 | new Cube(0, Color.RED), 30 | new Cube(3,Color.BLUE) 31 | }; 32 | } 33 | 34 | @Override 35 | protected void onBoundsChange(Rect bounds) { 36 | super.onBoundsChange(bounds); 37 | bounds = clipSquare(bounds); 38 | for (int i = 0; i < getChildCount(); i++) { 39 | Drawable child = getChildAt(i); 40 | ((AnimationDrawable) child).setDrawBounds( 41 | bounds.left, 42 | bounds.top, 43 | bounds.left + bounds.width() / 4, 44 | bounds.top + bounds.height() / 4 45 | ); 46 | } 47 | } 48 | 49 | private class Cube extends RectAnimDrawable { 50 | int startFrame; 51 | 52 | public Cube(int startFrame, int color) { 53 | super(); 54 | this.startFrame = startFrame; 55 | setColor(color); 56 | } 57 | 58 | @Override 59 | public ValueAnimator createAnimator() { 60 | float fractions[] = new float[]{0f, 0.25f, 0.5f, 0.51f, 0.75f, 1f}; 61 | AnimatorBuilder builder = new DrawableAnimatorBuilder(this) 62 | .rotate(fractions, 0f, -90f, -179f, -180f, -270f, -360f) 63 | .translateXPercentage(fractions, 0f, 0.75f, 0.75f, 0.75f, 0f, 0f) 64 | .translateYPercentage(fractions, 0f, 0f, 0.75f, 0.75f, 0.75f, 0f) 65 | .scale(fractions, 1f, 0.5f, 1f, 1f, 0.5f, 1f) 66 | .duration(1800) 67 | .easeInOut(fractions) 68 | .startFrame(startFrame); 69 | return builder.build(); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/container/WavingBars.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.container; 2 | 3 | 4 | import android.animation.ValueAnimator; 5 | import android.graphics.Rect; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.support.annotation.NonNull; 9 | 10 | import com.simon.core.animationtools.drawable.AnimDrawableContainer; 11 | import com.simon.core.animationtools.drawable.AnimationDrawable; 12 | import com.simon.core.animationtools.drawable.shape.RectAnimDrawable; 13 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 14 | import com.simon.core.animationtools.utils.ShapeUtils; 15 | 16 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 17 | 18 | /** 19 | * wandering bars 20 | * Created by simon on 17-6-8. 21 | */ 22 | 23 | public class WavingBars extends AnimDrawableContainer { 24 | 25 | @NonNull 26 | @Override 27 | public AnimationDrawable[] createChildren() { 28 | AnimationDrawable[] children = ShapeUtils.createShapeArray(WavingItem.class, 5); 29 | for (int i = 0; i < children.length; i++) { 30 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 31 | children[i].setAnimationDelay(600 + i * 100); 32 | } else { 33 | children[i].setAnimationDelay(-1200 + i * 100); 34 | } 35 | } 36 | return children; 37 | } 38 | 39 | @Override 40 | protected void onBoundsChange(Rect bounds) { 41 | super.onBoundsChange(bounds); 42 | bounds = clipSquare(bounds); 43 | int rw = bounds.width() / getChildCount(); 44 | int width = bounds.width() / 5 * 3 / 5; 45 | for (int i = 0; i < getChildCount(); i++) { 46 | Drawable child = getChildAt(i); 47 | int l = bounds.left + i * rw + rw / 5; 48 | int r = l + width; 49 | ((AnimationDrawable) child).setDrawBounds(l, bounds.top, r, bounds.bottom); 50 | } 51 | } 52 | 53 | public static class WavingItem extends RectAnimDrawable { 54 | 55 | WavingItem() { 56 | setScaleY(0.4f); 57 | } 58 | 59 | @Override 60 | public ValueAnimator createAnimator() { 61 | float fractions[] = new float[]{0f, 0.2f, 0.4f, 1f}; 62 | return new DrawableAnimatorBuilder(this).scaleY(fractions, 0.4f, 1f, 0.4f, 0.4f) 63 | .duration(1200) 64 | .easeInOut(fractions) 65 | .build(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/shape/CircleAnimDrawable.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.shape; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | import android.graphics.Rect; 6 | 7 | /** 8 | * CircleAnimDrawable 9 | * Created by simon on 17-6-7. 10 | */ 11 | 12 | public abstract class CircleAnimDrawable extends ShapeAnimDrawable { 13 | 14 | @Override 15 | public void drawShape(Canvas canvas, Paint paint) { 16 | Rect drawBounds = getDrawBounds(); 17 | int radius = Math.min(drawBounds.width() / 2, drawBounds.height()) / 2; 18 | canvas.drawCircle(drawBounds.centerX(), 19 | drawBounds.centerY(), 20 | radius, paint); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/shape/Pulse.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.shape; 2 | 3 | import android.animation.ValueAnimator; 4 | 5 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 6 | 7 | /** 8 | * Created by simon on 17-6-7. 9 | */ 10 | 11 | public class Pulse extends CircleAnimDrawable { 12 | 13 | public Pulse() { 14 | setScale(0f); 15 | } 16 | 17 | @Override 18 | public ValueAnimator createAnimator() { 19 | float fractions[] = new float[]{0f, 1f}; 20 | return new DrawableAnimatorBuilder(this) 21 | .scale(fractions, 0f, 1f) 22 | .alpha(fractions, 1f, 0f) 23 | .duration(1000) 24 | .easeInOut(fractions) 25 | .build(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/shape/RectAnimDrawable.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.shape; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | /** 7 | * abstract class ofRect animation drawable 8 | * Created by simon on 17-6-6. 9 | */ 10 | 11 | public abstract class RectAnimDrawable extends ShapeAnimDrawable { 12 | @Override 13 | public void drawShape(Canvas canvas, Paint paint) { 14 | canvas.drawRect(getDrawBounds(),paint); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/shape/RotatingPlane.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.shape; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.graphics.Rect; 5 | 6 | import com.simon.core.animationtools.animator.DrawableAnimatorBuilder; 7 | 8 | import static com.simon.core.animationtools.utils.ShapeUtils.clipSquare; 9 | 10 | public class RotatingPlane extends RectAnimDrawable { 11 | 12 | @Override 13 | protected void onBoundsChange(Rect bounds) { 14 | setDrawBounds(clipSquare(bounds)); 15 | } 16 | 17 | @Override 18 | public ValueAnimator createAnimator() { 19 | float fractions[] = new float[]{0f, 0.5f, 1f}; 20 | return new DrawableAnimatorBuilder(this). 21 | rotateX(fractions, 0f, -180f, -180f). 22 | rotateY(fractions, 0f, 0f, -180f). 23 | duration(1200). 24 | easeInOut(fractions) 25 | .build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/drawable/shape/ShapeAnimDrawable.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.drawable.shape; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.graphics.ColorFilter; 6 | import android.graphics.Paint; 7 | 8 | import com.simon.core.animationtools.drawable.AnimationDrawable; 9 | 10 | /** 11 | * 12 | * Created by simon on 17-6-6. 13 | */ 14 | 15 | public abstract class ShapeAnimDrawable extends AnimationDrawable { 16 | 17 | private Paint mPaint; 18 | private int mUseColor; 19 | private int mBaseColor; 20 | 21 | public ShapeAnimDrawable() { 22 | super(); 23 | setColor(Color.WHITE); 24 | mPaint = new Paint(); 25 | mPaint.setAntiAlias(true); 26 | mPaint.setColor(mUseColor); 27 | } 28 | 29 | public void setColor(int color) { 30 | mBaseColor = color; 31 | updateUseColor(); 32 | } 33 | 34 | public int getColor() { 35 | return mBaseColor; 36 | } 37 | 38 | @SuppressWarnings("unused") 39 | public int getUseColor() { 40 | return mUseColor; 41 | } 42 | 43 | @Override 44 | public void setAlpha(int alpha) { 45 | super.setAlpha(alpha); 46 | updateUseColor(); 47 | } 48 | 49 | 50 | private void updateUseColor() { 51 | int alpha = getAlpha(); 52 | alpha += alpha >> 7; 53 | final int baseAlpha = mBaseColor >>> 24; 54 | final int useAlpha = baseAlpha * alpha >> 8; 55 | mUseColor = (mBaseColor << 8 >>> 8) | (useAlpha << 24); 56 | } 57 | 58 | @Override 59 | public void setColorFilter(ColorFilter colorFilter) { 60 | mPaint.setColorFilter(colorFilter); 61 | } 62 | 63 | @Override 64 | protected final void drawSelf(Canvas canvas) { 65 | mPaint.setColor(mUseColor); 66 | drawShape(canvas, mPaint); 67 | } 68 | 69 | public abstract void drawShape(Canvas canvas, Paint paint); 70 | 71 | } 72 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/utils/ShapeUtils.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.utils; 2 | 3 | import android.graphics.Rect; 4 | 5 | import com.simon.core.animationtools.drawable.AnimationDrawable; 6 | import com.simon.core.animationtools.drawable.shape.ShapeAnimDrawable; 7 | 8 | import java.lang.reflect.Constructor; 9 | import java.lang.reflect.InvocationTargetException; 10 | 11 | /** 12 | * utils of shapes 13 | * Created by simon on 17-6-8. 14 | */ 15 | 16 | public class ShapeUtils { 17 | 18 | public static AnimationDrawable[] createShapeArray(Class clazz, int count) { 19 | AnimationDrawable[] array = new AnimationDrawable[count]; 20 | try { 21 | Constructor constructor = clazz.getConstructor(); 22 | for (int i = 0; i < array.length; i++) { 23 | array[i] = constructor.newInstance(); 24 | } 25 | return array; 26 | } catch (NoSuchMethodException e) { 27 | e.printStackTrace(); 28 | } catch (IllegalAccessException e) { 29 | e.printStackTrace(); 30 | } catch (InstantiationException e) { 31 | e.printStackTrace(); 32 | } catch (InvocationTargetException e) { 33 | e.printStackTrace(); 34 | } 35 | throw new IllegalStateException("class " + clazz.getName() + " cannot new instance"); 36 | } 37 | 38 | public static Rect clipSquare(Rect rect) { 39 | int w = rect.width(); 40 | int h = rect.height(); 41 | int min = Math.min(w, h); 42 | int cx = rect.centerX(); 43 | int cy = rect.centerY(); 44 | int r = min / 2; 45 | return new Rect( 46 | cx - r, 47 | cy - r, 48 | cx + r, 49 | cy + r 50 | ); 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /library/src/main/java/com/simon/core/animationtools/view/InterpolatorCanvas.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.support.annotation.Nullable; 8 | import android.util.AttributeSet; 9 | import android.view.View; 10 | import android.view.animation.Interpolator; 11 | 12 | /** 13 | * Created by simon on 17-5-12. 14 | */ 15 | 16 | public class InterpolatorCanvas extends View { 17 | 18 | private Interpolator interpolator; 19 | 20 | private Paint paint; 21 | 22 | public InterpolatorCanvas(Context context) { 23 | super(context); 24 | init(); 25 | } 26 | 27 | public InterpolatorCanvas(Context context, @Nullable AttributeSet attrs) { 28 | super(context, attrs); 29 | init(); 30 | } 31 | 32 | public InterpolatorCanvas(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { 33 | super(context, attrs, defStyleAttr); 34 | init(); 35 | } 36 | 37 | public void setInterpolator(Interpolator interpolator) { 38 | this.interpolator = interpolator; 39 | } 40 | 41 | private void init() { 42 | paint = new Paint(); 43 | paint.setAntiAlias(true); 44 | 45 | paint.setStrokeWidth(2); 46 | paint.setStyle(Paint.Style.FILL); 47 | } 48 | 49 | @Override 50 | protected void onDraw(Canvas canvas) { 51 | super.onDraw(canvas); 52 | int width = getWidth(); 53 | int height = getHeight(); 54 | paint.setColor(Color.GRAY); 55 | canvas.drawRect(0, 0, width, height, paint); 56 | if (interpolator == null) return; 57 | paint.setColor(Color.BLUE); 58 | for (int i = 0; i < width; i++) { 59 | float x = (((float) i) / width); 60 | float y = interpolator.getInterpolation(x); 61 | canvas.drawPoint(x * width, (1 - y) * height, paint); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | 4 | -------------------------------------------------------------------------------- /library/src/test/java/com/simon/core/animationtools/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.simon.core.animationtools; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.simon.animationtools" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.2.0' 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:recyclerview-v7:25.2.0' 30 | compile project(':library') 31 | } 32 | -------------------------------------------------------------------------------- /sample/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 /home/simon/developer/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/simon/animationtools/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 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 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.simon.animationtools", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sample/src/main/java/com/simon/animationtools/Assets.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 2 | 3 | import static android.graphics.Color.parseColor; 4 | 5 | /** 6 | * 7 | * Created by simon on 17-6-8. 8 | */ 9 | 10 | class Assets { 11 | 12 | static int[] colors = new int[]{ 13 | parseColor("#D55400"), 14 | parseColor("#00BD9C"), 15 | parseColor("#227FBB"), 16 | parseColor("#7F8C8D"), 17 | parseColor("#FFCC5C"), 18 | parseColor("#D55400"), 19 | parseColor("#1AAF5D"), 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /sample/src/main/java/com/simon/animationtools/DetailActivity.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.os.Bundle; 8 | import android.support.v4.view.PagerAdapter; 9 | import android.support.v4.view.ViewPager; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.ImageView; 14 | 15 | import com.simon.core.animationtools.drawable.AnimationDrawable; 16 | import com.simon.core.animationtools.drawable.container.ChasingDots; 17 | import com.simon.core.animationtools.drawable.container.CubeGrid; 18 | import com.simon.core.animationtools.drawable.container.DoubleCircleBounce; 19 | import com.simon.core.animationtools.drawable.container.FoldingCube; 20 | import com.simon.core.animationtools.drawable.container.MultiplePulse; 21 | import com.simon.core.animationtools.drawable.container.RotatingDots; 22 | import com.simon.core.animationtools.drawable.container.RotatingDots2; 23 | import com.simon.core.animationtools.drawable.container.ThreeBounce; 24 | import com.simon.core.animationtools.drawable.container.WanderingCubes; 25 | import com.simon.core.animationtools.drawable.container.WavingBars; 26 | import com.simon.core.animationtools.drawable.shape.RotatingPlane; 27 | import com.simon.core.animationtools.animator.ArgbEvaluator; 28 | 29 | import static com.simon.animationtools.Assets.colors; 30 | 31 | /** 32 | * test activity 33 | * Created by simon on 17-6-6. 34 | */ 35 | 36 | public class DetailActivity extends Activity { 37 | 38 | private static AnimationDrawable[] drawables = 39 | {new WavingBars(), new WanderingCubes(), new FoldingCube(), 40 | new CubeGrid(), new RotatingPlane(), new RotatingDots(), 41 | new RotatingDots2(), new DoubleCircleBounce(), new MultiplePulse(), 42 | new ThreeBounce(),new ChasingDots()}; 43 | 44 | public static void start(Context context, int position) { 45 | Intent intent = new Intent(context, DetailActivity.class); 46 | intent.putExtra("position", position); 47 | context.startActivity(intent); 48 | } 49 | 50 | @Override 51 | protected void onCreate(Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | setContentView(R.layout.activity_detail); 54 | ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); 55 | viewPager.setOffscreenPageLimit(0); 56 | viewPager.setAdapter(new PagerAdapter() { 57 | @Override 58 | public int getCount() { 59 | return drawables.length; 60 | } 61 | 62 | @Override 63 | public boolean isViewFromObject(View view, Object object) { 64 | return view == object; 65 | } 66 | 67 | @Override 68 | public Object instantiateItem(ViewGroup container, int position) { 69 | @SuppressLint("InflateParams") View view = LayoutInflater.from(container.getContext()).inflate(R.layout.item_pager, null); 70 | 71 | ImageView imageView = (ImageView) view.findViewById(R.id.image); 72 | AnimationDrawable drawable = drawables[position]; 73 | imageView.setImageDrawable(drawable); 74 | drawable.start(); 75 | container.addView(view); 76 | return view; 77 | } 78 | 79 | @Override 80 | public void destroyItem(ViewGroup container, int position, Object object) { 81 | container.removeView((View) object); 82 | } 83 | }); 84 | 85 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 86 | @Override 87 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 88 | int color = (int) ArgbEvaluator.getInstance().evaluate(positionOffset, 89 | colors[position % colors.length], 90 | colors[(position + 1) % colors.length]); 91 | getWindow().getDecorView().setBackgroundColor(color); 92 | } 93 | 94 | @Override 95 | public void onPageSelected(int position) { 96 | getWindow().getDecorView().setBackgroundColor(colors[position % colors.length]); 97 | } 98 | 99 | @Override 100 | public void onPageScrollStateChanged(int state) { 101 | 102 | } 103 | }); 104 | 105 | viewPager.setCurrentItem(getIntent().getIntExtra("position", 0)); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /sample/src/main/java/com/simon/animationtools/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.support.v7.widget.GridLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.ImageView; 11 | 12 | import com.simon.core.animationtools.drawable.AnimationDrawable; 13 | import com.simon.core.animationtools.drawable.container.ChasingDots; 14 | import com.simon.core.animationtools.drawable.container.CubeGrid; 15 | import com.simon.core.animationtools.drawable.container.DoubleCircleBounce; 16 | import com.simon.core.animationtools.drawable.container.FoldingCube; 17 | import com.simon.core.animationtools.drawable.container.MultiplePulse; 18 | import com.simon.core.animationtools.drawable.container.RotatingDots; 19 | import com.simon.core.animationtools.drawable.container.RotatingDots2; 20 | import com.simon.core.animationtools.drawable.container.ThreeBounce; 21 | import com.simon.core.animationtools.drawable.container.WanderingCubes; 22 | import com.simon.core.animationtools.drawable.container.WavingBars; 23 | import com.simon.core.animationtools.drawable.shape.RotatingPlane; 24 | 25 | import static com.simon.animationtools.Assets.colors; 26 | 27 | public class MainActivity extends AppCompatActivity { 28 | 29 | public static AnimationDrawable[] drawables = 30 | {new WavingBars(), new WanderingCubes(), new FoldingCube(), 31 | new CubeGrid(), new RotatingPlane(), new RotatingDots(), 32 | new RotatingDots2(), new DoubleCircleBounce(), new MultiplePulse(), 33 | new ThreeBounce(),new ChasingDots()}; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_main); 39 | RecyclerView list = (RecyclerView) findViewById(R.id.list); 40 | list.setLayoutManager(new GridLayoutManager(this,3)); 41 | list.setAdapter(new Adapter()); 42 | } 43 | 44 | private static class Adapter extends RecyclerView.Adapter{ 45 | 46 | @Override 47 | public Holder onCreateViewHolder(ViewGroup parent, int viewType) { 48 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, parent, false); 49 | return new Holder(view); 50 | } 51 | 52 | @Override 53 | public void onBindViewHolder(Holder holder, int position) { 54 | holder.bind(drawables[position], position); 55 | } 56 | 57 | @Override 58 | public int getItemCount() { 59 | return drawables.length; 60 | } 61 | } 62 | 63 | static class Holder extends RecyclerView.ViewHolder{ 64 | 65 | private ImageView imageView; 66 | 67 | Holder(View itemView) { 68 | super(itemView); 69 | imageView = (ImageView) itemView.findViewById(R.id.image); 70 | } 71 | 72 | void bind(AnimationDrawable drawable, final int position) { 73 | itemView.setBackgroundColor(colors[position % colors.length]); 74 | imageView.setImageDrawable(drawable); 75 | drawable.start(); 76 | itemView.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | DetailActivity.start(v.getContext(), position); 80 | } 81 | }); 82 | } 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /sample/src/main/java/com/simon/animationtools/SquareFrameLayout.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.os.Build; 6 | import android.util.AttributeSet; 7 | import android.widget.FrameLayout; 8 | 9 | public class SquareFrameLayout extends FrameLayout { 10 | public SquareFrameLayout(Context context) { 11 | super(context); 12 | } 13 | 14 | public SquareFrameLayout(Context context, AttributeSet attrs) { 15 | super(context, attrs); 16 | } 17 | 18 | public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { 19 | super(context, attrs, defStyleAttr); 20 | } 21 | 22 | @SuppressWarnings("unused") 23 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 24 | public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 25 | super(context, attrs, defStyleAttr, defStyleRes); 26 | } 27 | 28 | @Override 29 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 30 | //noinspection SuspiciousNameCombination 31 | super.onMeasure(widthMeasureSpec, widthMeasureSpec); 32 | } 33 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_pager.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AnimationTools 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/simon/animationtools/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.simon.animationtools; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /screen_record.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/screen_record.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | -------------------------------------------------------------------------------- /wavingbars_sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwei1993/AndroidAnimationTools/54ff9cab9a83c5d284ffc1d596a11fefca81ad0e/wavingbars_sample.gif --------------------------------------------------------------------------------