From 3366b4b8021f1c26bd4731f493ad8f9b4fb9f459 Mon Sep 17 00:00:00 2001 From: Ruben Sousa Date: Sun, 1 Sep 2024 23:46:41 +0200 Subject: [PATCH] Set perpendicular item spacing for grids too --- .../test/tests/spacing/DpadGridSpacingDecorationTest.kt | 2 +- .../java/com/rubensousa/dpadrecyclerview/DpadRecyclerView.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/spacing/DpadGridSpacingDecorationTest.kt b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/spacing/DpadGridSpacingDecorationTest.kt index f87cd2c3..83c12105 100644 --- a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/spacing/DpadGridSpacingDecorationTest.kt +++ b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/spacing/DpadGridSpacingDecorationTest.kt @@ -430,9 +430,9 @@ class DpadGridSpacingDecorationTest : DpadRecyclerViewTest() { // when onRecyclerView("Set spacing") { recyclerView -> - recyclerView.setItemSpacing(itemSpacing) recyclerView.setItemMinEdgeSpacing(minEdgeSpacing) recyclerView.setItemMaxEdgeSpacing(maxEdgeSpacing) + recyclerView.setItemSpacing(itemSpacing) // then assertThat(recyclerView.getSpacingDecoration()).isEqualTo( diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadRecyclerView.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadRecyclerView.kt index 53d129e4..20270362 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadRecyclerView.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadRecyclerView.kt @@ -1006,7 +1006,10 @@ open class DpadRecyclerView @JvmOverloads constructor( updateSpacingDecoration { previousDecoration -> when { previousDecoration is DpadGridSpacingDecoration -> { - previousDecoration.copy(itemSpacing = spacing) + previousDecoration.copy( + itemSpacing = spacing, + perpendicularItemSpacing = spacing + ) } previousDecoration is DpadLinearSpacingDecoration -> {