diff --git a/.travis.yml b/.travis.yml index a39602f..797c2f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,66 +1,12 @@ -language: java - -branches: - only: - - dev - - master - -jdk: oraclejdk7 - -env: - global: - - ANDROID_SDK_VERSION="r22.6.2" - -notifications: - email: false - - -before_install: - - # 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 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 - - # manually set sdk.dir variable, according to local paths - - echo "sdk.dir=$ANDROID_HOME" > local.properties - - # Install required components. - # For a full list, run `android list sdk -a --extended` - - echo yes | android update sdk --filter platform-tools --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 extra-android-support --no-ui --force > /dev/null - - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null - - # 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 \ No newline at end of file +language: android +android: + components: + - tools + - platform-tools + - build-tools-25.0.2 + - android-25 + - extra-android-support + - extra + - extra-android-m2repository +script: + - ./gradlew assembleDebug \ No newline at end of file diff --git a/README.md b/README.md index e164936..ebd5174 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Android View Animations [![Build Status](https://travis-ci.org/daimajia/AndroidViewAnimations.svg)](https://travis-ci.org/daimajia/AndroidAnimations) +# Android View Animations [![Build Status](https://travis-ci.org/daimajia/AndroidViewAnimations.svg)](https://travis-ci.org/daimajia/AndroidViewAnimations) One day, I saw [an iOS library](https://github.com/ArtFeel/AFViewShaker), which is a view shaker, it's very beautiful. I think Android also need one, and should be better. @@ -6,32 +6,30 @@ So, I started to collect animation effects... and in two days, this project born # Demo -![](http://ww3.sinaimg.cn/mw690/610dc034jw1ehnv2r93jpg20bx0kokjl.gif) +![](http://ww3.sinaimg.cn/mw690/610dc034gw1ej75mi2w77g20c30jb4qr.gif) -[Download Demo](https://github.com/daimajia/AndroidViewAnimations/releases/download/v1.0.0/Demo-v1.0.0.apk) +[Download Demo](https://github.com/daimajia/AndroidViewAnimations/releases/download/v1.1.2/AndroidViewAnimations-1.1.2.apk) # Usage +> Since Version 2.0, NineOldAndroids has been removed. Thanks Jake Wharton. + +For making animations more real, I created another project named [Android Easing Functions](https://github.com/daimajia/AnimationEasingFunctions) which is an implementations of [easing functions](http://easings.net/) on Android. So, we need to dependent that project. + ## Step 1 +#### Gradle ```groovy dependencies { - compile 'com.nineoldandroids:library:2.4.0' - compile 'com.daimajia.androidanimations:library:1.0.4@aar' + implementation 'com.daimajia.androidanimations:library:2.4@aar' } ``` -or Maven +#### Maven ```xml - - com.nineoldandroids - library - 2.4.0 - com.daimajia.androidanimation library - 1.0.4 - apklib + 2.4 ``` @@ -42,6 +40,7 @@ Just like play Yo-yo. ```java YoYo.with(Techniques.Tada) .duration(700) + .repeat(5) .playOn(findViewById(R.id.edit_area)); ``` @@ -50,7 +49,7 @@ YoYo.with(Techniques.Tada) `Flash`, `Pulse`, `RubberBand`, `Shake`, `Swing`, `Wobble`, `Bounce`, `Tada`, `StandUp`, `Wave` #### Special -`Hinge`, `RollIn`, `RollOut` +`Hinge`, `RollIn`, `RollOut`,`Landing`,`TakingOff`,`DropOut` #### Bounce `BounceIn`, `BounceInDown`, `BounceInLeft`, `BounceInRight`, `BounceInUp` @@ -80,14 +79,24 @@ YoYo.with(Techniques.Tada) Welcome contribute your amazing animation effect. :-D -#Thanks +# Thanks - [AFViewShaker](https://github.com/ArtFeel/AFViewShaker) - [Animate.css](https://github.com/daneden/animate.css) -#About me +# Why YoYo? -A student in mainland China. +YoYo is a [toy](https://en.wikipedia.org/wiki/Yo-yo), with a lot of [Techniques](./library/src/main/java/com/daimajia/androidanimations/library/Techniques.java). + +# About me + +(2013) +A student in mainland China. Welcome to [offer me an internship](mailto:daimajia@gmail.com). If you have any new idea about this project, feel free to [contact me](mailto:daimajia@gmail.com). + +(2019) +Five years later, now I become an investment associate in China. + +Welcome to send your business plan to [me](mailto:daimajia@gmail.com). Maybe I would have a better understanding on your startup project than others. Trust me. diff --git a/build.gradle b/build.gradle index 881b632..6441fdb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,17 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { repositories { - mavenCentral() + jcenter() + google() } + dependencies { - classpath 'com.android.tools.build:gradle:0.11.+' - classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.10.+' - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:4.0.1' } } allprojects { repositories { - mavenCentral() + jcenter() + google() } } diff --git a/demo/build.gradle b/demo/build.gradle index 56bd973..6497514 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,27 +1,28 @@ -apply plugin: 'android-sdk-manager' -apply plugin: 'android' +apply plugin: 'com.android.application' android { - compileSdkVersion 19 - buildToolsVersion "19.1.0" + compileSdkVersion COMPILE_SDK_VERSION.toInteger() defaultConfig { - applicationId "com.daimajia.androidanimations" - minSdkVersion 8 - targetSdkVersion 19 - versionCode 1 - versionName "1.0" + applicationId GROUP + minSdkVersion MIN_SDK_VERSION.toInteger() + targetSdkVersion TARGET_SDK_VERSION.toInteger() + versionCode VERSION_CODE.toInteger() + versionName VERSION_NAME } + buildTypes { release { - runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + lintOptions{ + abortOnError false + } } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.nineoldandroids:library:2.4.0' - compile project(':library') + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation project(':library') } diff --git a/demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java b/demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java index 35d5001..a204830 100644 --- a/demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java +++ b/demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java @@ -40,7 +40,7 @@ public View getView(final int position, View convertView, ViewGroup parent) { int start = o.getClass().getName().lastIndexOf(".") + 1; String name = o.getClass().getName().substring(start); t.setText(name); - v.setTag(o); + v.setTag(Techniques.values()[position]); return v; } } diff --git a/demo/src/main/java/com/daimajia/androidanimations/MyActivity.java b/demo/src/main/java/com/daimajia/androidanimations/MyActivity.java index 963288a..e045984 100644 --- a/demo/src/main/java/com/daimajia/androidanimations/MyActivity.java +++ b/demo/src/main/java/com/daimajia/androidanimations/MyActivity.java @@ -1,39 +1,88 @@ package com.daimajia.androidanimations; +import android.animation.Animator; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.animation.AccelerateInterpolator; +import android.view.animation.AccelerateDecelerateInterpolator; import android.widget.AdapterView; import android.widget.ListView; +import android.widget.Toast; -import com.daimajia.androidanimations.library.BaseViewAnimator; +import com.daimajia.androidanimations.library.Techniques; +import com.daimajia.androidanimations.library.YoYo; public class MyActivity extends Activity { private ListView mListView; private EffectAdapter mAdapter; private View mTarget; + private YoYo.YoYoString rope; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); - mListView = (ListView)findViewById(R.id.list_items); + + mListView = (ListView) findViewById(R.id.list_items); mTarget = findViewById(R.id.hello_world); + mAdapter = new EffectAdapter(this); mListView.setAdapter(mAdapter); + mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - ((BaseViewAnimator) (view.getTag())).setDuration(800) - .setInterpolator(new AccelerateInterpolator()) - .animate(mTarget); + if (rope != null) { + rope.stop(true); + } + Techniques technique = (Techniques) view.getTag(); + rope = YoYo.with(technique) + .duration(1200) + .repeat(YoYo.INFINITE) + .pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT) + .interpolate(new AccelerateDecelerateInterpolator()) + .withListener(new Animator.AnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + + } + + @Override + public void onAnimationEnd(Animator animation) { + } + + @Override + public void onAnimationCancel(Animator animation) { + Toast.makeText(MyActivity.this, "canceled previous animation", Toast.LENGTH_SHORT).show(); + } + + @Override + public void onAnimationRepeat(Animator animation) { + + } + }) + .playOn(mTarget); } }); + findViewById(R.id.hello_world).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (rope != null) { + rope.stop(true); + } + } + }); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + if (hasFocus) { + rope = YoYo.with(Techniques.FadeIn).duration(1000).playOn(mTarget);// after start,just click mTarget view, rope is not init + } } @@ -51,7 +100,7 @@ public boolean onOptionsItemSelected(MenuItem item) { // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { - startActivity(new Intent(this,ExampleActivity.class)); + startActivity(new Intent(this, ExampleActivity.class)); return true; } return super.onOptionsItemSelected(item); diff --git a/demo/src/main/res/layout/activity_my.xml b/demo/src/main/res/layout/activity_my.xml index 2e755fe..5403f25 100644 --- a/demo/src/main/res/layout/activity_my.xml +++ b/demo/src/main/res/layout/activity_my.xml @@ -1,3 +1,4 @@ + + + - + \ No newline at end of file diff --git a/demo/src/main/res/layout/example.xml b/demo/src/main/res/layout/example.xml index 85e51d3..b9f4877 100644 --- a/demo/src/main/res/layout/example.xml +++ b/demo/src/main/res/layout/example.xml @@ -1,67 +1,79 @@ - - - - + + - + android:layout_height="wrap_content"> - - -