Skip to content

Commit eab2b07

Browse files
committed
Move 'No Subtitles' option to bottom of subtitle list
- Moved 'No Subtitles' from top to bottom of adapter - Adjusted subtitle index calculations (removed +1 offset) - Changed condition from <= 0 to >= size for detecting no subtitle selection
1 parent 8e71bae commit eab2b07

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,6 @@ class GeneratorPlayer : FullScreenPlayer() {
11621162

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

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

11751174
val subtitleGroupIndexStart =
1176-
subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName) + 1
1175+
subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName)
11771176
var subtitleGroupIndex = subtitleGroupIndexStart
11781177

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

11841183
subsArrayAdapter.addAll(subtitles)
1184+
subsArrayAdapter.add(ctx.getString(R.string.no_subtitles).html())
11851185

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

12011201
val subtitleOptions =
12021202
subtitlesGroupedList
1203-
.getOrNull(subtitleGroupIndex - 1)?.value?.map { subtitle ->
1203+
.getOrNull(subtitleGroupIndex)?.value?.map { subtitle ->
12041204
val nameSuffix = subtitle.nameSuffix.html()
12051205
nameSuffix.ifBlank {
12061206
when (subtitle.origin) {
@@ -1252,7 +1252,7 @@ class GeneratorPlayer : FullScreenPlayer() {
12521252
}
12531253

12541254
subtitleOptionList.setOnItemClickListener { _, _, which, _ ->
1255-
if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.size
1255+
if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.size
12561256
?: -1)
12571257
) {
12581258
val child = subtitleOptionList.adapter.getView(which, null, subtitleList)
@@ -1337,10 +1337,10 @@ class GeneratorPlayer : FullScreenPlayer() {
13371337
binding.applyBtt.setOnClickListener {
13381338
var init = sourceIndex != startSource
13391339
if (subtitleGroupIndex != subtitleGroupIndexStart || subtitleOptionIndex != subtitleOptionIndexStart) {
1340-
init = init or if (subtitleGroupIndex <= 0) {
1340+
init = init or if (subtitleGroupIndex >= subtitlesGrouped.size) {
13411341
noSubtitles()
13421342
} else {
1343-
subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.getOrNull(
1343+
subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.getOrNull(
13441344
subtitleOptionIndex
13451345
)?.let {
13461346
setSubtitles(it, true)

0 commit comments

Comments
 (0)