CannyViewAnimator


Source link: https://github.com/LiveTyping/CannyViewAnimator

CannyViewAnimator

CannyViewAnimator is an enhanced version of ViewAnimator. It allows to use Animators and Transitions to extend Visibility. The logic is taken from ViewAnimator of the Android SDK. The ViewAnimator can show only one view. If you show an other view then previous one will be hidden. All changes are taking with animations.

Installation

Add compile 'com.livetyping:cannyviewanimator:0.8' in your dependencies.

Internal organization

CannyViewAnimator is divided into three layers of abstraction:

  • ViewAnimator - switches the visibility of child;
  • TransitionViewAnimator (extends ViewAnimator) - performs Transitions that extend Visibility;
  • CannyViewAnimator (extends TransitionViewAnimator) - performs Animators;
  • CannyTransition - interface for setting Transition for individual children;
  • InAnimator - interface for setting animator for appearing;
  • OutAnimator - interface for setting animator for disappearing.

ViewAnimator

Includes the following public methods:

  • setDisplayedChildIndex (int inChildIndex) - shows a child by its index in the parent;
  • setDisplayedChildId (@IdRes int id) - shows a child by its resID;
  • setDisplayedChild (View view) - shows a child by its object;
  • getDisplayedChildIndex () - obtains the index of the currently displayed child;
  • getDisplayedChild () - obtains the object of the currently displayed child;
  • getDisplayedChildId () – gets the resID of the currently displayed child;
  • bringChildToPosition (View child, int position) – changes the index of a child within the parent.

TransitionViewAnimator

(Use Transitions from AppCompat) Includes the following public methods:

  • startTransition() - launches Transition (starts by default after visibility changes)
  • setCannyTransition (CannyTransition cannyTransition) – interface setter for setting Transition for individual children

animator.setCannyTransition(new CannyTransition() {

 @Override

 public Transition getTransition(View inChild, View outChild) {

  TransitionSet transitionSet = new TransitionSet();

  transitionSet.addTransition(new Fade(Fade.IN).addTarget(inChild));

  transitionSet.addTransition(new Fade(Fade.OUT).addTarget(outChild));

  return transitionSet;

 
}

}
);

CannyViewAnimator

Includes the following public methods:

  • setInAnimator (T ... inAnimators) – interface setter for fading in animation (using the parameters)
  • setInAnimator (List<? extends inAnimators) – interface setter for fading in animation (using the list)
  • setOutAnimator (T ... outAnimators) – interface setter for fading out animation (using the parameters)
  • setOutAnimator (List<? extends OutAnimator>outAnimators) – interface setter for fading out animation (using the list)
 animator.setInAnimator(new InAnimator() {

 @Override

 public Animator getInAnimator(View inChild, View outChild) {

  return ObjectAnimator.ofFloat(inChild, View.ALPHA, 0, 1);

 
}

}
);

animator.setOutAnimator(new OutAnimator() {

 @Override

 public Animator getOutAnimator(View inChild, View outChild) {

  return ObjectAnimator.ofFloat(outChild, View.ALPHA, 1,0);

 
}

}
)

Flags

AnimateType - indicates the order in which the animation will run.

  • Sequentially
  • Together

animator.setAnimateType(CannyViewAnimator.TOGETHER);

LocationType - indicates the order in which the children will be placed in the parent. This flag makes sure that children don’t overlap with each other during animation.

  • For position
  • In always top
  • Out always top

animator.setLocationType(CannyViewAnimator.IN_ALWAYS_TOP);

DefaultCannyAnimators

This class group was originally created for testing, but in the end I decided to leave them because they help to make simple animations effortlessly. It is divided into two types:

  • PropertyAnimators - animators of View properties. [List] (library/src/main/java/com/livetyping/library/animators/property/PropertyAnimators.java)
  • RevealAnimators - CircularReveal animators. [List] (library/src/main/java/com/livetyping/library/animators/reveal/RevealAnimators.java)

Example:

 animator.setInAnimator(PropertyAnimators.ROTATION_180);
  animator.setInAnimator(PropertyAnimators.ROTATION_M180);

Helper classes

This group of classes is needed for easier creation of InAnimators and OutAnimators.

  • PropertyIn
  • PropertyOut
  • RevealIn
  • RevealOut

Example of parallax effect:

animator.setInAnimator(new PropertyIn(View.TRANSLATION_X, width, 0).setDuration(1000));
 animator.setOutAnimator(new PropertyOut(View.TRANSLATION_X, 0, -width / 2).setDuration(1000));
 animator.setLocationType(CannyViewAnimator.IN_ALWAYS_TOP);
 animator.setAnimateType(CannyViewAnimator.TOGETHER);

XML

Attribute list:

  • animate_type inmplementation setAnimateType
  • location_type inmplementation setLocationType
  • in set default in animator
  • out set default out animator
  • prelolipop_in set default in animator (without reveal animators)
  • prelolipop_out set default out animator (without reveal animators)

If the current Android version is lower than Lollipop, then animators will be taken from prelolipop_in, if prelolipop_in is empty, then animators will taken from in.

Example:

<com.livetyping.library.CannyViewAnimator

android:id="@+id/xml_animator"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

app:animate_type="together"

app:location_type="out_always_top"

app:out="circular_center"

app:pre_lollipop_out="scale_x|scale_y|alpha">

License

Copyright 2015 Danil Perevalov.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Resources

A different beautiful ViewPager, with quick swipe controls.

ColorPickerView is an android custom view, you can pick one colour from a gridview. You can define the columns, colours, border colour, etc.

A mini elegant WebView for fast easy access.

Feature list:

  • no more memory leak
  • easy web page margin fixed
  • easy web video implementation
  • easy web content display implementation
  • took care of life cycle issues
  • fantasy animation reveal fade in

Root Checker basically checks your device whether it is rooted or not.

Dewey is an android widget designed to hold an unlimited number of tabs, making it ideal for allowing pagination through a list.

Thin DownloadManager is an android library primary to download files and to avoid using DOWNLOAD_WITHOUT_NOTIFICATION permission when using Android provided DownloadManager in your 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