Skip to content

Commit

Permalink
Merge pull request #10 from daimajia/ease
Browse files Browse the repository at this point in the history
Robert Penner's Easing Functions
  • Loading branch information
daimajia committed Jun 27, 2014
2 parents 6d4df20 + 2c9a65a commit 29ea62b
Show file tree
Hide file tree
Showing 34 changed files with 1,391 additions and 29 deletions.
69 changes: 51 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,66 @@
language: java

branches:
only:
- dev
- master

jdk: oraclejdk7

env:
matrix:
- ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
global:
- ANDROID_SDK_VERSION="r22.6.2"

notifications:
email: false


before_install:
# Install base Android SDK

# environment info
- gradle -v
- uname -a

# required libs for android build tools
# Update a system for ia32 libraries
- sudo apt-get update -qq
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null; fi
- wget http://dl.google.com/android/android-sdk_r22.3-linux.tgz
- tar xzf android-sdk_r22.3-linux.tgz
- export ANDROID_HOME=$PWD/android-sdk-linux
- if [ `uname -m` = x86_64 ]; then sudo apt-get update; fi
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch; fi

# for gradle output style
- export TERM=dumb

# newer version of gradle
# - wget http://services.gradle.org/distributions/gradle-1.12-bin.zip
# - unzip -qq gradle-1.12-bin.zip
# - export GRADLE_HOME=$PWD/gradle-1.11
# - export PATH=$GRADLE_HOME/bin:$PATH

# just to test gradle version, against our provided one
- gradle -v

# newest android SDK
- wget http://dl.google.com/android/android-sdk_${ANDROID_SDK_VERSION}-linux.tgz
- tar -zxf android-sdk_${ANDROID_SDK_VERSION}-linux.tgz
- export ANDROID_HOME=`pwd`/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools

# Gradle
- wget http://services.gradle.org/distributions/gradle-1.9-bin.zip
- unzip gradle-1.9-bin.zip
- export GRADLE_HOME=$PWD/gradle-1.9
- export PATH=$GRADLE_HOME/bin:$PATH
# manually set sdk.dir variable, according to local paths
- echo "sdk.dir=$ANDROID_HOME" > local.properties

# Install required components
# Install required components.
# For a full list, run `android list sdk -a --extended`
# Note that sysimg-19 downloads only ARM, because only the first license query is accepted.
- echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null
- echo yes | android update sdk --all --filter build-tools-19.0.3 --no-ui --force > /dev/null
- echo yes | android update sdk --all --filter build-tools-19.1.0 --no-ui --force > /dev/null
- echo yes | android update sdk --filter android-19 --no-ui --force > /dev/null
- echo yes | android update sdk --filter sysimg-19 --no-ui --force > /dev/null
- echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null
- echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null

install:
- ./gradlew assemble
# Otherwise
#- echo yes | android update sdk -t tools,platform-tools,extra-android-support,extra-android-m2repository,android-19 --force --no-ui


# Let's try to build...
install: ./gradlew clean build

script: gradle check
2 changes: 1 addition & 1 deletion demo/src/main/res/menu/my.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<item android:id="@+id/action_settings"
android:title="@string/action_example"
android:orderInCategory="100"
app:showAsAction="never" />
android:showAsAction="always" />
</menu>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# org.gradle.parallel=true


VERSION_NAME=1.0.4
VERSION_CODE=5
VERSION_NAME=1.0.5
VERSION_CODE=6
GROUP=com.daimajia.androidanimations

