-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
setColoredDivider
and setVerticalGap
Kotlin extension funct…
…ions on the `RecyclerView` class.
- Loading branch information
1 parent
4fc934f
commit b666590
Showing
2 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
library/src/main/java/com/tazkiyatech/utils/views/RecyclerViewExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.tazkiyatech.utils.views | ||
|
||
import androidx.annotation.ColorInt | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
/** | ||
* Sets the colored divider that will be drawn between each item in the [RecyclerView]. | ||
* | ||
* Note that this method calls into the [RecyclerView.addItemDecoration] method internally. | ||
* This call will likely conflict with any other calls to [RecyclerView.addItemDecoration] that you make on the [RecyclerView]. | ||
*/ | ||
fun RecyclerView.setColoredDivider(@ColorInt dividerColor: Int, | ||
dividerHeightPixels: Int, | ||
dividerMarginLeftPixels: Int = 0, | ||
dividerMarginRightPixels: Int = 0) { | ||
val itemDecoration = RecyclerViewColoredDividerItemDecoration( | ||
dividerColor, dividerHeightPixels, dividerMarginLeftPixels, dividerMarginRightPixels | ||
) | ||
addItemDecoration(itemDecoration) | ||
} | ||
|
||
/** | ||
* Sets the vertical gap that will be drawn between each item in the [RecyclerView]. | ||
* | ||
* Note that this method calls into the [RecyclerView.addItemDecoration] method internally. | ||
* This call will likely conflict with any other calls to [RecyclerView.addItemDecoration] that you make on the [RecyclerView]. | ||
*/ | ||
fun RecyclerView.setVerticalGap(verticalGapInPixels: Int) { | ||
addItemDecoration(RecyclerViewVerticalGapItemDecoration(verticalGapInPixels)) | ||
} |