RecyclerViewDivider


Source link: https://github.com/Fondesa/RecyclerViewDivider

RecyclerViewDivider

A RecyclerView's divider that can be customized with simple properties or advanced ones.

It supports completely LinearLayoutManager, GridLayoutManager and partially StaggeredGridLayoutManager.

Usage

If you want to use the basic version of this divider you can just add this line of code after your setAdapter() method:

RecyclerViewDivider.with(context).build().addTo(recyclerView);

Customization

All dividers in the app have default values in xml resources:

  • Color → R.color.recycler_view_divider_color (default is #CFCFCF)
  • Size → R.dimen.recycler_view_divider_size (default is 1dp)
  • Inset before → R.dimen.recycler_view_divider_inset_before (default is 0dp)
  • Inset after → R.dimen.recycler_view_divider_inset_after (default is 0dp)

It can be customized in code with properties equals for each divider:

  • color(int) → change color
  • drawable(Drawable) → change drawable
  • tint(int) → change drawables' tint
  • size(int) → change height for an horizontal divider, width for a vertical one
  • inset(int, int) → change left/right inset for an horizontal divider, top/bottom for a vertical one
Example with all general properties set:
RecyclerViewDivider.with(context)

  .color(color)

  // OR

  .drawable(drawable)

  .tint(tint)

  .size(size)

  .inset(insetBefore, insetAfter)

  .hideLastDivider()

  .build()

  .addTo(recyclerView);

It can also use custom managers to have a different logic for each divider:

  • drawableManager(DrawableManager) → set color/drawable
  • insetManager(InsetManager) → set inset
  • sizeManager(SizeManager) → set size
  • tintManager(TintManager) → set tint
  • visibilityManager(VisibilityManager) → set visibility
Example with all managers set:
RecyclerViewDivider.with(context)

  .drawableManager(new DrawableManager() {

@Override

public Drawable itemDrawable(int groupCount, int groupIndex) {

 return position % 2 == 0 ? new ColorDrawable(Color.BLACK) : new ColorDrawable(Color.BLUE);

}

  
}
)

  .insetManager(new InsetManager() {

 @Override

public int itemInsetAfter(int groupCount, int groupIndex) {

 return position % 2 == 0 ? 10 : 10 * 2;

}

@Override

public int itemInsetBefore(int groupCount, int groupIndex) {

 return position % 2 == 0 ? 15 : 15 * 2;

}

  
}
)

  .sizeManager(new SizeManager() {

@Override

public int itemSize(@Nullable Drawable drawable, int orientation, int groupCount, int groupIndex) {

 return position % 2 == 0 ? 45 : 78;

}

  
}
)

  .tintManager(new TintManager() {

@Override

public int itemTint(int groupCount, int groupIndex) {

 return position == 0 ? Color.YELLOW : Color.GRAY;

}

  
}
)

  .visibilityManager(new VisibilityManager() {

@Override

public int itemVisibility(int groupCount, int groupIndex) {

 return groupCount % groupIndex == 0 ? SHOW_ITEMS_ONLY : SHOW_ALL;

}

  
}
)

  .build()

  .addTo(recyclerView);

You can also use this divider as a simple space between RecyclerView's items:

Example of divider as space:
RecyclerViewDivider.with(context).asSpace().build().addTo(recyclerView);

Compatibility

Android SDK: RecyclerViewDivider requires a minimum API level of 14 (the same of RecyclerView).

Integration

You can download a jar from GitHub's releases page or grab it from jcenter() or mavenCentral().

Gradle

dependencies {

  compile 'com.github.fondesa:recycler-view-divider:1.4.0' 
}

Maven

<dependency>
<groupId>com.github.fondesa</groupId>
<artifactId>recycler-view-divider</artifactId>
<version>1.4.0</version>
<type>pom</type> </dependency>

Resources

Android Http Service is probably the easiest way of using RestServices with Android.

With this component you only have to define whatever you want before and after the request, and declare an intent in your manifest. It will handle network problems, verbs, headers etc. only giving them to it. Developers only have to tell the component what they want to send.

A simple way to define and render UI specs on top of your Android UI.

Modern API for SQLiteDatabase and ContentProvider.

Typed Preferences provides classes which allow to store and retrieve settings from the preferences. There is an individual class for each native type:

  • BooleanPreference
  • DoublePreference
  • FloatPreference
  • IntPreference
  • LongPreference
  • StringPreference

A python utility to pull android database files of a particular app from an emulator without having to go through all the regular adb shenanigans every time, features:

  • pulls the .db files from the databases folder to a local directory on your dev computer
  • supports multiple devices
  • supports selective db file pulls
  • tested on a Genymotion emulator

FFmpeg-Android-Java:

  • FFmpeg for Android compiled with x264, libass, fontconfig, freetype and fribidi
  • Supports Android L

Supported Architecture:

  • armv7
  • armv7-neon
  • x86

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