POM_DESCRIPTION=Collect android animations
Expand Down
5 changes: 2 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.daimajia.androidanimations.library"
minSdkVersion 8
targetSdkVersion 19
versionCode 5
versionName "1.0.4"
versionCode 6
versionName "1.0.5"
}
buildTypes {
release {
Expand All @@ -21,7 +21,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.nineoldandroids:library:2.4.0'
}
apply from: './gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 daimajia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.daimajia.androidanimations.library.easing_functions;

import android.view.animation.Interpolator;

import com.nineoldandroids.animation.FloatEvaluator;

public abstract class BaseEasingMethod extends FloatEvaluator implements Interpolator{
protected float mDuration;


public BaseEasingMethod(float duration){
mDuration = duration;
}

public abstract float getInterpolation(float input);

public void setDuration(float duration){
mDuration = duration;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 daimajia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.daimajia.androidanimations.library.easing_functions;

import com.nineoldandroids.animation.ObjectAnimator;
import com.nineoldandroids.animation.PropertyValuesHolder;

public class Glider {

public static PropertyValuesHolder glide(Skill skill, float duration, PropertyValuesHolder propertyValuesHolder){
propertyValuesHolder.setEvaluator(skill.getMethod(duration));
return propertyValuesHolder;
}

public static ObjectAnimator glide(Skill skill, float duration, ObjectAnimator animator){
BaseEasingMethod t = skill.getMethod(duration);
animator.setInterpolator(t);
animator.setEvaluator(t);
return animator;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 daimajia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.daimajia.androidanimations.library.easing_functions;

import com.daimajia.androidanimations.library.easing_functions.back.BackEaseIn;
import com.daimajia.androidanimations.library.easing_functions.back.BackEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.back.BackEaseOut;
import com.daimajia.androidanimations.library.easing_functions.bounce.BounceEaseIn;
import com.daimajia.androidanimations.library.easing_functions.bounce.BounceEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.bounce.BounceEaseOut;
import com.daimajia.androidanimations.library.easing_functions.circ.CircEaseIn;
import com.daimajia.androidanimations.library.easing_functions.circ.CircEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.circ.CircEaseOut;
import com.daimajia.androidanimations.library.easing_functions.cubic.CubicEaseIn;
import com.daimajia.androidanimations.library.easing_functions.cubic.CubicEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.cubic.CubicEaseOut;
import com.daimajia.androidanimations.library.easing_functions.elastic.ElasticEaseIn;
import com.daimajia.androidanimations.library.easing_functions.elastic.ElasticEaseOut;
import com.daimajia.androidanimations.library.easing_functions.expo.ExpoEaseIn;
import com.daimajia.androidanimations.library.easing_functions.expo.ExpoEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.expo.ExpoEaseOut;
import com.daimajia.androidanimations.library.easing_functions.quad.QuadEaseIn;
import com.daimajia.androidanimations.library.easing_functions.quad.QuadEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.quad.QuadEaseOut;
import com.daimajia.androidanimations.library.easing_functions.quint.QuintEaseIn;
import com.daimajia.androidanimations.library.easing_functions.quint.QuintEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.quint.QuintEaseOut;
import com.daimajia.androidanimations.library.easing_functions.sine.SineEaseIn;
import com.daimajia.androidanimations.library.easing_functions.sine.SineEaseInOut;
import com.daimajia.androidanimations.library.easing_functions.sine.SineEaseOut;

public enum Skill {

BackEaseIn(BackEaseIn.class),
BackEaseOut(BackEaseOut.class),
BackEaseInOut(BackEaseInOut.class),

BounceEaseIn(BounceEaseIn.class),
BounceEaseOut(BounceEaseOut.class),
BounceEaseInOut(BounceEaseInOut.class),

CircEaseIn(CircEaseIn.class),
CircEaseOut(CircEaseOut.class),
CircEaseInOut(CircEaseInOut.class),

CubicEaseIn(CubicEaseIn.class),
CubicEaseOut(CubicEaseOut.class),
CubicEaseInOut(CubicEaseInOut.class),

ElasticEaseIn(ElasticEaseIn.class),
ElasticEaseOut(ElasticEaseOut.class),

ExpoEaseIn(ExpoEaseIn.class),
ExpoEaseOut(ExpoEaseOut.class),
ExpoEaseInOut(ExpoEaseInOut.class),

QuadEaseIn(QuadEaseIn.class),
QuadEaseOut(QuadEaseOut.class),
QuadEaseInOut(QuadEaseInOut.class),

QuintEaseIn(QuintEaseIn.class),
QuintEaseOut(QuintEaseOut.class),
QuintEaseInOut(QuintEaseInOut.class),

SineEaseIn(SineEaseIn.class),
SineEaseOut(SineEaseOut.class),
SineEaseInOut(SineEaseInOut.class);


private Class easingMethod;

private Skill(Class clazz) {
easingMethod = clazz;
}

public BaseEasingMethod getMethod(float duration) {
try {
return (BaseEasingMethod)easingMethod.getConstructor(float.class).newInstance(duration);
} catch (Exception e) {
e.printStackTrace();
throw new Error("Can not init easingMethod instance");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 daimajia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.daimajia.androidanimations.library.easing_functions.back;

import com.daimajia.androidanimations.library.easing_functions.BaseEasingMethod;

public class BackEaseIn extends BaseEasingMethod{

private float s = 1.70158f;

public BackEaseIn(float duration) {
super(duration);
}

public BackEaseIn(float duration, float back){
this(duration);
s = back;
}

@Override
public float getInterpolation(float input) {
return input*input*((s+1)*input - s);
}
}
Loading

0 comments on commit 29ea62b

Please sign in to comment.