From 581b28ef17faf99026b4067b801927ae0e4409cc Mon Sep 17 00:00:00 2001 From: Ruben Sousa Date: Wed, 4 Sep 2024 23:17:50 +0200 Subject: [PATCH] Bump to 1.4.0-alpha06 --- docs/changelog.md | 16 ++++++++++++++++ docs/migrating_leanback.md | 20 +++++++++++++------- docs/recipes/spacing.md | 32 ++++++++++++++++++++++++++------ docs/xml.md | 9 +++++++++ gradle.properties | 2 +- mkdocs.yml | 2 +- 6 files changed, 66 insertions(+), 15 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 092ff600..4061315e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,22 @@ ## Version 1.4.0 +### 1.4.0-alpha06 + +2024-09-05 + +#### New features + +- Added `setItemSpacing`, `setItemEdgeSpacing` and other spacing setters to `DpadRecyclerView` ([#263](https://github.com/rubensousa/DpadRecyclerView/pull/263)) + Documentation available [here](recipes/spacing.md). + +- Added independent min and max edge spacings to `DpadLinearSpacingDecoration` and `DpadGridSpacingDecoration` ([#263](https://github.com/rubensousa/DpadRecyclerView/pull/263)) + +#### API changes + +- Now `DpadDragHelper` exposes `fromUser` in `onDragStopped`, which allows distinguishing between user or programmatic stop requests ([#264](https://github.com/rubensousa/DpadRecyclerView/pull/264)) + + ### 1.4.0-alpha05 2024-08-30 diff --git a/docs/migrating_leanback.md b/docs/migrating_leanback.md index a68f4d3d..2f5eb073 100644 --- a/docs/migrating_leanback.md +++ b/docs/migrating_leanback.md @@ -20,12 +20,22 @@ You can combine `DpadRecyclerView` with `BaseGridView` as follows: Instead of using `VerticalGridView` or `HorizontalGridView`, use `DpadRecyclerView` and set the orientation either programmatically with `setOrientation` or with plain XML: -```xml linenums="1" hl_lines="5" +```xml linenums="1" hl_lines="6" + +``` + +```xml linenums="1" hl_lines="6" + + ``` ## Window Alignment @@ -140,11 +150,7 @@ If you were using `FacetProviderAdapter` for anything else, just write your own ## Item spacing -There's no public API for item spacings at the layout level for `DpadRecyclerView` like `setItemSpacing` from `BaseGridView`. - -However, we can use the standard `RecyclerView.ItemDecoration` API for this. - -`DpadRecyclerView` ships with `DpadLinearSpacingDecoration` and `DpadGridSpacingDecoration` to achieve the same effect. +`DpadRecyclerView` ships with `DpadLinearSpacingDecoration` and `DpadGridSpacingDecoration` to achieve this, together with `setItemSpacing` and similar APIs. Please check the examples in the recipes at [Spacing](recipes/spacing.md). diff --git a/docs/recipes/spacing.md b/docs/recipes/spacing.md index 3a7f3ca2..cd3275f3 100644 --- a/docs/recipes/spacing.md +++ b/docs/recipes/spacing.md @@ -1,13 +1,21 @@ # Spacing Recipes -Unlike `BaseGridView`, `DpadRecyclerView` does not have a `setItemSpacing` method. -However, you can achieve the same effect with one of the implementations of `ItemDecoration` provided by this library: +You can achieve spacing between items with one of the implementations of `ItemDecoration` provided by this library: - `DpadLinearSpacingDecoration`: for columns and rows - `DpadGridSpacingDecoration`: for grids + Both of them support vertical and horizontal orientations. Please check the examples below. +Alternatively, the following APIs also work: + +```kotlin +setItemSpacing() +setItemEdgeSpacing() +setItemMaxEdgeSpacing() +setItemMinEdgeSpacing() +``` ## Linear spacings @@ -33,6 +41,18 @@ fun setupSpacing(recyclerView: DpadRecyclerView) { } ``` +XML variant: + +```xml linenums="1" hl_lines="6-7" + +``` + !!! note - If you don't specify a `edgeSpacing`, by default it will be the same as `itemSpacing`. @@ -147,14 +167,14 @@ fun setupSpacing(recyclerView: DpadRecyclerView) { ```kotlin linenums="1" fun setupSpacing(recyclerView: DpadRecyclerView) { recyclerView.addItemDecoration( - DpadGridSpacingDecoration.createVertical( - horizontalItemSpacing = recyclerView.resources.getDimensionPixelOffset( + DpadGridSpacingDecoration.create( + itemSpacing = recyclerView.resources.getDimensionPixelOffset( R.dimen.grid_horizontal_item_spacing ), - verticalItemSpacing = recyclerView.resources.getDimensionPixelOffset( + perpendicularItemSpacing = recyclerView.resources.getDimensionPixelOffset( R.dimen.grid_horizontal_item_spacing ), - verticalEdgeSpacing = recyclerView.resources.getDimensionPixelOffset( + edgeSpacing = recyclerView.resources.getDimensionPixelOffset( R.dimen.horizontal_edge_spacing ) ) diff --git a/docs/xml.md b/docs/xml.md index 2f27eca8..c7c6772e 100644 --- a/docs/xml.md +++ b/docs/xml.md @@ -1,5 +1,6 @@ # XML Attributes + ## Alignment ```xml linenums="1" @@ -18,6 +19,14 @@ ``` +## Spacings + +```xml linenums="1" + + + + +``` ## Focus diff --git a/gradle.properties b/gradle.properties index 7090a371..c790c619 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-alpha05 \ No newline at end of file +LIBRARY_VERSION=1.4.0-alpha06 \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 5a3f02a6..5588ecef 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,7 +24,7 @@ theme: extra: dpadrecyclerview: - version: '1.4.0-alpha05' + version: '1.4.0-alpha06' social: - icon: 'fontawesome/brands/github' link: 'https://github.com/rubensousa/DpadRecyclerView'