Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,6 @@ class GeneratorPlayer : FullScreenPlayer() {

val subsArrayAdapter =
ArrayAdapter<Spanned>(ctx, R.layout.sort_bottom_single_choice)
subsArrayAdapter.add(ctx.getString(R.string.no_subtitles).html())

val subtitlesGrouped =
currentSubtitles.groupBy { it.originalName }.map { (key, value) ->
Expand All @@ -1173,7 +1172,7 @@ class GeneratorPlayer : FullScreenPlayer() {
val subtitles = subtitlesGrouped.map { it.key.html() }

val subtitleGroupIndexStart =
subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName) + 1
subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName)
var subtitleGroupIndex = subtitleGroupIndexStart

val subtitleOptionIndexStart =
Expand All @@ -1182,6 +1181,7 @@ class GeneratorPlayer : FullScreenPlayer() {
var subtitleOptionIndex = subtitleOptionIndexStart

subsArrayAdapter.addAll(subtitles)
subsArrayAdapter.add(ctx.getString(R.string.no_subtitles).html())

subtitleList.adapter = subsArrayAdapter
subtitleList.choiceMode = AbsListView.CHOICE_MODE_SINGLE
Expand All @@ -1200,7 +1200,7 @@ class GeneratorPlayer : FullScreenPlayer() {

val subtitleOptions =
subtitlesGroupedList
.getOrNull(subtitleGroupIndex - 1)?.value?.map { subtitle ->
.getOrNull(subtitleGroupIndex)?.value?.map { subtitle ->
val nameSuffix = subtitle.nameSuffix.html()
nameSuffix.ifBlank {
when (subtitle.origin) {
Expand Down Expand Up @@ -1252,7 +1252,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}

subtitleOptionList.setOnItemClickListener { _, _, which, _ ->
if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.size
if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.size
?: -1)
) {
val child = subtitleOptionList.adapter.getView(which, null, subtitleList)
Expand Down Expand Up @@ -1337,10 +1337,10 @@ class GeneratorPlayer : FullScreenPlayer() {
binding.applyBtt.setOnClickListener {
var init = sourceIndex != startSource
if (subtitleGroupIndex != subtitleGroupIndexStart || subtitleOptionIndex != subtitleOptionIndexStart) {
init = init or if (subtitleGroupIndex <= 0) {
init = init or if (subtitleGroupIndex >= subtitlesGrouped.size) {
noSubtitles()
} else {
subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.getOrNull(
subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.getOrNull(
subtitleOptionIndex
)?.let {
setSubtitles(it, true)
Expand Down