MultiLineDivider


Source link: https://github.com/sakebook/MultiLineDivider

MultiLineDivider

Multi divider in RecyclerView on Android.

Vertical Horizontal
Inset Dash
Grid FullBleed
Position Inverted

  • Requirement
    • SDK Version 16+
    • (Use from Java)Kotlin Version 1.0.0+

Usage

Add dependencies

compile 'com.github.sakebook:MultiLineDivider:0.2.0@aar'  // Use from Java compile "org.jetbrains.kotlin:kotlin-stdlib:kotlin_version"

Add to RecyclerView like in addItemDecoration

  • Java
MultiLineDivider multiLineDivider = new MultiLineDivider(this, LinearLayout.VERTICAL);
 recyclerView.addItemDecoration(multiLineDivider);
  • Kotlin
val multiLineDivider = MultiLineDivider(this) recyclerView.addItemDecoration(multiLineDivider)

And Implement VerticalDivider in ViewHolder

  • Java
public class YourViewHolder extends RecyclerView.ViewHolder implements VerticalDivider {

public YourViewHolder(View itemView) {

super(itemView);

  
}

@Override
  public int getHeight() {

return this.itemView.getContext().getResources()

  .getDimensionPixelSize(R.dimen.small_margin);

  
}

@Override
  public int getDrawableRes() {

return R.drawable.custom_divider;
  
}

@Nullable
  @Override
  // android.support.v4.util.Pair
  public Pair<Integer, Integer> getVerticalInset() {

return null;
  
}
 
}
  • Kotlin
class YourViewHolder(view: View): RecyclerView.ViewHolder(view), VerticalDivider {

  override val height = view.context.resources.getDimensionPixelSize(R.dimen.small_margin)
  override val drawableRes = R.drawable.custom_divider
  override val verticalInset: Pair<Int, Int>? = null 
}

Custom

If you want to draw Horizontal divider

MultiLineDivider multiLineDivider = new MultiLineDivider(this, LinearLayout.HORIZONTAL);

and implements HorizontalDivider

If you don't want to draw divider

Implements NoDivider

If you want to inset in divider

@Nullable @Override // android.support.v4.util.Pair public Pair<Integer, Integer> getVerticalInset() {

  int insetLeft = (int) resources.getDimension(R.dimen.list_padding);

  int insetRight = 0;
  return Pair.create(insetLeft, insetRight);
 
}
  

If you want to padding in grid

  • Java
public class YourViewHolder extends RecyclerView.ViewHolder implements GridDivider {

public YourViewHolder(View itemView) {

super(itemView);

  
}

@Override
  public int getPadding() {

return itemView.getContext().getResources().getDimensionPixelSize(R.dimen.tiny_margin);

  
}

@Override
  public boolean getFullBleed() {

return false;
  
}
 
}
  • Kotlin
class YourViewHolder(view: View): RecyclerView.ViewHolder(view), GridDivider {

  override val padding = view.context.resources.getDimensionPixelSize(R.dimen.grid_padding)
  override val fullBleed = true 
}

If you want to draw divider in specific position

  • Java
public class YourViewHolder extends RecyclerView.ViewHolder implements PositionDivider {

public YourViewHolder(View itemView) {

super(itemView);

  
}

@NotNull
  @Override
  public List<Integer> getPositions() {

return Arrays.asList(2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42);
 // include "2"
  
}

@Override
  public boolean getInverted() {

return false;
  
}
 
}
  • Kotlin
class YourViewHolder(view: View): RecyclerView.ViewHolder(view), PositionDivider {

  override val positions = listOf(2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 42)
  override val inverted = false 
}

If you don't want to draw divider in specific position

Implements PositionDivider with inverted true

If you want to draw custom divider in specific position

Implements PositionDivider and VerticalDivider or HorizontalDivider

ProGuard

If you are using ProGuard you might need to add the following option:

-keep class com.sakebook.android.library.multilinedevider.*{
 *; 
}
 

Sample in project sample/

LICENSE

Copyright (C) 2017 Shinya Sakemoto  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

Akatsuki is an Android library that handles state restoration via annotations. The library automatically generates source files through JSR269 to ensure almost zero performance impact.

This library supports Floating Action Button transformation in Material Design Guideline.

This is an all-in-one script to build the Android adb tool for ARM architecture. When executed, the script will download all the necessary files and it will run a custom makefile to build the adb.

A 2D metaball loading indicator.

Mobile Broadcasting Library provides necessary API for broadcasting live video and audio content from mobile device to a media server, which supports RTSP publishing of interleaved H.264/AAC stream over TCP. Basic and Digest RTSP authentication methods are supported and used depending on capabilities of target media server. MBL was successfully tested with Nimble Streamer, Wowza Streaming Engine and Flussonic Media Server.

Video and audio encoding is performed via mobile camera API. Video is encoded in H.264, audio is encoded in AAC format. All streaming related processing is performed via MBL.

Folding tabbar menu for Android. You can easily add a nice animated tab menu to your app.

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