Morphos


Source link: https://github.com/rjsvieira/morphos

Morphos

They say a pic is worth a 1000 words. Is it true to admit a .gif is worth a 1000 pics?

Include in your project

In your root/build.gradle

allprojects {

repositories {

...
maven {
 url 'https://jitpack.io' 
}

}
 
}
  

In your app/build.gradle

dependencies {

compile 'com.github.rjsvieira:morphos:1.0.0' 
}

Introducing Morphos : an animation wrapper. Morphos will take care of your views' animations without you having to write all that boring boilerplate code.

Initialization

Morphos are easy to interact with. Go ahead and create the following simple Morpho :

View viewToAnimate = ... ; Morpho morph = new Morpho(viewToAnimate)
.translate(50,50,0,1500) // will translate the view (x=50,y=50,z=0) in 1500 milliseconds, 
.rotationXY(45,45,2000);
 // will rotate the view by 45 degrees on both the X-axis and Y-axis in 2000 milliseconds

You can then animate it by doing

morph.animate();
 

Which will then animate the desired Morphos using the default animation type (SEQUENTIAL).

What if I want to reverse the animation? Sure, just do :

morph.reverse();

Configuration

Create a Morpho

Morpho morphoOne = new Morphos(view);

Configure the Morphos' animations

As of the first release, Morphos supports the 7 most basic and common animations. Since Morphos has plenty of combinations for interpolation, animation type, duration, etc, the user is allowed to configure them according to his needs. Every animation configuration method returns the Morphos object itself, thus allowing the user to chain his preferred animations.

Note : If the user does not specify the duration and/or interpolator, the animation will assume a 0 second duration and the default interpolator.

alpha(double value) alpha(double value, int duration) alpha(double value, int duration, Interpolator interpolator)  scale(double valueX, double valueY) scale(double valueX, double valueY, int duration) scale(double valueX, double valueY, int duration, Interpolator interpolator)  translationX(AnimationTarget target, float valueX) translationX(AnimationTarget target, float valueX, int duration) translationX(AnimationTarget target, float valueX, int duration, Interpolator interpolator)  translationY(AnimationTarget target, float valueX) translationY(AnimationTarget target, float valueX, int duration) translationY(AnimationTarget target, float valueX, int duration, Interpolator interpolator)  translationZ(AnimationTarget target, float valueX) translationZ(AnimationTarget target, float valueX, int duration) translationZ(AnimationTarget target, float valueX, int duration, Interpolator interpolator)  translation(AnimationTarget target, float valueX, float valueY, float valueZ) translation(AnimationTarget target, float valueX, float valueY, float valueZ, int duration) translation(AnimationTarget target, float valueX, float valueY, float valueZ, int duration, Interpolator interpolator)  dimensions(float width, float height) dimensions(float width, float height, int duration) dimensions(float width, float height, int duration, Interpolator interpolator)  rotationXY(AnimationTarget target, double degreesX, double degreesY) rotationXY(AnimationTarget target, double degreesX, double degreesY, int duration) rotationXY(AnimationTarget target, double degreesX, double degreesY, int duration, Interpolator interpolator)  rotation(AnimationTarget target, double degrees) rotation(AnimationTarget target, double degrees, int duration) rotation(AnimationTarget target, double degrees, int duration, Interpolator interpolator)

Set a Listener to track the Morphos' animation process

morphoOne.setListener(new Animator.AnimatorListener() {

@Override
public void onAnimationStart(Animator animator) {

 System.out.println("Start");

}

 @Override
public void onAnimationEnd(Animator animator) {

 System.out.println("End");

}

 @Override
public void onAnimationCancel(Animator animator) {

 
}

 @Override
public void onAnimationRepeat(Animator animator) {

 
}
 
}
)  

Animate() the Morpho

This can be done through one of the several methods created just to make the invocation easier. The animate() method's default values are :
AnimationType : SEQUENTIAL - All animations are executed one sequentially Duration : -1 - Since no duration was specified, -1 is assumed thus executing every animation in its given duration. For example : morphoOne.translate(100,0,0,3000).scale(2,2,2000).animate() will execute the translation animation in 3 seconds, followed by an upscale animation of 2 seconds Interpolator - The overall interpolator (LinearInterpolator)
animate() animate(AnimationType type, int duration) animate(AnimationType type, int duration, Interpolator interpolator)

Reverse

After executing animate(), the user can rollback the animation by invoking the reverse() method. The reverse method works just like the animate() method, having the same combinations and parameters.

reverse() reverse(AnimationType type, int duration) reverse(AnimationType type, int duration, Interpolator interpolator)

Cancel

If the user wishes to cancel the on-going animation by any reason, he can do so by invoking the cancel method :

morphoOne.cancel();

updateView

Like the method explicitly indicates, the user can update the view associated with the Morpho. This will clear every animation already configured for the given object. updateView(View v) also invokes reset();

morphoOne.updateView(newView);

Reset

If by any chance the user wants to reset he Morpho and re-build it from scratch, he can do so by invoking the reset() method

morphoOne.reset()

Dispose

Last but not least, if they user wishes to discard the Morphos object, he can invoke the dispose() method, thus clearing and preparing the Morphos' inner variables for garbage collection.

morphoOne.dispose();

Resources

Simple Custom Tabs A library made to use custom tabs without going crazy!

Android passcode view.

A TextView subclass to show a reveal effect.

This is a library designed for highlighting hashtags ("#example") and catching click on them.

A simple, easy to use library to parse rss feeds into your app.

A minimalistic, easy to use Rss reader application.

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