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

Response logging interceptor for OkHttp. Logs a url link with url-encoded response for every OkHttp call.

restafari is an android library mostly oriented to facilitate REST API calls to a server and storing the server API response to a local SQLite database.

Adds listeners for Activity and Fragment.

Just a cool background view.

It is generally known that load an unoptimized Dex file at runtime in Android (especially in ART mode) would take a long time. When your App is using MultiDex or PluginFramework, You will find that this problem is hard to bear.

TurboDex was born to solve this problem, Like to opens the god mode for AndroidVM, after using TurboDex, no matter how much Dex file your need to load, it will be finished in a very short time.

Legend is a Hook framework for Android Development, it allows you to Hook Java methods without ROOT. Even more exciting is that it supports both Dalvik and Art environment!

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