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:
parent
5363db0b80
commit
cedca9b2b1
5 changed files with 134 additions and 39 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue