Add button to navigate to random item (#1916)

## Description
Adds a random button on library tab/grid pages which navigates to a
random item in the list. This goes to the item's detail page.

The random item is chosen with the filters applied. So you could filter
by unplayed Action movies with 7+ stars and the random button will
select from those movies.

Pressing back restores focus on the random button so it's easy to
quickly retry.

### Related issues
Closes #838

### Testing
Emulator

## Screenshots
<img width="935" height="105" alt="image"
src="https://github.com/user-attachments/assets/170b495c-b47d-41ce-93b5-99831f2064c7"
/>
<img width="936" height="114" alt="image"
src="https://github.com/user-attachments/assets/3efa6a11-ebe8-42d7-b023-354b1e6eda37"
/>



## AI or LLM usage
None
This commit is contained in:
Damontecres 2026-09-01 16:07:26 -04:00 • committed by GitHub
parent 5363db0b80
commit cedca9b2b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 134 additions and 39 deletions

View file

@ -2,6 +2,7 @@ package com.github.damontecres.wholphin.util
import java.util.function.IntFunction
import java.util.function.Predicate
import kotlin.random.Random
/**
* A [List] which has function that will wait for a result
@ -17,6 +18,11 @@ interface BlockingList<T> : List<T> {
*/
suspend fun indexOfBlocking(predicate: Predicate<T>): Int
suspend fun randomBlocking(): T {
val index = Random.nextInt(size)
return getBlocking(index)
}
companion object {
/**
* Create a [BlockingList] over a regular [List]