Skip to content

Commit

Permalink
Bump to 1.4.0-alpha06
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Sep 4, 2024
1 parent bf54c35 commit 581b28e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 15 deletions.
16 changes: 16 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions docs/migrating_leanback.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
<!-- This is the same as VerticalGridView -->
<com.rubensousa.dpadrecyclerview.DpadRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical|horizontal"
android:orientation="vertical"/>
```

```xml linenums="1" hl_lines="6"
<!-- This is the same as HorizontalGridView -->
<com.rubensousa.dpadrecyclerview.DpadRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"/>
```

## Window Alignment
Expand Down Expand Up @@ -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).

Expand Down
32 changes: 26 additions & 6 deletions docs/recipes/spacing.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -33,6 +41,18 @@ fun setupSpacing(recyclerView: DpadRecyclerView) {
}
```

XML variant:

```xml linenums="1" hl_lines="6-7"
<com.rubensousa.dpadrecyclerview.DpadRecyclerView
android:id="@+id/recyclerView"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
app:dpadRecyclerViewItemEdgeSpacing="@dimen/vertical_edge_spacing"
app:dpadRecyclerViewItemSpacing="@dimen/vertical_item_spacing" />
```

!!! note

- If you don't specify a `edgeSpacing`, by default it will be the same as `itemSpacing`.
Expand Down Expand Up @@ -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
)
)
Expand Down
9 changes: 9 additions & 0 deletions docs/xml.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# XML Attributes


## Alignment

```xml linenums="1"
Expand All @@ -18,6 +19,14 @@
<attr name="dpadRecyclerViewParentAlignmentPreferKeylineOverEdge" format="boolean" />
```

## Spacings

```xml linenums="1"
<attr name="dpadRecyclerViewItemSpacing" format="dimension" />
<attr name="dpadRecyclerViewItemEdgeSpacing" format="dimension" />
<attr name="dpadRecyclerViewItemMinEdgeSpacing" format="dimension" />
<attr name="dpadRecyclerViewItemMaxEdgeSpacing" format="dimension" />
```

## Focus

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
LIBRARY_VERSION=1.4.0-alpha06
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 581b28e

Please sign in to comment.