Android-InfiniteCards


Source link: https://github.com/BakerJQ/Android-InfiniteCards

InfiniteCards

An infinite card switching UI for Android, support custom animation
?????????????? ?????

Screenshot

Gradle via JCenter

compile 'com.bakerj:infinite-cards:1.0.3'

Attrs

  • animType : animation type
    • front : move the selected card to first
    • switchPosition : move the selected card to first, and the first card to the selected position
    • frontToLast : move the first card to last position
  • cardRatio : ratio of the card
  • animDuration : duration of each card's animation
  • animAddRemoveDelay : delay of animation of add and remove between each card
  • animAddRemoveDuration : duration of add and remove each card's animation

How to use

layout in xml

<com.bakerj.infinitecards.InfiniteCardView

android:id="@+id/view"

android:layout_width="match_parent"

android:layout_height="match_parent"

infiniteCard:animDuration="1000"

infiniteCard:cardRatio="1"/> 

Set Adapter

Just extends the BaseAdapter

class MyAdapter extends BaseAdapter{

... 
}
 mAdapter = new MyAdapter(resId);
 mCardView.setAdapter(mAdapter);

Animation transformers and interpolators

Default

If you just use all default animations, just do nothing.

mCardView.setAnimInterpolator(new LinearInterpolator());
 mCardView.setTransformerToFront(new DefaultTransformerToFront());
 mCardView.setTransformerToBack(new DefaultTransformerToBack());
 mCardView.setZIndexTransformerToBack(new DefaultZIndexTransformerCommon());

Customisation

mCardView.setTransformerToBack(new AnimationTransformer() {

  @Override
  public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {

int positionCount = fromPosition - toPosition;

float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);

ViewHelper.setScaleX(view, scale);

ViewHelper.setScaleY(view, scale);

if (fraction < 0.5) {

 ViewCompat.setRotationX(view, 180 * fraction);

}
 else {

 ViewCompat.setRotationX(view, 180 * (1 - fraction));

}

  
}

@Override
  public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {

int positionCount = fromPosition - toPosition;

float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);

ViewHelper.setTranslationY(view, -cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.02f *

  fromPosition - 0.02f * fraction * positionCount));

  
}
 
}
);
 mCardView.setZIndexTransformerToBack(new ZIndexTransformer() {

  @Override
  public void transformAnimation(CardItem card, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {

if (fraction < 0.4f) {

 card.zIndex = 1f + 0.01f * fromPosition;

}
 else {

 card.zIndex = 1f + 0.01f * toPosition;

}

  
}

@Override
  public void transformInterpolatedAnimation(CardItem card, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {

}
 
}
);

License

InfiniteCards is released under the Apache 2.0 license.

Copyright 2017 BakerJ.  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 following link.

 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

Dredd was created to be a simple way to detach application business logic in order to create a decision tree model best for visualize and perhaps easy to understand and maintain.

Fluxxan Fluxxan is an Android implementation of the Flux Architecture that combines concepts from both Fluxxor and Redux.

Meter is a simple micro-benchmarking tool for Android (and Java) projects. This is not a profiler, this is very small utility class that designed for making benchmarking easy.

This is an ambitious example project of what can be done with RxJava to create an app based on streams of data.

Material CAB allows you to implement a customizable and flexible contextual action bar in your app. The traditional stock CAB on Android is limited to being placed at the top of your Activity, and the navigation drawer cannot go over it. This library lets you choose its exact location, and a toolbar is used allowing views to be be placed over and under it.

An Android library for pattern lock.

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