Repository: daimajia/AndroidViewAnimations Branch: master Commit: 6a35c466d23e Files: 99 Total size: 161.4 KB Directory structure: gitextract_z2hbnmcy/ ├── .gitignore ├── .travis.yml ├── License ├── README.md ├── build.gradle ├── demo/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── daimajia/ │ │ └── androidanimations/ │ │ ├── EffectAdapter.java │ │ ├── ExampleActivity.java │ │ └── MyActivity.java │ └── res/ │ ├── layout/ │ │ ├── activity_my.xml │ │ ├── example.xml │ │ └── item.xml │ ├── menu/ │ │ └── my.xml │ ├── values/ │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── values-w820dp/ │ └── dimens.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ ├── gradle-mvn-push.gradle │ ├── gradle.properties │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── daimajia/ │ │ └── androidanimations/ │ │ └── library/ │ │ ├── BaseViewAnimator.java │ │ ├── Techniques.java │ │ ├── YoYo.java │ │ ├── attention/ │ │ │ ├── BounceAnimator.java │ │ │ ├── FlashAnimator.java │ │ │ ├── PulseAnimator.java │ │ │ ├── RubberBandAnimator.java │ │ │ ├── ShakeAnimator.java │ │ │ ├── StandUpAnimator.java │ │ │ ├── SwingAnimator.java │ │ │ ├── TadaAnimator.java │ │ │ ├── WaveAnimator.java │ │ │ └── WobbleAnimator.java │ │ ├── bouncing_entrances/ │ │ │ ├── BounceInAnimator.java │ │ │ ├── BounceInDownAnimator.java │ │ │ ├── BounceInLeftAnimator.java │ │ │ ├── BounceInRightAnimator.java │ │ │ └── BounceInUpAnimator.java │ │ ├── fading_entrances/ │ │ │ ├── FadeInAnimator.java │ │ │ ├── FadeInDownAnimator.java │ │ │ ├── FadeInLeftAnimator.java │ │ │ ├── FadeInRightAnimator.java │ │ │ └── FadeInUpAnimator.java │ │ ├── fading_exits/ │ │ │ ├── FadeOutAnimator.java │ │ │ ├── FadeOutDownAnimator.java │ │ │ ├── FadeOutLeftAnimator.java │ │ │ ├── FadeOutRightAnimator.java │ │ │ └── FadeOutUpAnimator.java │ │ ├── flippers/ │ │ │ ├── FlipInXAnimator.java │ │ │ ├── FlipInYAnimator.java │ │ │ ├── FlipOutXAnimator.java │ │ │ └── FlipOutYAnimator.java │ │ ├── rotating_entrances/ │ │ │ ├── RotateInAnimator.java │ │ │ ├── RotateInDownLeftAnimator.java │ │ │ ├── RotateInDownRightAnimator.java │ │ │ ├── RotateInUpLeftAnimator.java │ │ │ └── RotateInUpRightAnimator.java │ │ ├── rotating_exits/ │ │ │ ├── RotateOutAnimator.java │ │ │ ├── RotateOutDownLeftAnimator.java │ │ │ ├── RotateOutDownRightAnimator.java │ │ │ ├── RotateOutUpLeftAnimator.java │ │ │ └── RotateOutUpRightAnimator.java │ │ ├── sliders/ │ │ │ ├── SlideInDownAnimator.java │ │ │ ├── SlideInLeftAnimator.java │ │ │ ├── SlideInRightAnimator.java │ │ │ ├── SlideInUpAnimator.java │ │ │ ├── SlideOutDownAnimator.java │ │ │ ├── SlideOutLeftAnimator.java │ │ │ ├── SlideOutRightAnimator.java │ │ │ └── SlideOutUpAnimator.java │ │ ├── specials/ │ │ │ ├── HingeAnimator.java │ │ │ ├── RollInAnimator.java │ │ │ ├── RollOutAnimator.java │ │ │ ├── in/ │ │ │ │ ├── DropOutAnimator.java │ │ │ │ └── LandingAnimator.java │ │ │ └── out/ │ │ │ └── TakingOffAnimator.java │ │ ├── zooming_entrances/ │ │ │ ├── ZoomInAnimator.java │ │ │ ├── ZoomInDownAnimator.java │ │ │ ├── ZoomInLeftAnimator.java │ │ │ ├── ZoomInRightAnimator.java │ │ │ └── ZoomInUpAnimator.java │ │ └── zooming_exits/ │ │ ├── ZoomOutAnimator.java │ │ ├── ZoomOutDownAnimator.java │ │ ├── ZoomOutLeftAnimator.java │ │ ├── ZoomOutRightAnimator.java │ │ └── ZoomOutUpAnimator.java │ └── res/ │ └── values/ │ └── strings.xml └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .gradle /local.properties /.idea/workspace.xml .DS_Store /build # built application files *.apk *.ap_ # files for the dex VM *.dex # Java class files *.class .DS_Store # generated files bin/ gen/ Wiki/ # Local configuration file (sdk path, etc) local.properties # Eclipse project files .classpath .project .settings/ # Proguard folder generated by Eclipse proguard/ #Android Studio build/ # Intellij project files *.iml *.ipr *.iws .idea/ #gradle .gradle/ ================================================ FILE: .travis.yml ================================================ language: android android: components: - tools - platform-tools - build-tools-25.0.2 - android-25 - extra-android-support - extra - extra-android-m2repository script: - ./gradlew assembleDebug ================================================ FILE: License ================================================ 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. ================================================ FILE: README.md ================================================ # 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. So, I started to collect animation effects... and in two days, this project born. # Demo ![](http://ww3.sinaimg.cn/mw690/610dc034gw1ej75mi2w77g20c30jb4qr.gif) [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 { implementation 'com.daimajia.androidanimations:library:2.4@aar' } ``` #### Maven ```xml com.daimajia.androidanimation library 2.4 ``` ## Step 2 Just like play Yo-yo. ```java YoYo.with(Techniques.Tada) .duration(700) .repeat(5) .playOn(findViewById(R.id.edit_area)); ``` ### Effects #### Attension `Flash`, `Pulse`, `RubberBand`, `Shake`, `Swing`, `Wobble`, `Bounce`, `Tada`, `StandUp`, `Wave` #### Special `Hinge`, `RollIn`, `RollOut`,`Landing`,`TakingOff`,`DropOut` #### Bounce `BounceIn`, `BounceInDown`, `BounceInLeft`, `BounceInRight`, `BounceInUp` #### Fade `FadeIn`, `FadeInUp`, `FadeInDown`, `FadeInLeft`, `FadeInRight` `FadeOut`, `FadeOutDown`, `FadeOutLeft`, `FadeOutRight`, `FadeOutUp` #### Flip `FlipInX`, `FlipOutX`, `FlipOutY` #### Rotate `RotateIn`, `RotateInDownLeft`, `RotateInDownRight`, `RotateInUpLeft`, `RotateInUpRight` `RotateOut`, `RotateOutDownLeft`, `RotateOutDownRight`, `RotateOutUpLeft`, `RotateOutUpRight` #### Slide `SlideInLeft`, `SlideInRight`, `SlideInUp`, `SlideInDown` `SlideOutLeft`, `SlideOutRight`, `SlideOutUp`, `SlideOutDown` #### Zoom `ZoomIn`, `ZoomInDown`, `ZoomInLeft`, `ZoomInRight`, `ZoomInUp` `ZoomOut`, `ZoomOutDown`, `ZoomOutLeft`, `ZoomOutRight`, `ZoomOutUp` Welcome contribute your amazing animation effect. :-D # Thanks - [AFViewShaker](https://github.com/ArtFeel/AFViewShaker) - [Animate.css](https://github.com/daneden/animate.css) # Why YoYo? 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. ================================================ FILE: build.gradle ================================================ buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:4.0.1' } } allprojects { repositories { jcenter() google() } } ================================================ FILE: demo/.gitignore ================================================ /build ================================================ FILE: demo/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion COMPILE_SDK_VERSION.toInteger() defaultConfig { applicationId GROUP minSdkVersion MIN_SDK_VERSION.toInteger() targetSdkVersion TARGET_SDK_VERSION.toInteger() versionCode VERSION_CODE.toInteger() versionName VERSION_NAME } buildTypes { release { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } lintOptions{ abortOnError false } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation project(':library') } ================================================ FILE: demo/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: demo/src/main/AndroidManifest.xml ================================================ ================================================ FILE: demo/src/main/java/com/daimajia/androidanimations/EffectAdapter.java ================================================ package com.daimajia.androidanimations; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.daimajia.androidanimations.library.Techniques; public class EffectAdapter extends BaseAdapter { private Context mContext; public EffectAdapter(Context context){ mContext = context; } @Override public int getCount() { return Techniques.values().length; } @Override public Object getItem(int position) { return Techniques.values()[position].getAnimator(); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { View v = LayoutInflater.from(mContext).inflate(R.layout.item,null,false); TextView t = (TextView)v.findViewById(R.id.list_item_text); Object o = getItem(position); int start = o.getClass().getName().lastIndexOf(".") + 1; String name = o.getClass().getName().substring(start); t.setText(name); v.setTag(Techniques.values()[position]); return v; } } ================================================ FILE: demo/src/main/java/com/daimajia/androidanimations/ExampleActivity.java ================================================ package com.daimajia.androidanimations; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import com.daimajia.androidanimations.library.Techniques; import com.daimajia.androidanimations.library.YoYo; public class ExampleActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.example); final TextView t = (TextView) findViewById(R.id.notice); t.setText("Please input your Email and Password"); findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YoYo.with(Techniques.Tada) .duration(700) .playOn(findViewById(R.id.edit_area)); t.setText("Wrong password!"); } }); final TextView t2 = (TextView) findViewById(R.id.notice2); t2.setText("Please input your Email and Password"); findViewById(R.id.submit2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { YoYo.with(Techniques.Shake).playOn(findViewById(R.id.edit_area2)); t2.setText("Wrong password!"); } }); } } ================================================ FILE: demo/src/main/java/com/daimajia/androidanimations/MyActivity.java ================================================ 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.AccelerateDecelerateInterpolator; import android.widget.AdapterView; import android.widget.ListView; import android.widget.Toast; 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); 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) { 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 } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.my, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // 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)); return true; } return super.onOptionsItemSelected(item); } } ================================================ FILE: demo/src/main/res/layout/activity_my.xml ================================================ ================================================ FILE: demo/src/main/res/layout/example.xml ================================================