wava


Source link: https://github.com/hujiaweibujidao/wava

????

wava

Wow, Android View Animation! (capital letter of each word forms WAVA)

I wanna build another fancy Android animation library, but I was still thinking how to do that. 🐈

daimajia has built an amazing library named AndroidViewAnimations, it's really really awesome.

Currently wava is just a library based on AndroidViewAnimations with many updates. Since it has changed a lot from the latest release of AndroidViewAnimations (although I tried to keep the API as same as before), I think better make another one than pulling requests.

Later I will try my best to add other fancy new features to wava, star it if you have any interest. 😜

Sample

Usage

It's almost the same.

YoYo.with(technique).duration(1200)
  .interpolate(new AccelerateDecelerateInterpolator())
  .listen(new AnimatorListenerAdapter() {

@Override

public void onAnimationCancel(Animator animation) {

  Toast.makeText(MainActivity.this, "canceled", Toast.LENGTH_SHORT).show();

}

  
}
)
  .playOn(mTarget);

Setup

1.add this in your build.gradle file in root project

allprojects {

  repositories {

...

maven {
 url "https://www.jitpack.io" 
}

  
}
 
}
 

2.add the following dependency

dependencies {

  compile 'com.github.hujiaweibujidao:wava:1.0.0' 
}
 

Changes

The following are main changes from AndroidViewAnimations:

1.removed deprecated NineOldAndroids.

New applications should use  minSdkVersion="14" or higher which has access to the platform animation APIs.

For example, animation reset no longer needs ViewHelper

public void reset() {

  mTarget.setAlpha(1);

  mTarget.setScaleX(1);

  mTarget.setScaleY(1);

  mTarget.setTranslationX(0);

  mTarget.setTranslationY(0);

  mTarget.setRotation(0);

  mTarget.setRotationX(0);

  mTarget.setRotationY(0);

  mTarget.setPivotX(mTarget.getMeasuredWidth() / 2.0f);

  mTarget.setPivotY(mTarget.getMeasuredHeight() / 2.0f);
 
}

2.simplified the core YoYo class (including Builder and YoYoString) while keeping the original API.

public static class Builder {

private static final int DEFAULT_REPEAT = 1;//?????????
  private static final long DEFAULT_DELAY = 0;//??????????
  private static final boolean DEFAULT_RESET = false;//???????????
  private static final long DEFAULT_DURATION = 1000;//?????????1?

private View target;//???view
  private long delay = DEFAULT_DELAY;//??????
  private long duration = DEFAULT_DURATION;//??????
  private int repeat = DEFAULT_REPEAT;//??????
  private boolean reset = DEFAULT_RESET;//?????????????????true????
  private BaseViewAnimator animator;//animator?
  private Interpolator interpolator;//interpolator ?????
  private List<Animator.AnimatorListener> listeners = new ArrayList<Animator.AnimatorListener>();
//??????

//??????????animator????????
  private Builder(Techniques technique) {

this.animator = technique.getAnimator();

  
}

private Builder(BaseViewAnimator animator) {

this.animator = animator;
  
}

public Builder duration(long duration) {

this.duration = duration;

return this;
  
}

public Builder delay(long delay) {

this.delay = delay;

return this;
  
}

public Builder interpolate(Interpolator interpolator) {

this.interpolator = interpolator;

return this;
  
}

public Builder listen(AnimatorListenerAdapter listener) {

this.listeners.add(listener);

return this;
  
}

public Builder reset(boolean reset) {

this.reset = reset;

return this;
  
}

public Builder repeat(int count) {

this.repeat = count;

return this;
  
}

//??play???????????????????????YoYoString
  public YoYoString playOn(View target) {

this.target = target;

start();

return new YoYoString(this.animator);

  
}

//builder???start????animatorset??
  private void start() {

animator.setTarget(target).setDuration(duration).setInterpolator(interpolator)

  .setStartDelay(delay).setRest(reset).setRepeat(repeat);

 if (listeners.size() > 0) {

 animator.addAllListeners(listeners);

}

 animator.start();

  
}
 
}

3.added supports to animation replay and animation reset after animation ends.

public void start() {

  reset();

  prepare();

  if (mRepeat != 0) {

for (Animator animator : mAnimatorSet.getChildAnimations()) {

 ((ValueAnimator) animator).setRepeatCount(mRepeat > 0 ? mRepeat - 1 : mRepeat);
//?????

 //((ValueAnimator) animator).setRepeatMode(ValueAnimator.REVERSE);


}

  
}

  if (mRest) {

mAnimatorSet.addListener(new AnimatorListenerAdapter() {

 @Override

 public void onAnimationEnd(Animator animation) {

  reset();

 
}

}
);

  
}

  mAnimatorSet.start();
 
}

4.replaced the original dependency AndroidEasingFunctions with my another library yava.

public class LandingAnimator extends BaseViewAnimator {

  @Override
  protected void prepare() {

 //before //

  mAnimatorSet.playTogether( //

 Glider.glide(Skill.QuintEaseOut, mAnimatorSet.getDuration(), ObjectAnimator.ofFloat(mTarget, "scaleX", 1.5f, 1f)), //

 Glider.glide(Skill.QuintEaseOut, mAnimatorSet.getDuration(), ObjectAnimator.ofFloat(mTarget, "scaleY", 1.5f, 1f)), //

 Glider.glide(Skill.QuintEaseOut, mAnimatorSet.getDuration(), ObjectAnimator.ofFloat(mTarget, "alpha", 0, 1f)) //

  );


 //after

ObjectAnimator animator1 = ObjectAnimator.ofFloat(mTarget, "scaleX", 1.5f, 1f);

animator1.setInterpolator(EasingFunction.QUINT_OUT);

ObjectAnimator animator2 = ObjectAnimator.ofFloat(mTarget, "scaleY", 1.5f, 1f);

animator2.setInterpolator(EasingFunction.QUINT_OUT);

ObjectAnimator animator3 = ObjectAnimator.ofFloat(mTarget, "alpha", 0, 1f);

animator3.setInterpolator(EasingFunction.QUINT_OUT);

mAnimatorSet.playTogether(animator1, animator2, animator3);

  
}
 
}

5.simplified all the ViewAnimator with easy access way to mAnimatorSet and mTarget.

public class BounceAnimator extends BaseViewAnimator {

  @Override
  public void prepare() {

mAnimatorSet.playTogether(

  ObjectAnimator.ofFloat(mTarget, "translationY", 0, 0, -30, 0, -15, 0, 0)

);

  
}
 
}

6.modified the effect visualization code while keeping it same as before.

License

The MIT License (MIT)  Copyright (c) 2016 Hujiawei  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. 

Resources

A very small library to implement a connection indicator view. These connections may be GPS, Network or other loading indicators.

JFixture is an open source library based on the popular .NET library, AutoFixture.

JFixture is a Java library to assist in the writing of Unit Tests, particularly when following Test Driven Development. It generates types based on the concept of 'constrained non-determinism', which is an implementation of the Generated Value xUnit test pattern.

Rx wrapper for the Firebase Android library.

Failsafe is a lightweight, zero-dependency library for handling failures. It was designed to be as easy to use as possible, with a concise API for handling everyday use cases and the flexibility to handle everything else.

This project is implementation of ideas from Managing state reactive way article.

"vcard-androidParser" is an android library for developers who wish to get ez-vcard working for android devices or simply it can be used to parse vcf or vcard files in android

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes