From 0bca4538418b9b2fecbcc4f1e6882ad267014cc6 Mon Sep 17 00:00:00 2001 From: Ruben Sousa Date: Wed, 14 Aug 2024 17:29:26 +0200 Subject: [PATCH 1/2] Make header visible by default --- .../tests/layout/DpadScrollableLayoutTest.kt | 27 ++++++++++++++++++- .../dpadrecyclerview/DpadScrollableLayout.kt | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/layout/DpadScrollableLayoutTest.kt b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/layout/DpadScrollableLayoutTest.kt index d104547e..38296db7 100644 --- a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/layout/DpadScrollableLayoutTest.kt +++ b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/layout/DpadScrollableLayoutTest.kt @@ -405,8 +405,33 @@ class DpadScrollableLayoutTest { Rect(0, headerHeight / 2, screenWidth, headerHeight / 2 + headerHeight) ) assertThat(recyclerViewBounds).isEqualTo( - Rect(0, headerHeight / 2 + headerHeight, screenWidth, screenHeight + headerHeight / 2 + headerHeight) + Rect( + 0, + headerHeight / 2 + headerHeight, + screenWidth, + screenHeight + headerHeight / 2 + headerHeight + ) + ) + } + + @Test + fun testHeaderIsVisibleByDefault() { + // given + val headerHeight = getHeaderHeight() + val screenWidth = getWidth() + var actualVisibility = false + + // when + fragmentScenario.onFragment { fragment -> + actualVisibility = fragment.scrollableLayout?.isHeaderVisible ?: false + } + + // then + val header1Bounds = getViewBounds(R.id.header1) + assertThat(header1Bounds).isEqualTo( + Rect(0, 0, screenWidth, headerHeight) ) + assertThat(actualVisibility).isTrue() } private fun waitViewAtCoordinates(viewId: Int, top: Int, bottom: Int, timeout: Long = 4L) { diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadScrollableLayout.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadScrollableLayout.kt index 605a502b..6adf666e 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadScrollableLayout.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/DpadScrollableLayout.kt @@ -52,7 +52,7 @@ class DpadScrollableLayout @JvmOverloads constructor( var headerHeight = 0 private set - var isHeaderVisible = false + var isHeaderVisible = true private set private var currentOffset = 0 From b6188f618e6ade5f48cf194689a673e0451bd3d5 Mon Sep 17 00:00:00 2001 From: Ruben Sousa Date: Wed, 14 Aug 2024 17:31:51 +0200 Subject: [PATCH 2/2] Bump to 1.4.0-alpha03 --- docs/changelog.md | 9 +++++++++ gradle.properties | 2 +- mkdocs.yml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 17b8f2b0..b860e4d2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,15 @@ ## Version 1.4.0 +### 1.4.0-alpha03 + +2024-08-14 + +#### Bug fixes + +- Fix header not being initially shown sometimes with `DpadScrollableLayout` ([#253](https://github.com/rubensousa/DpadRecyclerView/pull/253)) + + ### 1.4.0-alpha02 2024-08-14 diff --git a/gradle.properties b/gradle.properties index f166f1ae..e6ee9e4c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,4 +22,4 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true android.enableR8.fullMode=true -LIBRARY_VERSION=1.4.0-alpha02 \ No newline at end of file +LIBRARY_VERSION=1.4.0-alpha03 \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 1393ba5f..997a5e05 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,7 +24,7 @@ theme: extra: dpadrecyclerview: - version: '1.4.0-alpha02' + version: '1.4.0-alpha03' social: - icon: 'fontawesome/brands/github' link: 'https://github.com/rubensousa/DpadRecyclerView'