Skip to content

Commit

Permalink
Fix subtitle menu not always showing "None" as first item
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Nov 11, 2024
1 parent f969f01 commit ae19a4c
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ class ClosedCaptionsAction(
videoPlayerAdapter.leanbackOverlayFragment.setFading(false)
PopupMenu(context, view, Gravity.END).apply {
with(menu) {
var order = 0
add(0, -1, order++, context.getString(R.string.lbl_none)).apply {
isChecked = playbackController.subtitleStreamIndex == -1
}

for (sub in playbackController.currentMediaSource.mediaStreams.orEmpty()) {
if (sub.type != MediaStreamType.SUBTITLE) continue

add(0, sub.index, sub.index, sub.displayTitle).apply {
add(0, sub.index, order++, sub.displayTitle).apply {
isChecked = sub.index == playbackController.subtitleStreamIndex
}
}

add(0, -1, 0, context.getString(R.string.lbl_none)).apply {
isChecked = playbackController.subtitleStreamIndex == -1
}

setGroupCheckable(0, true, false)
}
setOnDismissListener { videoPlayerAdapter.leanbackOverlayFragment.setFading(true) }
Expand Down

0 comments on commit ae19a4c

Please sign in to comment.