├── app ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── sikeeo │ │ └── eeanimator │ │ ├── EEAnimationListener.java │ │ ├── EEAnimationProperty.java │ │ ├── EEViewAnimator.java │ │ └── EEAnimationBuilder.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── EEAnimator.iml ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikeeoh/EEAnimator/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 13 17:59:14 KST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | /*/build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio 30 | .idea/ 31 | *.iml 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/sikeeo/eeanimator/EEAnimationListener.java: -------------------------------------------------------------------------------- 1 | package com.sikeeo.eeanimator; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by sikeeo on 2016. 1. 4.. 7 | */ 8 | public class EEAnimationListener { 9 | private EEAnimationListener() { 10 | } 11 | 12 | public interface Start { 13 | void onStart(); 14 | } 15 | 16 | public interface Stop { 17 | void onStop(); 18 | } 19 | 20 | protected interface Update { 21 | void update(V view, float value); 22 | } 23 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.novoda.bintray-release' 3 | 4 | 5 | publish { 6 | userOrg = 'sikeeo' 7 | groupId = 'com.sikeeo.eeanimator' 8 | artifactId = 'eeanimator' 9 | publishVersion = '1.0.2' 10 | desc = 'A sikeeo Android animation library' 11 | website = 'https://github.com/sikeeo/EEAnimator' 12 | issueTracker = "${website}/issues" 13 | repository = "${website}.git" 14 | } 15 | 16 | android { 17 | compileSdkVersion 23 18 | buildToolsVersion "23.0.2" 19 | 20 | defaultConfig { 21 | minSdkVersion 14 22 | targetSdkVersion 23 23 | versionCode 1 24 | versionName "${LIB_VERSION}" 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/mozzet/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/sikeeo/eeanimator/EEAnimationProperty.java: -------------------------------------------------------------------------------- 1 | package com.sikeeo.eeanimator; 2 | 3 | /** 4 | * Created by sikeeo on 2016. 1. 5.. 5 | */ 6 | public class EEAnimationProperty { 7 | 8 | public final static String TRANSLATION_X = "translationX"; 9 | public final static String TRANSLATION_Y = "translationY"; 10 | public final static String ALPHA = "alpha"; 11 | public final static String SCALE_X = "scaleX"; 12 | public final static String SCALE_Y = "scaleY"; 13 | public final static String ROTATION = "rotation"; 14 | public final static String ROTATION_X = "rotationX"; 15 | public final static String ROTATION_Y = "rotationY"; 16 | public final static String BACKGROUND_COLOR = "backgroundColor"; 17 | public final static String TEXT_COLOR = "textColor"; 18 | } 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | LIB_VERSION = 1.0.2 -------------------------------------------------------------------------------- /EEAnimator.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/java/com/sikeeo/eeanimator/EEViewAnimator.java: -------------------------------------------------------------------------------- 1 | package com.sikeeo.eeanimator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.AnimatorSet; 5 | import android.view.View; 6 | import android.view.ViewTreeObserver; 7 | import android.view.animation.Interpolator; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by sikeeo on 2016. 1. 4.. 14 | */ 15 | public class EEViewAnimator { 16 | 17 | List eeAnimationList = new ArrayList<>(); 18 | Long duration = 0L; 19 | Interpolator interpolator = null; 20 | 21 | AnimatorSet animatorSet; 22 | View waitView = null; 23 | 24 | EEAnimationListener.Start startListener; 25 | EEAnimationListener.Stop stopListener; 26 | 27 | EEViewAnimator prevAnimator = null; 28 | EEViewAnimator nextAnimator = null; 29 | 30 | public static EEAnimationBuilder animate(View... views) { 31 | EEViewAnimator eeViewAnimator = new EEViewAnimator(); 32 | return eeViewAnimator.addAnimationBuilder(views); 33 | } 34 | 35 | public EEAnimationBuilder nextAnimate(View... views) { 36 | EEViewAnimator nextViewAnimator = new EEViewAnimator(); 37 | this.nextAnimator = nextViewAnimator; 38 | nextViewAnimator.prevAnimator = this; 39 | return nextAnimator.addAnimationBuilder(views); 40 | } 41 | 42 | public EEAnimationBuilder addAnimationBuilder(View... views) { 43 | EEAnimationBuilder eeAnimationBuilder = new EEAnimationBuilder(this, views); 44 | eeAnimationList.add(eeAnimationBuilder); 45 | return eeAnimationBuilder; 46 | } 47 | 48 | public AnimatorSet createAnimatorSet() { 49 | List animators = new ArrayList<>(); 50 | for (EEAnimationBuilder eeAnimationBuilder : eeAnimationList) { 51 | animators.addAll(eeAnimationBuilder.createAnimators()); 52 | } 53 | 54 | for (EEAnimationBuilder eeAnimationBuilder : eeAnimationList) { 55 | if (eeAnimationBuilder.isWaitForView()) { 56 | waitView = eeAnimationBuilder.getView(); 57 | break; 58 | } 59 | } 60 | 61 | AnimatorSet animatorSet = new AnimatorSet(); 62 | animatorSet.playTogether(animators); 63 | 64 | if (duration != null) animatorSet.setDuration(duration); 65 | if (interpolator != null) animatorSet.setInterpolator(interpolator); 66 | 67 | animatorSet.addListener(new Animator.AnimatorListener() { 68 | @Override 69 | public void onAnimationStart(Animator animation) { 70 | if (startListener != null) startListener.onStart(); 71 | } 72 | 73 | @Override 74 | public void onAnimationEnd(Animator animation) { 75 | if (stopListener != null) stopListener.onStop(); 76 | if (nextAnimator != null) { 77 | nextAnimator.prevAnimator = null; 78 | nextAnimator.start(); 79 | } 80 | } 81 | 82 | @Override 83 | public void onAnimationCancel(Animator animation) { 84 | 85 | } 86 | 87 | @Override 88 | public void onAnimationRepeat(Animator animation) { 89 | 90 | } 91 | 92 | }); 93 | 94 | return animatorSet; 95 | } 96 | 97 | public EEViewAnimator start() { 98 | if (prevAnimator != null) { 99 | prevAnimator.start(); 100 | } else { 101 | animatorSet = createAnimatorSet(); 102 | 103 | if (waitView != null) { 104 | waitView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 105 | @Override 106 | public boolean onPreDraw() { 107 | animatorSet.start(); 108 | waitView.getViewTreeObserver().removeOnPreDrawListener(this); 109 | return false; 110 | } 111 | }); 112 | } else { 113 | animatorSet.start(); 114 | } 115 | } 116 | return this; 117 | } 118 | 119 | public void cancel() { 120 | if (animatorSet != null) { 121 | animatorSet.cancel(); 122 | } 123 | if (nextAnimator != null) { 124 | nextAnimator.cancel(); 125 | nextAnimator = null; 126 | } 127 | } 128 | 129 | public EEViewAnimator duration(long duration) { 130 | this.duration = duration; 131 | return this; 132 | } 133 | 134 | public EEViewAnimator onStart(EEAnimationListener.Start startListener) { 135 | this.startListener = startListener; 136 | return this; 137 | } 138 | 139 | public EEViewAnimator onStop(EEAnimationListener.Stop stopListener) { 140 | this.stopListener = stopListener; 141 | return this; 142 | } 143 | 144 | public EEViewAnimator interpolator(Interpolator interpolator) { 145 | this.interpolator = interpolator; 146 | return this; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EEAnimator 2 | A musubioh's Android animation library 3 | ======= 4 | 5 | [![API](https://img.shields.io/badge/API-14%2B-green.svg)](https://github.com/musubioh/EEAnimator) 6 | 7 | 8 | #Usage 9 | 10 | ```java 11 | EEViewAnimator.animate(ivSample1, ivSample2, tvTest) 12 | .translationY(-1000, 0) 13 | .alpha(0, 1f) 14 | .bounce() 15 | .duration(3000) 16 | .nextAnimate(ivSample2) 17 | .translationX(0, -500, 0) 18 | .overShoot() 19 | .duration(2200) 20 | .nextAnimate(tvTest) 21 | .rotation(360) 22 | .duration(2000) 23 | .nextAnimate(ivSample2) 24 | .scale(1f, 0.5f, 1f) 25 | .accelerate() 26 | .duration(1500) 27 | .start(); 28 | 29 | ``` 30 | 31 | [![gif](http://i.giphy.com/BHM3pgcKJIhcA.gif)](https://youtu.be/SHS1neM53Hc) 32 | 33 | If you do not use a EEAnimator 34 | 35 | ```java 36 | AnimatorSet animatorSet = new AnimatorSet(); 37 | animatorSet.playTogether( 38 | ObjectAnimator.ofFloat(ivSample1, "translationY", -1000, 0), 39 | ObjectAnimator.ofFloat(ivSample2, "translationY", -1000, 0), 40 | ObjectAnimator.ofFloat(tvTest, "translationY", -1000, 0), 41 | ); 42 | animatorSet.setInterpolator(new BounceInterpolator()); 43 | animatorSet.setDuration(3000); 44 | animatorSet.addListener(new AnimatorListenerAdapter() { 45 | @Override 46 | public void onAnimationEnd(Animator animation) { 47 | AnimatorSet animatorSet2 = new AnimatorSet(); 48 | animatorSet2.playTogether( 49 | ObjectAnimator.ofFloat(ivSample2, "translationX", 0, -500, 0), 50 | ); 51 | animatorSet2.setInterpolator(new OvershootInterpolator()); 52 | animatorSet2.setDuration(2200); 53 | animatorSet2.start(); 54 | animatorSet2.addListener(new AnimatorListenerAdapter() { 55 | @Override 56 | public void onAnimationEnd(Animator animation) { 57 | AnimatorSet animatorSet3 = new AnimatorSet(); 58 | animatorSet3.playTogether( 59 | ObjectAnimator.ofFloat(tvTest, "rotation",360) 60 | ); 61 | animatorSet3.setDuration(2200); 62 | animatorSet3.start(); 63 | animatorSet3.addListener(new AnimatorListenerAdapter() { 64 | @Override 65 | public void onAnimationEnd(Animator animation) { 66 | AnimatorSet animatorSet4 = new AnimatorSet(); 67 | animatorSet4.playTogether( 68 | ObjectAnimator.ofFloat(ivSample2, "scale",1f, 0.5f, 1f) 69 | ); 70 | animatorSet4.setDuration(1500); 71 | animatorSet4.setInterpolator(new AccelerateInterpolator()); 72 | animatorSet4.start(); 73 | } 74 | }); 75 | } 76 | }); 77 | } 78 | }); 79 | 80 | animatorSet.start(); 81 | ``` 82 | 83 | #More 84 | 85 | Add listeners 86 | ```java 87 | EEViewAnimator.animate(ivSample1, ivSample2, tvTest) 88 | .translationY(-1000, 0) 89 | .alpha(0, 1f) 90 | .bounce() 91 | .duration(3000) 92 | .nextAnimate(tvTest) 93 | .scale(1f, 0.5f, 1f) 94 | .onStop(new EEAnimationListener.Stop() { 95 | @Override 96 | public void onStop() { 97 | tvTest.setText("Bye World"); 98 | } 99 | }) 100 | .duration(3000) 101 | .start(); 102 | ``` 103 | 104 | ```java 105 | EEViewAnimator 106 | .animate(image) 107 | .onStart(new EEAnimationListener.Start() { 108 | @Override 109 | public void onStart() { 110 | 111 | } 112 | }) 113 | .onStop(new EEAnimationListener.Stop() { 114 | @Override 115 | public void onStop() { 116 | 117 | } 118 | }) 119 | .start(); 120 | ``` 121 | 122 | 123 | View Height / Width (dp) 124 | ```java 125 | EEViewAnimator 126 | .animate(view) 127 | .widthDp(100,200) 128 | .heightDp(50,100) 129 | .start(); 130 | ``` 131 | 132 | Color 133 | ```java 134 | EEViewAnimator 135 | .animate(view) 136 | .textColor(Color.BLACK,Color.GREEN) 137 | .backgroundColor(Color.WHITE,Color.BLACK) 138 | .start(); 139 | ``` 140 | 141 | 142 | #Download 143 | 144 | Add into your **build.gradle** 145 | 146 | ```groovy 147 | compile 'com.sikeeo.eeanimator:eeanimator:1.0.2@aar' 148 | ``` 149 | 150 | #Community 151 | 152 | musubioh@gmail.com 153 | 154 | #License 155 | 156 | The MIT License (MIT) 157 | 158 | Copyright (c) 2017 musubioh 159 | 160 | Permission is hereby granted, free of charge, to any person obtaining a copy 161 | of this software and associated documentation files (the "Software"), to deal 162 | in the Software without restriction, including without limitation the rights 163 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 164 | copies of the Software, and to permit persons to whom the Software is 165 | furnished to do so, subject to the following conditions: 166 | 167 | The above copyright notice and this permission notice shall be included in all 168 | copies or substantial portions of the Software. 169 | 170 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 171 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 172 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 173 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 174 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 175 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 176 | SOFTWARE. 177 | 178 | -------------------------------------------------------------------------------- /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 | 203 | -------------------------------------------------------------------------------- /app/src/main/java/com/sikeeo/eeanimator/EEAnimationBuilder.java: -------------------------------------------------------------------------------- 1 | package com.sikeeo.eeanimator; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ArgbEvaluator; 5 | import android.animation.ObjectAnimator; 6 | import android.animation.ValueAnimator; 7 | import android.content.Context; 8 | import android.view.View; 9 | import android.view.animation.AccelerateDecelerateInterpolator; 10 | import android.view.animation.AccelerateInterpolator; 11 | import android.view.animation.AnticipateInterpolator; 12 | import android.view.animation.AnticipateOvershootInterpolator; 13 | import android.view.animation.BounceInterpolator; 14 | import android.view.animation.DecelerateInterpolator; 15 | import android.view.animation.Interpolator; 16 | import android.view.animation.OvershootInterpolator; 17 | import android.widget.TextView; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * Created by sikeeo on 2016. 1. 4.. 24 | */ 25 | public class EEAnimationBuilder { 26 | 27 | private final EEViewAnimator eeViewAnimator; 28 | private final View[] views; 29 | private final ArrayList animatorList; 30 | 31 | public boolean waitForView; 32 | public boolean isDp; 33 | 34 | public EEAnimationBuilder(EEViewAnimator eeViewAnimator, View... views) { 35 | this.eeViewAnimator = eeViewAnimator; 36 | this.views = views; 37 | isDp = false; 38 | animatorList = new ArrayList<>(); 39 | } 40 | 41 | public EEAnimationBuilder add(Animator animator) { 42 | this.animatorList.add(animator); 43 | return this; 44 | } 45 | 46 | public EEAnimationBuilder property(String propertyName, float... values) { 47 | for (View view : views) { 48 | this.animatorList.add(ObjectAnimator.ofFloat(view, propertyName, values)); 49 | } 50 | return this; 51 | } 52 | 53 | public EEAnimationBuilder translationX(float... x) { 54 | return property(EEAnimationProperty.TRANSLATION_X, x); 55 | } 56 | 57 | public EEAnimationBuilder translationY(float... y) { 58 | return property(EEAnimationProperty.TRANSLATION_Y, y); 59 | } 60 | 61 | public EEAnimationBuilder alpha(float... alpha) { 62 | return property(EEAnimationProperty.ALPHA, alpha); 63 | } 64 | 65 | public EEAnimationBuilder scaleX(float... scaleX) { 66 | return property(EEAnimationProperty.SCALE_X, scaleX); 67 | } 68 | 69 | public EEAnimationBuilder scaleY(float... scaleY) { 70 | return property(EEAnimationProperty.SCALE_Y, scaleY); 71 | } 72 | 73 | 74 | public EEAnimationBuilder fadeIn() { 75 | return alpha(0, 0.25f, 0.5f, 0.75f, 1); 76 | } 77 | 78 | public EEAnimationBuilder fadeOut() { 79 | return alpha(1, 0.75f, 0.5f, 0.25f, 0); 80 | } 81 | 82 | public EEAnimationBuilder flash() { 83 | return alpha(1, 0, 1, 0, 1); 84 | } 85 | 86 | public EEAnimationBuilder flipHorizontal() { 87 | return rotationX(90, -15, 15, 0); 88 | } 89 | 90 | public EEAnimationBuilder flipVertical() { 91 | return rotationY(90, -15, 15, 0); 92 | } 93 | 94 | public EEAnimationBuilder pulse() { 95 | return scaleY(1, 1.1f, 1).scaleX(1, 1.1f, 1); 96 | } 97 | 98 | public EEAnimationBuilder rollIn() { 99 | View target = getView(); 100 | return alpha(0, 1) 101 | .translationX(-(target.getWidth() - target.getPaddingLeft() - target.getPaddingRight()), 0) 102 | .rotation(-120, 0); 103 | } 104 | 105 | public EEAnimationBuilder rollOut() { 106 | View target = getView(); 107 | return alpha(1, 0) 108 | .translationX(0, target.getWidth()) 109 | .rotation(0, 120); 110 | } 111 | 112 | public EEAnimationBuilder rubber() { 113 | return scaleX(1, 1.25f, 0.75f, 1.15f, 1).scaleY(1, 0.75f, 1.25f, 0.85f, 1); 114 | } 115 | 116 | public EEAnimationBuilder shake() { 117 | return translationX(0, 25, -25, 25, -25, 15, -15, 6, -6, 0); 118 | } 119 | 120 | public EEAnimationBuilder swing() { 121 | return rotation(0, 10, -10, 6, -6, 3, -3, 0); 122 | } 123 | 124 | public EEAnimationBuilder tada() { 125 | return scaleX(1, 0.9f, 0.9f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1) 126 | .scaleY(1, 0.9f, 0.9f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1.1f, 1) 127 | .rotation(0, -3, -3, 3, -3, 3, -3, 3, -3, 0); 128 | } 129 | 130 | public EEAnimationBuilder wobble() { 131 | View target = getView(); 132 | float width = target.getWidth(); 133 | float one = (float) (width / 100.0); 134 | return translationX(0 * one, -25 * one, 20 * one, -15 * one, 10 * one, -5 * one, 0 * one, 0) 135 | .rotation(0, -5, 3, -3, 2, -1, 0); 136 | } 137 | 138 | public EEAnimationBuilder zoomIn() { 139 | return scaleX(0.45f, 1).scaleY(0.45f, 1).alpha(0, 1); 140 | } 141 | 142 | public EEAnimationBuilder zoomOut() { 143 | return scaleX(1, 0.3f, 0).scaleY(1, 0.3f, 0).alpha(1, 0, 0); 144 | } 145 | 146 | 147 | public EEAnimationBuilder scale(float... scale) { 148 | scaleX(scale); 149 | scaleY(scale); 150 | return this; 151 | } 152 | 153 | public EEAnimationBuilder pivotX(float pivotX) { 154 | for (View view : views) { 155 | view.setPivotX(pivotX); 156 | } 157 | return this; 158 | } 159 | 160 | public EEAnimationBuilder pivotY(float pivotY) { 161 | for (View view : views) { 162 | view.setPivotY(pivotY); 163 | } 164 | return this; 165 | } 166 | 167 | public EEAnimationBuilder rotationX(float... rotationX) { 168 | return property(EEAnimationProperty.ROTATION_X, rotationX); 169 | } 170 | 171 | public EEAnimationBuilder rotationY(float... rotationY) { 172 | return property(EEAnimationProperty.ROTATION_Y, rotationY); 173 | } 174 | 175 | public EEAnimationBuilder rotation(float... rotation) { 176 | return property(EEAnimationProperty.ROTATION, rotation); 177 | } 178 | 179 | public EEAnimationBuilder backgroundColor(int... colors) { 180 | for (View view : views) { 181 | if (view instanceof TextView) { 182 | ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, EEAnimationProperty.BACKGROUND_COLOR, colors); 183 | objectAnimator.setEvaluator(new ArgbEvaluator()); 184 | this.animatorList.add(objectAnimator); 185 | } 186 | } 187 | 188 | return this; 189 | } 190 | 191 | public EEAnimationBuilder backgroundColorRes(int... colorResIds) { 192 | return backgroundColor(getColorsByResIds(colorResIds)); 193 | } 194 | 195 | public EEAnimationBuilder textColor(int... colors) { 196 | for (View view : views) { 197 | if (view instanceof TextView) { 198 | ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, EEAnimationProperty.TEXT_COLOR, colors); 199 | objectAnimator.setEvaluator(new ArgbEvaluator()); 200 | this.animatorList.add(objectAnimator); 201 | } 202 | } 203 | return this; 204 | } 205 | 206 | public EEAnimationBuilder textColorRes(int... colorResIds) { 207 | return textColor(getColorsByResIds(colorResIds)); 208 | } 209 | 210 | private EEAnimationBuilder custom(final EEAnimationListener.Update updateListener, float... values) { 211 | for (final View view : views) { 212 | if (values == null) { 213 | values = new float[1]; 214 | } 215 | 216 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(values); 217 | if (updateListener != null) { 218 | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 219 | @Override 220 | public void onAnimationUpdate(ValueAnimator animation) { 221 | updateListener.update(view, Float.parseFloat(animation.getAnimatedValue().toString())); 222 | } 223 | }); 224 | add(valueAnimator); 225 | } 226 | } 227 | return this; 228 | } 229 | 230 | public EEAnimationBuilder heightDp(float... height) { 231 | if (!waitForView) waitForView(); 232 | return custom(new EEAnimationListener.Update() { 233 | @Override 234 | public void update(View view, float value) { 235 | view.getLayoutParams().height = toPx(Math.round(value)); 236 | view.requestLayout(); 237 | } 238 | }, height); 239 | } 240 | 241 | public EEAnimationBuilder heightPx(float... height) { 242 | if (!waitForView) waitForView(); 243 | return custom(new EEAnimationListener.Update() { 244 | @Override 245 | public void update(View view, float value) { 246 | view.getLayoutParams().height = Math.round(value); 247 | view.requestLayout(); 248 | } 249 | }, height); 250 | } 251 | 252 | public EEAnimationBuilder heightRes(int... dimenResIds) { 253 | return heightDp(getSizesByResIds(dimenResIds)); 254 | } 255 | 256 | public EEAnimationBuilder widthDp(float... width) { 257 | if (!waitForView) waitForView(); 258 | return custom(new EEAnimationListener.Update() { 259 | @Override 260 | public void update(View view, float value) { 261 | view.getLayoutParams().width = toPx(Math.round(value)); 262 | view.requestLayout(); 263 | } 264 | }, width); 265 | } 266 | 267 | public EEAnimationBuilder widthPx(float... width) { 268 | if (!waitForView) waitForView(); 269 | return custom(new EEAnimationListener.Update() { 270 | @Override 271 | public void update(View view, float value) { 272 | view.getLayoutParams().width = Math.round(value); 273 | view.requestLayout(); 274 | } 275 | }, width); 276 | } 277 | 278 | public EEAnimationBuilder widthRes(int... dimenResIds) { 279 | return widthDp(getSizesByResIds(dimenResIds)); 280 | } 281 | 282 | private int toPx(final float dp) { 283 | return (int) (dp * views[0].getContext().getResources().getDisplayMetrics().density); 284 | } 285 | 286 | private EEAnimationBuilder waitForView() { 287 | waitForView = true; 288 | return this; 289 | } 290 | 291 | protected List createAnimators() { 292 | return animatorList; 293 | } 294 | 295 | public EEAnimationBuilder nextAnimate(View... views) { 296 | return eeViewAnimator.nextAnimate(views); 297 | } 298 | 299 | public EEAnimationBuilder andAnimate(View... views) { 300 | return eeViewAnimator.addAnimationBuilder(views); 301 | } 302 | 303 | public EEViewAnimator start() { 304 | return eeViewAnimator.start(); 305 | } 306 | 307 | public EEViewAnimator duration(long duration) { 308 | return eeViewAnimator.duration(duration); 309 | } 310 | 311 | public EEViewAnimator onStart(EEAnimationListener.Start startListener) { 312 | return eeViewAnimator.onStart(startListener); 313 | } 314 | 315 | public EEViewAnimator onStop(EEAnimationListener.Stop stopListener) { 316 | return eeViewAnimator.onStop(stopListener); 317 | } 318 | 319 | public EEViewAnimator interpolator(Interpolator interpolator) { 320 | return eeViewAnimator.interpolator(interpolator); 321 | } 322 | 323 | public EEViewAnimator accelerate() { 324 | return eeViewAnimator.interpolator(new AccelerateInterpolator()); 325 | } 326 | 327 | public EEViewAnimator descelerate() { 328 | return eeViewAnimator.interpolator(new DecelerateInterpolator()); 329 | } 330 | 331 | public EEViewAnimator accelerateDecelerate() { 332 | return eeViewAnimator.interpolator(new AccelerateDecelerateInterpolator()); 333 | } 334 | 335 | public EEViewAnimator anticipate() { 336 | return eeViewAnimator.interpolator(new AnticipateInterpolator()); 337 | } 338 | 339 | public EEViewAnimator overShoot() { 340 | return eeViewAnimator.interpolator(new OvershootInterpolator()); 341 | } 342 | 343 | public EEViewAnimator anticipateOvershoot() { 344 | return eeViewAnimator.interpolator(new AnticipateOvershootInterpolator()); 345 | } 346 | 347 | public EEViewAnimator bounce() { 348 | return eeViewAnimator.interpolator(new BounceInterpolator()); 349 | } 350 | 351 | public View[] getViews() { 352 | return views; 353 | } 354 | 355 | public View getView() { 356 | return views[0]; 357 | } 358 | 359 | protected boolean isWaitForView() { 360 | return waitForView; 361 | } 362 | 363 | private int[] getColorsByResIds(int... resIds) { 364 | Context context = views[0].getContext(); 365 | int[] colors = new int[resIds.length]; 366 | 367 | for (int i = 0; i < resIds.length; i++) { 368 | colors[i] = context.getResources().getColor(resIds[i]); 369 | } 370 | 371 | return colors; 372 | } 373 | 374 | private float[] getSizesByResIds(int... resIds) { 375 | Context context = views[0].getContext(); 376 | float[] sizes = new float[resIds.length]; 377 | 378 | for (int i = 0; i < resIds.length; i++) { 379 | sizes[i] = context.getResources().getDimension(resIds[i]); 380 | } 381 | 382 | return sizes; 383 | } 384 | } 385 | --------------------------------------------------------------------------------