crash fixes

This commit is contained in:
LagradOst 2022-06-22 03:20:10 +02:00
parent 1a5439143c
commit 81113ea436
3 changed files with 29 additions and 18 deletions

View File

@ -518,7 +518,7 @@ class GeneratorPlayer : FullScreenPlayer() {
val subsArrayAdapter =
ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice)
subsArrayAdapter.add(getString(R.string.no_subtitles))
subsArrayAdapter.add(ctx.getString(R.string.no_subtitles))
subsArrayAdapter.addAll(currentSubtitles.map { it.name })
subtitleList.adapter = subsArrayAdapter
@ -838,20 +838,22 @@ class GeneratorPlayer : FullScreenPlayer() {
tvType = meta.tvType
}
}
//Generate video title
val playerVideoTitle = if (headerName != null) {
(headerName +
if (tvType.isEpisodeBased() && episode != null)
if (season == null)
" - ${getString(R.string.episode)} $episode"
else
" \"${getString(R.string.season_short)}${season}:${getString(R.string.episode_short)}${episode}\""
else "") + if (subName.isNullOrBlank() || subName == headerName) "" else " - $subName"
} else {
""
context?.let { ctx ->
//Generate video title
val playerVideoTitle = if (headerName != null) {
(headerName +
if (tvType.isEpisodeBased() && episode != null)
if (season == null)
" - ${ctx.getString(R.string.episode)} $episode"
else
" \"${ctx.getString(R.string.season_short)}${season}:${ctx.getString(R.string.episode_short)}${episode}\""
else "") + if (subName.isNullOrBlank() || subName == headerName) "" else " - $subName"
} else {
""
}
return playerVideoTitle
}
return playerVideoTitle
return ""
}
@ -933,8 +935,8 @@ class GeneratorPlayer : FullScreenPlayer() {
context?.let { ctx ->
val settingsManager = PreferenceManager.getDefaultSharedPreferences(ctx)
titleRez = settingsManager.getInt(getString(R.string.prefer_limit_title_rez_key), 3)
limitTitle = settingsManager.getInt(getString(R.string.prefer_limit_title_key), 0)
titleRez = settingsManager.getInt(ctx.getString(R.string.prefer_limit_title_rez_key), 3)
limitTitle = settingsManager.getInt(ctx.getString(R.string.prefer_limit_title_key), 0)
updateForcedEncoding(ctx)
}

View File

@ -1,5 +1,6 @@
package com.lagradost.cloudstream3.ui.result
import android.content.Context
import android.content.res.Configuration
import android.graphics.Rect
import android.os.Bundle
@ -73,6 +74,9 @@ open class ResultTrailerPlayer : com.lagradost.cloudstream3.ui.player.FullScreen
fixPlayerSize()
}
override fun showMirrorsDialogue() {}
override fun openOnlineSubPicker(context: Context, imdbId: Long?, dismissCallback: () -> Unit) {}
override fun subtitlesChanged() {}
override fun embeddedSubtitlesFetched(subtitles: List<SubtitleData>) {}

View File

@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.SyncApis
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
@ -234,11 +235,15 @@ class SyncViewModel : ViewModel() {
_metaResponse.postValue(Resource.Loading())
var lastError: Resource<SyncAPI.SyncResult> = Resource.Failure(false, null, null, "No data")
val current = syncs.toList()
val current = ArrayList(syncs.toList())
// shitty way to sort anilist first, as it has trailers while mal does not
if (syncs.containsKey(aniListApi.idPrefix)) {
Collections.swap(current, current.indexOfFirst { it.first == aniListApi.idPrefix }, 0)
try { // swap can throw error
Collections.swap(current, current.indexOfFirst { it.first == aniListApi.idPrefix }, 0)
} catch (e : Exception) {
logError(e)
}
}
current.forEach { (prefix, id) ->