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

View file

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

View file

@ -7,6 +7,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.lagradost.cloudstream3.apmap import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.mvvm.Resource 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.SyncApis
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
@ -234,11 +235,15 @@ class SyncViewModel : ViewModel() {
_metaResponse.postValue(Resource.Loading()) _metaResponse.postValue(Resource.Loading())
var lastError: Resource<SyncAPI.SyncResult> = Resource.Failure(false, null, null, "No data") 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 // shitty way to sort anilist first, as it has trailers while mal does not
if (syncs.containsKey(aniListApi.idPrefix)) { 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) -> current.forEach { (prefix, id) ->