Probable fix for Fire TV home provider categories selection

This commit is contained in:
Blatzar 2022-09-25 00:21:58 +02:00
parent 2a6d20cab4
commit 3bea7f01ef

View file

@ -352,11 +352,25 @@ class HomeFragment : Fragment() {
arrayAdapter.notifyDataSetChanged() arrayAdapter.notifyDataSetChanged()
} }
/**
* Since fire tv is fucked we need to manually define the focus layout.
* Since visible buttons are only known in runtime this is required.
**/
var lastButton: MaterialButton? = null
for ((button, validTypes) in pairList) { for ((button, validTypes) in pairList) {
val isValid = val isValid =
validAPIs.any { api -> validTypes.any { api.supportedTypes.contains(it) } } validAPIs.any { api -> validTypes.any { api.supportedTypes.contains(it) } }
button?.isVisible = isValid button?.isVisible = isValid
if (isValid) { if (isValid) {
// Set focus navigation
button?.let { currentButton ->
lastButton?.nextFocusRightId = currentButton.id
lastButton?.id?.let { currentButton.nextFocusLeftId = it }
lastButton = currentButton
}
fun buttonContains(): Boolean { fun buttonContains(): Boolean {
return preSelectedTypes.any { validTypes.contains(it) } return preSelectedTypes.any { validTypes.contains(it) }
} }