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

Scaling layout just like in Blinkist and Spotify app.

MaterialTabsTemplate is solely created to reduce the burden of writing same boiler plate codes for Tab creation in Android.

Pretty print the result of Android lint tool. Would work great when you run lint as part of continuous integration flow.

This lib provides simple and fluent API for creating Android Spannable.

An android library containing most of the helper classes every android developer needs.

The Problem

Every Android developer faces few problems while developing Android Apps. Listing down some of them, which I have faced everytime I create a new android project.

  1. The problem of writing boilerplate code while creating Activities, Fragments is annoying.
  2. Need of readymade methods which can come handy such as showing a toast, or showing a progress dialog or launching a new activity.
  3. The problem of applying proper styles and themes to activities and handling those for pre-lollipop and post-lollipop.

What if we had a library which takes care of all these problems and let the developers concentrate on writing the actual business logic and create awesome functionalities.

The Solution

Using the Helper library developer can solve the above mentioned problems. Using this Helper library is pretty simple.

Ready to use one time password component.

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