### Start alignment configuration
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/alignment
Configures a horizontal DpadRecyclerView to align views to the start with a specific offset.
```XML
```
```Kotlin
recyclerView.setParentAlignment(
ParentAlignment(
fraction = 0f,
offset = 24.dp.toPx()
)
)
recyclerView.setChildAlignment(
ChildAlignment(fraction = 0f)
)
```
--------------------------------
### Setup linear column spacing
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing
Programmatic configuration for column spacing using DpadLinearSpacingDecoration.
```kotlin
fun setupSpacing(recyclerView: DpadRecyclerView) {
recyclerView.addItemDecoration(
DpadLinearSpacingDecoration.create(
itemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.vertical_item_spacing
),
edgeSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.vertical_edge_spacing
),
perpendicularEdgeSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.horizontal_edge_spacing
)
)
)
}
```
--------------------------------
### Setup linear row spacing
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing
Programmatic configuration for row spacing using DpadLinearSpacingDecoration.
```kotlin
fun setupSpacing(recyclerView: DpadRecyclerView) {
recyclerView.addItemDecoration(
DpadLinearSpacingDecoration.create(
itemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.horizontal_item_spacing
),
edgeSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.horizontal_edge_spacing
),
perpendicularEdgeSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.vertical_edge_spacing
)
)
)
}
```
--------------------------------
### Setup uniform grid spacing
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing
Programmatic configuration for applying the same spacing to all sides in a grid.
```kotlin
fun setupSpacing(recyclerView: DpadRecyclerView) {
recyclerView.addItemDecoration(
DpadGridSpacingDecoration.create(
itemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.grid_item_spacing
)
)
)
}
```
--------------------------------
### Setup even linear spacing
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing
Simplified programmatic configuration for uniform spacing across all items.
```kotlin
fun setupSpacing(recyclerView: DpadRecyclerView) {
recyclerView.addItemDecoration(
DpadLinearSpacingDecoration.create(
itemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.vertical_item_spacing
)
)
)
}
```
--------------------------------
### Setup vertical grid spacing
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/spacing
Programmatic configuration for vertical grid spacing using DpadGridSpacingDecoration.
```kotlin
fun setupSpacing(recyclerView: DpadRecyclerView) {
recyclerView.addItemDecoration(
DpadGridSpacingDecoration.createVertical(
itemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.grid_horizontal_item_spacing
),
perpendicularItemSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.grid_vertical_item_spacing
),
edgeSpacing = recyclerView.resources.getDimensionPixelOffset(
R.dimen.grid_vertical_edge_spacing
)
)
)
}
```
--------------------------------
### Listener Management
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/index.html
Methods for getting listeners for key and motion events.
```APIDOC
## getOnKeyInterceptListener
### Description
Gets the listener for intercepted key events.
### Method
fun
### Endpoint
getOnKeyInterceptListener(): DpadRecyclerView.OnKeyInterceptListener?
## getOnMotionInterceptListener
### Description
Gets the listener for intercepted motion events.
### Method
fun
### Endpoint
getOnMotionInterceptListener(): DpadRecyclerView.OnMotionInterceptListener?
```
--------------------------------
### Set Extra Layout Space Strategy
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/layout
Implement `ExtraLayoutSpaceStrategy` to define how extra layout space is calculated. This example adds half a page width of extra space at the start of the layout, useful for edge alignment.
```kotlin
recyclerView.setExtraLayoutSpaceStrategy(object : ExtraLayoutSpaceStrategy {
override fun calculateStartExtraLayoutSpace(state: RecyclerView.State): Int {
return recyclerView.width / 2
}
})
```
--------------------------------
### Create a focusable Composable
Source: https://rubensousa.github.io/DpadRecyclerView/getting_started
Example of a Composable item that handles focus states and click events using dpadClickable.
```kotlin
@Composable
fun ItemComposable(
item: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
var isFocused by remember { mutableStateOf(false) }
val backgroundColor = if (isFocused) Color.White else Color.Black
val textColor = if (isFocused) Color.Black else Color.White
Box(
modifier = modifier
.background(backgroundColor)
.onFocusChanged { focusState ->
isFocused = focusState.hasFocus
}
.focusable()
.dpadClickable {
onClick()
},
contentAlignment = Alignment.Center,
) {
Text(
text = item.toString(),
color = textColor,
fontSize = 35.sp
)
}
}
```
--------------------------------
### DpadComposeViewHolder Usage
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-compose/com.rubensousa.dpadrecyclerview.compose/-dpad-compose-view-holder/index.html
Examples of how to use DpadComposeViewHolder in onCreateViewHolder and onBindViewHolder.
```APIDOC
## DpadComposeViewHolder Usage Examples
### onCreateViewHolder
This example shows how to return a DpadComposeViewHolder in `onCreateViewHolder`.
```kotlin
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DpadComposeViewHolder {
return DpadComposeViewHolder(parent) { item, isFocused ->
ItemComposable(item, isFocused)
}
}
```
### onBindViewHolder
This example demonstrates how to update the item state in `onBindViewHolder`.
```kotlin
override fun onBindViewHolder(holder: DpadComposeViewHolder, position: Int) {
holder.setItemState(getItem(position))
}
```
```
--------------------------------
### Start Drag Operation
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-drag-helper/index.html
Initiates a drag operation for the item at the specified position. Returns true if the drag was started successfully, false otherwise. This requires the RecyclerView to be attached.
```kotlin
fun startDrag(position: Int): Boolean
```
--------------------------------
### DpadViewActions
Source: https://rubensousa.github.io/DpadRecyclerView/testing
Provides ViewActions for DPAD navigation, including getting view bounds and managing focus.
```APIDOC
## DpadViewActions
### Description
Contains various ViewActions for interacting with views, particularly for DPAD navigation and retrieving view properties.
### Actions
- `getViewBounds`: Returns the bounds of a view in the coordinate-space of the root view of the window.
- `getRelativeViewBounds`: Returns the bounds of a view in the coordinate-space of the parent view.
- `clearFocus`: Clears the focus of a view if something else can take focus in its place.
- `requestFocus`: Requests focus for a view.
```
--------------------------------
### Custom Span Sizes with DpadSpanSizeLookup
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/layout
Implement `DpadSpanSizeLookup` to customize the span size of items in a grid. This example makes the first item occupy the full width of the grid.
```kotlin
recyclerView.setSpanSizeLookup(object : DpadSpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return if (position == 0) {
recyclerView.getSpanCount()
} else {
1
}
}
})
```
--------------------------------
### DpadRecyclerView Layout and Decoration Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.layoutmanager/-pivot-layout-manager/index.html
Provides methods related to the layout and decoration of items within the DpadRecyclerView, including getting decoration heights, widths, and managing child views.
```APIDOC
## DpadRecyclerView Layout and Decoration Methods
### Description
Methods for managing item layout, decorations, and child views within the DpadRecyclerView.
### Methods
- **getBottomDecorationHeight** (`@NonNull child: View`): `Int` - Gets the height of the bottom decoration for a given child view.
- **getDecoratedBottom** (`@NonNull child: View`): `Int` - Gets the bottom coordinate of the decorated child view.
- **getDecoratedBoundsWithMargins** (`@NonNull view: View`, `@NonNull outBounds: Rect`) - Gets the decorated bounds of a view, including margins.
- **getDecoratedLeft** (`@NonNull child: View`): `Int` - Gets the left coordinate of the decorated child view.
- **getDecoratedMeasuredHeight** (`@NonNull child: View`): `Int` - Gets the measured height of the decorated child view.
- **getDecoratedMeasuredWidth** (`@NonNull child: View`): `Int` - Gets the measured width of the decorated child view.
- **getDecoratedRight** (`@NonNull child: View`): `Int` - Gets the right coordinate of the decorated child view.
- **getDecoratedTop** (`@NonNull child: View`): `Int` - Gets the top coordinate of the decorated child view.
- **getLeftDecorationWidth** (`@NonNull child: View`): `Int` - Gets the width of the left decoration for a given child view.
- **getRightDecorationWidth** (`@NonNull child: View`): `Int` - Gets the width of the right decoration for a given child view.
- **getTopDecorationHeight** (`@NonNull child: View`): `Int` - Gets the height of the top decoration for a given child view.
- **getTransformedBoundingBox** (`@NonNull child: View`, `includeDecorInsets: Boolean`, `@NonNull out: Rect`) - Gets the transformed bounding box of a child view.
- **layoutDecorated** (`@NonNull child: View`, `left: Int`, `top: Int`, `right: Int`, `bottom: Int`) - Lays out a decorated child view.
- **layoutDecoratedWithMargins** (`@NonNull child: View`, `left: Int`, `top: Int`, `right: Int`, `bottom: Int`) - Lays out a decorated child view with margins.
- **measureChild** (`@NonNull child: View`, `widthUsed: Int`, `heightUsed: Int`) - Measures a child view.
- **measureChildWithMargins** (`@NonNull child: View`, `widthUsed: Int`, `heightUsed: Int`) - Measures a child view with margins.
- **offsetChildrenHorizontal** (`@Px dx: Int`) - Offsets children horizontally.
- **offsetChildrenVertical** (`@Px dy: Int`) - Offsets children vertically.
```
--------------------------------
### Companion.create
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-grid-spacing-decoration/-companion/index.html
Factory methods to instantiate DpadGridSpacingDecoration with various spacing configurations.
```APIDOC
## Static Function create
### Description
Creates a new instance of DpadGridSpacingDecoration with specified spacing values.
### Parameters
- **itemSpacing** (Int) - Required - Spacing between items.
- **edgeSpacing** (Int) - Optional - Spacing at the edges (defaults to itemSpacing).
- **perpendicularItemSpacing** (Int) - Optional - Spacing between items in the perpendicular direction (defaults to itemSpacing).
## Static Function create (Overload)
### Description
Creates a new instance of DpadGridSpacingDecoration with distinct minimum and maximum edge spacing.
### Parameters
- **itemSpacing** (Int) - Required - Spacing between items.
- **minEdgeSpacing** (Int) - Optional - Minimum spacing at the edges (defaults to itemSpacing).
- **maxEdgeSpacing** (Int) - Optional - Maximum spacing at the edges (defaults to itemSpacing).
- **perpendicularItemSpacing** (Int) - Optional - Spacing between items in the perpendicular direction (defaults to itemSpacing).
```
--------------------------------
### minEdgeSpacing Property
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-linear-spacing-decoration/min-edge-spacing.html
Configuration for the spacing between the start edge and the first item.
```APIDOC
## minEdgeSpacing
### Description
Defines the spacing between the start edge and the first item in the DPadRecyclerView. If not explicitly specified, it defaults to the value of itemSpacing.
### Parameters
- **minEdgeSpacing** (Int) - Required - The spacing value in pixels.
```
--------------------------------
### calculateStartExtraLayoutSpace
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-extra-layout-space-strategy/calculate-start-extra-layout-space.html
Calculates the extra space in pixels to be added to the start of the layout.
```APIDOC
## calculateStartExtraLayoutSpace
### Description
Calculates the extra space (in pixels) to be added to the start of the layout.
### Parameters
#### Path Parameters
- **state** (RecyclerView.State) - Required - The current DpadRecyclerView state
### Response
- **Return** (Int) - The extra space (in pixels) to be added to the start of the layout
```
--------------------------------
### Get Sub-Position Alignments
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-view-holder/index.html
Retrieves the list of sub-position alignments for the ViewHolder.
```kotlin
open fun getSubPositionAlignments(): List
```
--------------------------------
### DpadSpacingDecoration Constructor
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-spacing-decoration/index.html
Initializes a new instance of the DpadSpacingDecoration class.
```APIDOC
## Constructors
DpadSpacingDecoration
Link copied to clipboard
constructor()
```
--------------------------------
### GET /spacing-decoration
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/get-spacing-decoration.html
Retrieves the current spacing decoration configuration for the DpadRecyclerView.
```APIDOC
## GET /spacing-decoration
### Description
Retrieves the current spacing decoration configuration set for the DpadRecyclerView. This configuration is established through methods like setItemSpacing, setItemEdgeSpacing, setItemMinEdgeSpacing, setItemMaxEdgeSpacing, or addItemDecoration.
### Method
GET
### Endpoint
/spacing-decoration
### Return
- **DpadSpacingDecoration?** - An object representing the spacing decoration, or null if not configured.
```
--------------------------------
### Methods and Properties
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-linear-spacing-decoration/index.html
Overview of available methods and properties for managing spacing configurations.
```APIDOC
## Methods and Properties
### Properties
- **itemSpacing** (Int) - Spacing between items.
- **minEdgeSpacing** (Int) - Spacing at the start edge.
- **maxEdgeSpacing** (Int) - Spacing at the end edge.
- **perpendicularEdgeSpacing** (Int) - Spacing perpendicular to layout orientation.
### Functions
- **setSpacingLookup(spacingLookup: DpadSpacingLookup?)** - Configures a custom spacing lookup for the decoration.
- **getItemOffsets(...)** - Calculates the offsets for the item decoration.
- **onDraw(...)** - Handles drawing logic for the decoration.
- **onDrawOver(...)** - Handles drawing logic over the items.
```
--------------------------------
### GET getParentAlignment
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/get-parent-alignment.html
Retrieves the current parent alignment configuration for the DPadRecyclerView.
```APIDOC
## getParentAlignment
### Description
Retrieves the current parent alignment configuration for the DPadRecyclerView.
### Return
- **ParentAlignment** - The current parent alignment configuration.
```
--------------------------------
### setMinEdgeFadingOffset
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/set-min-edge-fading-offset.html
Configures the starting position for the fading effect at the minimum edge of the RecyclerView.
```APIDOC
## setMinEdgeFadingOffset
### Description
Sets the start position of the fading effect applied to the min edge in pixels. Default is 0, which means that the fading effect starts from the min edge (left or top).
### Parameters
#### Method Parameters
- **offset** (Int) - Required - The start position of the fading effect in pixels.
```
--------------------------------
### Constructor: DpadGridSpacingDecoration
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-grid-spacing-decoration/index.html
Initializes a new instance of DpadGridSpacingDecoration with specified spacing parameters.
```APIDOC
## Constructor DpadGridSpacingDecoration
### Description
Creates an item decoration that applies spacing to all sides of a view part of a grid.
### Parameters
- **itemSpacing** (Int) - Required - Default spacing between items that share a span group.
- **minEdgeSpacing** (Int) - Required - Spacing between the start edge and the first row.
- **maxEdgeSpacing** (Int) - Required - Spacing between the last row and the end edge.
- **perpendicularItemSpacing** (Int) - Required - Spacing between items across different span groups.
```
--------------------------------
### GET /getOnKeyInterceptListener
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/get-on-key-intercept-listener.html
Retrieves the currently set key intercept listener for the DpadRecyclerView.
```APIDOC
## GET /getOnKeyInterceptListener
### Description
Retrieves the `OnKeyInterceptListener` that was previously set using `setOnKeyInterceptListener`.
### Method
GET
### Endpoint
`/getOnKeyInterceptListener`
### Response
#### Success Response (200)
- **listener** (DpadRecyclerView.OnKeyInterceptListener?) - The listener set by `setOnKeyInterceptListener`, or null if no listener is set.
#### Response Example
```json
{
"listener": null
}
```
```
--------------------------------
### FocusedRootMatcher Constructor
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-testing/com.rubensousa.dpadrecyclerview.testing.matchers/-focused-root-matcher/index.html
Initializes a new instance of the FocusedRootMatcher class.
```APIDOC
## FocusedRootMatcher Constructor
### Description
Initializes a new instance of the FocusedRootMatcher class.
### Method
constructor()
### Endpoint
N/A (Class Constructor)
### Parameters
None
### Request Example
N/A
### Response
N/A
```
--------------------------------
### execute
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-testing/com.rubensousa.dpadrecyclerview.testing.actions/-dpad-recycler-view-actions/execute.html
Creates a ViewAction to be executed on a DpadRecyclerView instance.
```APIDOC
## execute
### Description
Creates a ViewAction that performs a specified action on a DpadRecyclerView instance.
### Parameters
- **label** (String) - Required - A label identifying the action.
- **action** ((recyclerView: DpadRecyclerView) -> Unit) - Required - A lambda function to be executed on the DpadRecyclerView instance.
### Returns
- **ViewAction** - The resulting action object.
```
--------------------------------
### Get Parent Alignment
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-alignment-lookup/index.html
Retrieves the custom parent alignment for a specific ViewHolder.
```kotlin
open fun getParentAlignment( viewHolder: RecyclerView.ViewHolder): ParentAlignment?
```
--------------------------------
### Get Child Alignment
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-alignment-lookup/index.html
Retrieves the custom child alignment for a specific ViewHolder.
```kotlin
open fun getChildAlignment( viewHolder: RecyclerView.ViewHolder): ChildAlignment?
```
--------------------------------
### Initialize DpadScroller
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-scroller/index.html
Instantiate the DpadScroller with an optional custom scroll distance calculator.
```kotlin
class DpadScroller(calculator: DpadScroller.ScrollDistanceCalculator = DefaultScrollDistanceCalculator())
```
--------------------------------
### minEdgeSpacing Configuration
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-grid-spacing-decoration/min-edge-spacing.html
Configures the spacing between the start edge and the first row of items in the DPadRecyclerView.
```APIDOC
## Property: minEdgeSpacing
### Description
Sets the spacing between the start edge and the first row. If not specified, it defaults to `itemSpacing`.
### Type
Int
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
None
#### Response Example
None
```
--------------------------------
### Constructor DpadLinearSpacingDecoration
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-linear-spacing-decoration/index.html
Initializes a new instance of DpadLinearSpacingDecoration with specified spacing parameters.
```APIDOC
## Constructor DpadLinearSpacingDecoration
### Description
Creates an item decoration that applies spacing to all sides of a view within a Column or Row layout.
### Parameters
#### Constructor Parameters
- **itemSpacing** (Int) - Required - Spacing between items in the layout direction.
- **minEdgeSpacing** (Int) - Required - Spacing between the start edge and the first item.
- **maxEdgeSpacing** (Int) - Required - Spacing between the last item and the end edge.
- **perpendicularEdgeSpacing** (Int) - Required - Spacing between the edges perpendicular to the layout orientation.
```
--------------------------------
### Asserting focus in DpadRecyclerView
Source: https://rubensousa.github.io/DpadRecyclerView/testing
Example of using DpadRecyclerViewAssertions to verify if a specific position is focused.
```kotlin
Espresso.onView(withId(R.id.recyclerView))
.assert(DpadRecyclerViewAssertions.isFocused(position = 5))
```
--------------------------------
### Create DpadGridSpacingDecoration instances
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-grid-spacing-decoration/-companion/index.html
Use these static factory methods to instantiate a DpadGridSpacingDecoration with specified spacing parameters.
```kotlin
@JvmStatic
fun create( @Px itemSpacing: Int, @Px edgeSpacing: Int = itemSpacing, @Px perpendicularItemSpacing: Int = itemSpacing): DpadGridSpacingDecoration
```
```kotlin
@JvmStatic
fun create( @Px itemSpacing: Int, @Px minEdgeSpacing: Int = itemSpacing, @Px maxEdgeSpacing: Int = itemSpacing, @Px perpendicularItemSpacing: Int = itemSpacing): DpadGridSpacingDecoration
```
--------------------------------
### GET /values
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-focusable-direction/values.html
Retrieves an array of all constants defined in the FocusableDirection enum in their declared order.
```APIDOC
## values()
### Description
Returns an array containing the constants of the FocusableDirection enum type, in the order they are declared. This method is useful for iterating over all available enum constants.
### Response
#### Success Response (200)
- **Array** - An array containing all enum constants.
```
--------------------------------
### DpadGridSpacingDecoration.create
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-grid-spacing-decoration/-companion/create.html
Factory methods to instantiate DpadGridSpacingDecoration with various spacing configurations.
```APIDOC
## Static Method: create
### Description
Creates an instance of DpadGridSpacingDecoration with specified spacing parameters.
### Parameters
- **itemSpacing** (Int) - Required - The spacing between items.
- **edgeSpacing** (Int) - Optional - The spacing at the edges (defaults to itemSpacing).
- **perpendicularItemSpacing** (Int) - Optional - The spacing between items in the perpendicular direction (defaults to itemSpacing).
## Static Method: create (Overload)
### Description
Creates an instance of DpadGridSpacingDecoration with explicit minimum and maximum edge spacing.
### Parameters
- **itemSpacing** (Int) - Required - The spacing between items.
- **minEdgeSpacing** (Int) - Optional - The minimum spacing at the edges (defaults to itemSpacing).
- **maxEdgeSpacing** (Int) - Optional - The maximum spacing at the edges (defaults to itemSpacing).
- **perpendicularItemSpacing** (Int) - Optional - The spacing between items in the perpendicular direction (defaults to itemSpacing).
```
--------------------------------
### GET /entries
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-focusable-direction/entries.html
Retrieves an immutable list of all enum entries for FocusableDirection in their declared order.
```APIDOC
## GET /entries
### Description
Returns a representation of an immutable list of all enum entries for FocusableDirection, in the order they're declared. This method is intended for iteration over the enum entries.
### Response
#### Success Response (200)
- **entries** (EnumEntries) - An immutable list of all enum entries.
```
--------------------------------
### View Transition and Focus Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-scrollable-layout/index.html
Methods for managing view transitions and focus management within the view hierarchy.
```APIDOC
## dispatchFinishTemporaryDetach
### Description
Called when a temporary detach operation is finished.
### Method
`open fun`
### Endpoint
`dispatchFinishTemporaryDetach()`
## dispatchStartTemporaryDetach
### Description
Called to initiate a temporary detach operation.
### Method
`open fun`
### Endpoint
`dispatchStartTemporaryDetach()`
## endViewTransition
### Description
Ends a view transition.
### Method
`open fun`
### Endpoint
`endViewTransition(view: View?)`
## findFocus
### Description
Finds the currently focused view.
### Method
`open fun`
### Endpoint
`findFocus(): View?`
## focusableViewAvailable
### Description
Called when a focusable view becomes available.
### Method
`open fun`
### Endpoint
`focusableViewAvailable(v: View?)`
## focusSearch
### Description
Performs a focus search in a given direction.
### Method
`open fun`
### Endpoint
`focusSearch(focused: View?, direction: Int): View?`
```
--------------------------------
### Get Selected Sub Position
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/get-selected-sub-position.html
Retrieves the current selected sub-position within the DPadRecyclerView.
```APIDOC
## GET /getSelectedSubPosition
### Description
Retrieves the current selected sub position within the DPadRecyclerView. Returns 0 if no sub-position is currently selected.
### Method
GET
### Endpoint
/getSelectedSubPosition
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **subPosition** (Int) - The current selected sub position, or 0 if none is selected.
#### Response Example
```json
{
"subPosition": 2
}
```
```
--------------------------------
### Styling and Attribute Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-scrollable-layout/index.html
Methods for setting background properties and view attributes.
```APIDOC
## setBackgroundColor
### Description
Sets the background color of the view.
### Parameters
- **color** (Int) - Required - The color integer to apply.
```
--------------------------------
### GET /DpadLoopDirection/entries
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-loop-direction/entries.html
Retrieves an immutable list of all enum entries for DpadLoopDirection in their declared order.
```APIDOC
## GET /DpadLoopDirection/entries
### Description
Returns a representation of an immutable list of all enum entries for DpadLoopDirection, in the order they are declared. This is primarily used for iterating over the enum values.
### Method
GET
### Endpoint
/DpadLoopDirection/entries
### Response
#### Success Response (200)
- **entries** (EnumEntries) - An immutable list of all enum entries.
```
--------------------------------
### DpadViewActions Utility Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-testing/com.rubensousa.dpadrecyclerview.testing.actions/-dpad-view-actions/index.html
A collection of static methods to perform common view operations like focus management and bounds retrieval.
```APIDOC
## DpadViewActions Methods
### clearFocus
- **Description**: Clears focus from the current view. Note: This only works if another view in the hierarchy can take focus.
- **Method**: @JvmStatic
### getRelativeViewBounds
- **Description**: Retrieves the relative bounds of the view.
- **Parameters**: rect (Rect) - The rectangle to store the bounds.
### getViewBounds
- **Description**: Retrieves the absolute bounds of the view.
- **Parameters**: rect (Rect) - The rectangle to store the bounds.
### requestFocus
- **Description**: Requests focus for the target view.
- **Method**: @JvmStatic
### waitForCondition
- **Description**: Waits for a specific condition to be met by the view.
- **Parameters**:
- **description** (String) - Description of the condition.
- **condition** ((view: T) -> Boolean) - The predicate to evaluate.
- **timeout** (Long) - Optional, default 2.
- **timeoutUnit** (TimeUnit) - Optional, default TimeUnit.SECONDS.
```
--------------------------------
### DpadSelectionSnapHelper Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-selection-snap-helper/index.html
Core methods for managing snapping behavior and RecyclerView attachment.
```APIDOC
## Methods
### attachToRecyclerView
- **recyclerView** (RecyclerView?) - The RecyclerView to attach the helper to.
### calculateDistanceToFinalSnap
- **layoutManager** (RecyclerView.LayoutManager) - The layout manager.
- **targetView** (View) - The view to snap to.
### calculateScrollDistance
- **velocityX** (Int) - Velocity in X direction.
- **velocityY** (Int) - Velocity in Y direction.
### findSnapView
- **layoutManager** (RecyclerView.LayoutManager) - The layout manager to find the snap view in.
### findTargetSnapPosition
- **layoutManager** (RecyclerView.LayoutManager?) - The layout manager.
- **velocityX** (Int) - Velocity in X.
- **velocityY** (Int) - Velocity in Y.
### onFling
- **velocityX** (Int) - Velocity in X.
- **velocityY** (Int) - Velocity in Y.
```
--------------------------------
### Adapter and State Management
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/index.html
Methods for setting the adapter, saving hierarchy state, and scheduling drawables.
```APIDOC
## POST /setAdapter
### Description
Sets the adapter for the RecyclerView.
### Method
POST
### Endpoint
/setAdapter
### Parameters
#### Request Body
- **adapter** (Object) - Required - The RecyclerView adapter to set.
### Request Example
```json
{
"adapter": { "type": "MyAdapter" }
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the adapter was set successfully.
#### Response Example
```json
{
"message": "Adapter set successfully"
}
```
## POST /saveHierarchyState
### Description
Saves the hierarchy state of the RecyclerView.
### Method
POST
### Endpoint
/saveHierarchyState
### Parameters
#### Request Body
- **container** (Object) - Required - A SparseArray to hold the saved state.
### Request Example
```json
{
"container": { "type": "SparseArray" }
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the hierarchy state was saved successfully.
#### Response Example
```json
{
"message": "Hierarchy state saved successfully"
}
```
## POST /scheduleDrawable
### Description
Schedules a drawable to be run.
### Method
POST
### Endpoint
/scheduleDrawable
### Parameters
#### Request Body
- **who** (Object) - Required - The Drawable to schedule.
- **what** (Object) - Required - The Runnable to execute.
- **when** (Long) - Required - The time at which to execute the Runnable.
### Request Example
```json
{
"who": { "type": "Drawable" },
"what": { "type": "Runnable" },
"when": 1678886400000
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the drawable was scheduled successfully.
#### Response Example
```json
{
"message": "Drawable scheduled successfully"
}
```
```
--------------------------------
### DpadSelectionSnapHelper Constructor
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-selection-snap-helper/-dpad-selection-snap-helper.html
Initializes the DpadSelectionSnapHelper with configuration for scroll-based selection updates.
```APIDOC
## Constructor DpadSelectionSnapHelper
### Description
Initializes a new instance of DpadSelectionSnapHelper to manage selection snapping behavior in a DpadRecyclerView.
### Parameters
#### Constructor Parameters
- **updateSelectionOnScrollChanges** (Boolean) - Optional (Default: true) - If true, the selection will automatically update based on the scrolling target view; if false, it will not.
```
--------------------------------
### ExtraLayoutSpaceStrategy Interface
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-extra-layout-space-strategy/index.html
Defines methods to calculate extra layout space at the start and end of a RecyclerView.
```APIDOC
## Interface ExtraLayoutSpaceStrategy
### Description
Overrides the default mechanism for laying out extra views at the borders of the RecyclerView. Check `LinearLayoutManager.calculateExtraLayoutSpace` for more details. By default, DpadRecyclerView will not layout any extra space to minimise the number of views in memory.
### Members
#### Functions
##### calculateEndExtraLayoutSpace
```kotlin
open fun calculateEndExtraLayoutSpace(state: RecyclerView.State): Int
```
Calculates the extra space that should be laid out (in pixels) at the end of the RecyclerView.
##### calculateStartExtraLayoutSpace
```kotlin
open fun calculateStartExtraLayoutSpace(state: RecyclerView.State): Int
```
Calculates the extra space that should be laid out (in pixels) at the start of the RecyclerView.
```
--------------------------------
### Focus and Navigation Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-scrollable-layout/index.html
Methods for handling view focus, scrolling, and input requests.
```APIDOC
## scrollHeaderTo
### Description
Scrolls the header to a specific offset.
### Parameters
- **topOffset** (Int) - Required - The vertical offset to scroll to.
- **smooth** (Boolean) - Optional - Whether to perform a smooth scroll (default: true).
```
--------------------------------
### Styling
Source: https://rubensousa.github.io/DpadRecyclerView/xml
How to apply default or individual styles to D-Pad RecyclerView.
```APIDOC
## Styling
### Description
How to apply default or individual styles to D-Pad RecyclerView.
### Default Style in Theme
Apply a default style in your theme:
```xml
```
### Individual Styles
Create individual styles for specific configurations:
```xml
```
```
--------------------------------
### Performing DpadRecyclerView actions
Source: https://rubensousa.github.io/DpadRecyclerView/testing
Example of using DpadRecyclerViewActions to scroll to a specific item within a RecyclerView.
```kotlin
Espresso.onView(withId(R.id.recyclerView))
.perform(DpadRecyclerViewActions.scrollTo(
hasDescendant(withText("Some title"))
))
```
--------------------------------
### View Properties and State
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/index.html
Methods for setting various view properties like background, focus, and autofill hints.
```APIDOC
## POST /setAddStatesFromChildren
### Description
Sets whether the view should add states from its children.
### Method
POST
### Endpoint
/setAddStatesFromChildren
### Parameters
#### Query Parameters
- **addsStates** (Boolean) - Required - True to add states from children, false otherwise.
### Request Example
```json
{
"addsStates": true
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the setting was updated.
#### Response Example
```json
{
"message": "Add states from children setting updated"
}
```
## POST /setAllowClickWhenDisabled
### Description
Sets whether clicks are allowed even when the view is disabled.
### Method
POST
### Endpoint
/setAllowClickWhenDisabled
### Parameters
#### Query Parameters
- **clickableWhenDisabled** (Boolean) - Required - True to allow clicks when disabled, false otherwise.
### Request Example
```json
{
"clickableWhenDisabled": true
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the setting was updated.
#### Response Example
```json
{
"message": "Allow click when disabled setting updated"
}
```
## POST /setAllowedHandwritingDelegatePackage
### Description
Sets the allowed package name for the handwriting delegate.
### Method
POST
### Endpoint
/setAllowedHandwritingDelegatePackage
### Parameters
#### Query Parameters
- **allowedPackageName** (String) - Optional - The package name to allow.
### Request Example
```json
{
"allowedPackageName": "com.example.handwriting"
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the allowed handwriting delegate package was set.
#### Response Example
```json
{
"message": "Allowed handwriting delegate package set"
}
```
## POST /setAllowedHandwritingDelegatorPackage
### Description
Sets the allowed package name for the handwriting delegator.
### Method
POST
### Endpoint
/setAllowedHandwritingDelegatorPackage
### Parameters
#### Query Parameters
- **allowedPackageName** (String) - Optional - The package name to allow.
### Request Example
```json
{
"allowedPackageName": "com.example.delegator"
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the allowed handwriting delegator package was set.
#### Response Example
```json
{
"message": "Allowed handwriting delegator package set"
}
```
## POST /setAutofillHints
### Description
Sets the autofill hints for the view.
### Method
POST
### Endpoint
/setAutofillHints
### Parameters
#### Query Parameters
- **autofillHints** (Array of Strings) - Optional - The autofill hints to set.
### Request Example
```json
{
"autofillHints": ["username", "email"]
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the autofill hints were set successfully.
#### Response Example
```json
{
"message": "Autofill hints set successfully"
}
```
## POST /setBackgroundColor
### Description
Sets the background color of the view.
### Method
POST
### Endpoint
/setBackgroundColor
### Parameters
#### Query Parameters
- **color** (Int) - Required - The color value.
### Request Example
```json
{
"color": -16777216
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the background color was set successfully.
#### Response Example
```json
{
"message": "Background color set successfully"
}
```
## POST /setBackgroundResource
### Description
Sets the background of the view to a given resource.
### Method
POST
### Endpoint
/setBackgroundResource
### Parameters
#### Query Parameters
- **resid** (Int) - Required - The resource ID for the background.
### Request Example
```json
{
"resid": 2131034113
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the background resource was set successfully.
#### Response Example
```json
{
"message": "Background resource set successfully"
}
```
## POST /setGravity
### Description
Sets the gravity for the view.
### Method
POST
### Endpoint
/setGravity
### Parameters
#### Query Parameters
- **gravity** (Int) - Required - The gravity value.
### Request Example
```json
{
"gravity": 1
}
```
### Response
#### Success Response (200)
- **message** (String) - Indicates the gravity was set successfully.
#### Response Example
```json
{
"message": "Gravity set successfully"
}
```
```
--------------------------------
### DpadViewHolderState Methods
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.state/-dpad-view-holder-state/index.html
Methods for managing the lifecycle of ViewHolder state persistence.
```APIDOC
## saveState
### Description
Saves the view hierarchy state of a RecyclerView.ViewHolder.
### Parameters
- **holder** (RecyclerView.ViewHolder) - Required - The ViewHolder to save.
- **key** (String) - Required - The unique identifier for the state.
## restoreState
### Description
Restores the view hierarchy state to a RecyclerView.ViewHolder.
### Parameters
- **holder** (RecyclerView.ViewHolder) - Required - The ViewHolder to restore.
- **key** (String) - Required - The unique identifier for the state.
- **consume** (Boolean) - Optional - Whether to consume the state after restoration (default: false).
## clear
### Description
Clears ViewHolder states to prevent them from being restored.
### Parameters
- **key** (String) - Optional - The specific key to clear. If omitted, all states are cleared.
```
--------------------------------
### Get DpadLoopDirection Enum Values
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-loop-direction/values.html
This snippet shows how to retrieve an array containing all constants of the DpadLoopDirection enum.
```APIDOC
## Get DpadLoopDirection Enum Values
### Description
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.
### Method
GET
### Endpoint
/values
### Parameters
None
### Request Example
None
### Response
#### Success Response (200)
- **values** (Array) - An array containing all enum constants.
```
--------------------------------
### shouldApplySpacing Method
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.spacing/-dpad-spacing-lookup/should-apply-spacing.html
Determines if spacing should be applied to a ViewHolder.
```APIDOC
## shouldApplySpacing
abstract fun shouldApplySpacing( viewHolder: RecyclerView.ViewHolder, itemCount: Int): Boolean
### Description
Determines if the ViewHolder should have spacing applied to it.
### Method
ABSTRACT FUNCTION
### Parameters
#### Path Parameters
- **viewHolder** (RecyclerView.ViewHolder) - Required - The ViewHolder currently in layout.
- **itemCount** (Int) - Required - The item count at the layout stage. See RecyclerView.State.getItemCount.
### Response
#### Success Response (Boolean)
- **true** - Indicates that spacing should be applied.
- **false** - Indicates that spacing should not be applied.
```
--------------------------------
### STANDARD Navigation
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-focusable-direction/-s-t-a-n-d-a-r-d/index.html
Explains the default directional focus behavior for DPadRecyclerView.
```APIDOC
## STANDARD Navigation
### Description
Focus goes to the next left, top, right or bottom view available.
### Method
N/A (Describes behavior, not an API call)
### Endpoint
N/A
```
--------------------------------
### onItemsAdded Callback
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.layoutmanager/-pivot-layout-manager/on-items-added.html
This callback is invoked when items are added to the DPadRecyclerView. It provides the starting position and the number of items added.
```APIDOC
## onItemsAdded
### Description
This method is called when new items are added to the RecyclerView. It provides information about the range of newly added items.
### Method
open override fun
### Endpoint
N/A (Callback Method)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
N/A
### Response
#### Success Response (N/A)
This is a callback method and does not return a value.
#### Response Example
N/A
### Parameters
- **recyclerView** (RecyclerView) - The RecyclerView instance where items were added.
- **positionStart** (Int) - The starting index of the newly added items.
- **itemCount** (Int) - The total number of items that were added.
```
--------------------------------
### DpadViewAssertions - Focus Assertions
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-testing/com.rubensousa.dpadrecyclerview.testing.assertions/-dpad-view-assertions/index.html
Provides static functions to create ViewAssertions for checking the focus state of D-pad views.
```APIDOC
## DpadViewAssertions
Provides static functions to create ViewAssertions for checking the focus state of D-pad views.
### Functions
#### `doesNotHaveFocus()`
Creates a `ViewAssertion` that asserts the view does not have focus.
- **Method**: N/A (Static function returning a ViewAssertion)
- **Endpoint**: N/A
#### `hasFocus()`
Creates a `ViewAssertion` that asserts the view has focus.
- **Method**: N/A (Static function returning a ViewAssertion)
- **Endpoint**: N/A
#### `isFocused()`
Creates a `ViewAssertion` that asserts the view is focused.
- **Method**: N/A (Static function returning a ViewAssertion)
- **Endpoint**: N/A
#### `isNotFocused()`
Creates a `ViewAssertion` that asserts the view is not focused.
- **Method**: N/A (Static function returning a ViewAssertion)
- **Endpoint**: N/A
### Request Example
```kotlin
// Example usage within an Android testing framework
dpadView.assertThat(R.id.my_dpad_view).doesNotHaveFocus()
dpadView.assertThat(R.id.my_dpad_view).hasFocus()
dpadView.assertThat(R.id.my_dpad_view).isFocused()
dpadView.assertThat(R.id.my_dpad_view).isNotFocused()
```
### Response
These functions return `ViewAssertion` objects, which are used within testing frameworks to perform assertions on views. They do not have direct request/response bodies in the typical API sense.
```
--------------------------------
### GET /focusSearchDebounceMs
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview/-dpad-recycler-view/get-focus-search-debounce-ms.html
Retrieves the current debounce time in milliseconds for focus search operations. Returns null if debouncing is disabled.
```APIDOC
## GET /focusSearchDebounceMs
### Description
Retrieves the value set in `setFocusSearchDebounceMs` or null if debouncing is disabled.
### Method
GET
### Endpoint
/focusSearchDebounceMs
### Response
#### Success Response (200)
- **return_value** (Int?) - The debounce time in milliseconds, or null if disabled.
```
--------------------------------
### DpadLayoutParams Constructors
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.layoutmanager/-dpad-layout-params/index.html
Provides information on the different ways to construct a DpadLayoutParams object.
```APIDOC
## DpadLayoutParams Constructors
### Description
Constructors for creating DpadLayoutParams instances.
### Constructors
- **DpadLayoutParams**(context: Context, attrs: AttributeSet)
- Description: Creates a DpadLayoutParams with the given context and attributes.
- **DpadLayoutParams**(width: Int, height: Int)
- Description: Creates a DpadLayoutParams with the specified width and height.
- **DpadLayoutParams**(source: ViewGroup.MarginLayoutParams)
- Description: Creates a DpadLayoutParams by copying margin parameters from a ViewGroup.MarginLayoutParams.
- **DpadLayoutParams**(source: ViewGroup.LayoutParams)
- Description: Creates a DpadLayoutParams by copying parameters from a ViewGroup.LayoutParams.
- **DpadLayoutParams**(source: RecyclerView.LayoutParams)
- Description: Creates a DpadLayoutParams by copying parameters from a RecyclerView.LayoutParams.
- **DpadLayoutParams**(source: DpadLayoutParams)
- Description: Creates a DpadLayoutParams by copying parameters from another DpadLayoutParams instance.
```
--------------------------------
### onItemsRemoved Callback
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview/com.rubensousa.dpadrecyclerview.layoutmanager/-pivot-layout-manager/on-items-removed.html
This callback is invoked when items are removed from the RecyclerView managed by DPadRecyclerView. It provides the starting position and the number of items removed.
```APIDOC
## onItemsRemoved
### Description
Callback invoked when items are removed from the RecyclerView.
### Method
open override fun
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
None
### Response
#### Success Response (200)
None
#### Response Example
None
### Parameters
- **recyclerView** (RecyclerView) - The RecyclerView from which items were removed.
- **positionStart** (Int) - The starting position of the removed items.
- **itemCount** (Int) - The total number of items removed.
```
--------------------------------
### Dispatching key events with KeyEvents
Source: https://rubensousa.github.io/DpadRecyclerView/testing
Utility methods for simulating key presses with optional delays.
```kotlin
KeyEvents.click()
KeyEvents.back()
KeyEvents.pressDown(times = 5)
// 50 ms between each key press
KeyEvents.pressUp(times = 5, delay = 50)
```
--------------------------------
### pressKey Method
Source: https://rubensousa.github.io/DpadRecyclerView/api/dpadrecyclerview-testing/com.rubensousa.dpadrecyclerview.testing/-key-events/press-key.html
Simulates a key press event with configurable repetition and delay.
```APIDOC
## pressKey
### Description
Simulates a key press event on the DPadRecyclerView. This method is static and allows for multiple key presses with a specified delay between them.
### Parameters
- **key** (Int) - Required - The key code to be pressed.
- **times** (Int) - Optional - The number of times to press the key. Defaults to 1.
- **delay** (Long) - Optional - The delay in milliseconds between key presses. Defaults to DEFAULT_KEY_PRESS_DELAY.
```
--------------------------------
### Create DpadDragHelper Instance
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/dragdrop
Instantiate DpadDragHelper with your DragAdapter and a DragCallback to handle drag events. The callback provides methods for when dragging starts and stops.
```java
private val adapter = ExampleAdapter()
private val dragHelper = DpadDragHelper(
adapter = dragAdapter,
callback = object : DpadDragHelper.DragCallback {
override fun onDragStarted(viewHolder: RecyclerView.ViewHolder) {
// ViewHolder is now being dragged
}
override fun onDragStopped(fromUser: Boolean) {
// Dragging was cancelled either by user or programmatically
}
}
)
```
--------------------------------
### Start Drag Operation
Source: https://rubensousa.github.io/DpadRecyclerView/recipes/dragdrop
Initiate a drag operation programmatically by calling startDrag with the desired item position. If the item is not selected, a selection will be triggered first.
```kotlin
dragHelper.startDrag(position = 0)
```