Dewey


Source link: https://github.com/TippingCanoe/Dewey

Dewey

Introduction

Dewey is an android widget designed to hold an unlimited number of tabs, making it ideal for allowing pagination through a list, hence it being named after The Dewey Decimal System. Most other implementations of this style of widget don't recycle their child views, leading to performance issues even on modern devices for large data-sets.

A demo application included with this repository shows an example of this functionality;

Installing

  1. Add the repository;

    repositories {
      maven {
    
    url 'https://jitpack.io'  
    }
     
    }
    
  2. Add the dependency;

    dependencies {
      compile 'com.TippingCanoe.Dewey:library:0.0.1' 
    }
    

Creating layout

The com.tippingcanoe.dewey.Dewey view is the core of this project. Simply add one to your view;

<com.tippingcanoe.dewey.Dewey  android:layout_width="match_parent"  android:layout_height="wrap_content" />

You can also customize certain properties of the view, more on what those properties control later;

<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:custom="http://schemas.android.com/apk/res-auto"  android:layout_width="match_parent"
  android:layout_height="match_parent">

<com.tippingcanoe.dewey.Dewey

android:layout_width="match_parent"

android:layout_height="wrap_content"

custom:stripColor="@color/accent_material_light"

custom:animationDurationMs="@integer/animation_duration_ms"

custom:cloakColor="@color/background_floating_material_dark"

custom:minCloakPercentage="@integer/min_cloak_percentage"

custom:stripHeight="@dimen/strip_height" />  </RelativeLayout>

Setting up views

Once you've got your layout setup, you'll need to find your view;

Dewey dewey = (Dewey) findViewById(R.id.dewey);

Dewey extends android.support.v7.widget.RecyclerView, so you'll need to create and add a new RecyclerView.Adapter. This works the same as any other implementation, so take a look at the example code in the :app module of this repository or familiarize yourself with Google's Documentation;

dewey.setAdapter(new MyAdapter());
  public class MyAdapter extends RecyclerView.Adapter<MyViewHolder> {
  ... 
}
  public class MyViewHolder extends RecyclerView.ViewHolder {
  ... 
}

You can also setup a listener on the view to receive notifications when a new page is selected;

dewey.setOnFocusedPositionChangedListener(new Dewey.OnFocusedPositionChangedListener() {
  @Override  public void onFocusedPositionChanged ( int previousFocusedPosition, int newFocusedPosition ) {

...  
}
 
}
);

Customizing

This library provides plenty of customization touch points to ensure the effect is right for your application;

  • cloakColor
    • The first and last "page" of the list are always visible to the user, pinned at the beginning and end of the list. The "cloak" is rendered behind them to ensure they are legible.
  • minCloakPercentage
    • Sets the minimum amount, between 0 and 100 percent, of the background "cloak"s transparency. From this point, it is calculated on a curve.
  • stripHeight
    • Sets the height dimension for the current page indication strip.
  • stripColor
    • Sets the colour for the current page indication strip.
  • animationDurationMs
    • Sets the speed of the animation for changing pages, in milliseconds.

Contact

Love it? Hate it? Want to make changes to it? Contact me at @iainconnor or [email protected].

Resources

Generating pure tone of an specific frequency was never that easy. ZenTone does all the heavy lifting for you.

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers.

A common RecyclerView.Adapter implementation which supports any kind of items and has useful data operating APIs such as remove, add, etc.

EasyForm makes a form creation and field validation easy.

SegmentedControlView is unswipable button style control view. Inspired by iOS's UISegmentedControl, buttons are evenly spaced in width. Simple usage! Just specify the highlight colors and unselected text colors are calculated automatically.

Cool ImageVeiw effects.

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