mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
HabitCardListView: Prevent duplicate inset decorations
This commit is contained in:
@@ -60,6 +60,7 @@ class HabitCardListView(
|
|||||||
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
) : RecyclerView(context, null, R.attr.scrollableRecyclerViewStyle) {
|
||||||
|
|
||||||
var checkmarkCount: Int = 0
|
var checkmarkCount: Int = 0
|
||||||
|
private var insetDecorationsAdded: Boolean = false
|
||||||
|
|
||||||
var dataOffset: Int = 0
|
var dataOffset: Int = 0
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -84,6 +85,8 @@ class HabitCardListView(
|
|||||||
|
|
||||||
private fun applyBottomInset() {
|
private fun applyBottomInset() {
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
|
ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
|
||||||
|
if (insetDecorationsAdded) return@setOnApplyWindowInsetsListener insets
|
||||||
|
insetDecorationsAdded = true
|
||||||
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val systemBarsInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
addItemDecoration(object : ItemDecoration() {
|
addItemDecoration(object : ItemDecoration() {
|
||||||
override fun getItemOffsets(
|
override fun getItemOffsets(
|
||||||
|
|||||||
Reference in New Issue
Block a user