fixed tv issue and cross-provider cache

This commit is contained in:
LagradOst 2022-05-28 16:52:36 +02:00
parent 57128dbc7d
commit 45a7977a53
2 changed files with 5 additions and 4 deletions

View file

@ -15,7 +15,7 @@ class RepoLinkGenerator(
) : IGenerator { ) : IGenerator {
companion object { companion object {
const val TAG = "RepoLink" const val TAG = "RepoLink"
val cache: HashMap<Int, Pair<MutableSet<ExtractorLink>, MutableSet<SubtitleData>>> = hashMapOf() val cache: HashMap<Pair<String, Int>, Pair<MutableSet<ExtractorLink>, MutableSet<SubtitleData>>> = hashMapOf()
} }
override val hasCache = true override val hasCache = true
@ -71,7 +71,7 @@ class RepoLinkGenerator(
val (currentLinkCache, currentSubsCache) = if (clearCache) { val (currentLinkCache, currentSubsCache) = if (clearCache) {
Pair(mutableSetOf(), mutableSetOf()) Pair(mutableSetOf(), mutableSetOf())
} else { } else {
cache[current.id] ?: Pair(mutableSetOf(), mutableSetOf()) cache[Pair(current.apiName, current.id)] ?: Pair(mutableSetOf(), mutableSetOf())
} }
//val currentLinkCache = if (clearCache) mutableSetOf() else linkCache[index].toMutableSet() //val currentLinkCache = if (clearCache) mutableSetOf() else linkCache[index].toMutableSet()
@ -137,7 +137,7 @@ class RepoLinkGenerator(
} }
} }
) )
cache[current.id] = Pair(currentLinkCache, currentSubsCache) cache[Pair(current.apiName, current.id)] = Pair(currentLinkCache, currentSubsCache)
return result return result
} }

View file

@ -75,9 +75,10 @@ class SettingsFragment : Fragment() {
private fun Context.isAutoTv(): Boolean { private fun Context.isAutoTv(): Boolean {
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager? val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager?
// AFT = Fire TV // AFT = Fire TV
val model = Build.MODEL.lowercase()
return uiModeManager?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION || Build.MODEL.contains( return uiModeManager?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION || Build.MODEL.contains(
"AFT" "AFT"
) ) || model.contains("firestick") || model.contains("fire tv") || model.contains("chromecast")
} }
} }