AnimePahe: Fix lag for some people (#1335)

This commit is contained in:
Secozzi
2023-02-26 21:32:54 +01:00
committed by GitHub
parent 34a2bdc7ff
commit aab558292b
2 changed files with 18 additions and 1 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'AnimePahe'
pkgNameSuffix = 'en.animepahe'
extClass = '.AnimePahe'
extVersionCode = 19
extVersionCode = 20
libVersion = '13'
}

View File

@ -111,6 +111,7 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
for (item in array) {
val anime = SAnime.create()
anime.title = item.jsonObject["title"]!!.jsonPrimitive.content
anime.thumbnail_url = item.jsonObject["poster"]!!.jsonPrimitive.content
val animeId = item.jsonObject["id"]!!.jsonPrimitive.int
anime.setUrlWithoutDomain("$baseUrl/anime/?anime_id=$animeId")
animeList.add(anime)
@ -136,6 +137,9 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
for (item in array) {
val anime = SAnime.create()
anime.title = item.jsonObject["anime_title"]!!.jsonPrimitive.content
if (preferences.getBoolean("preferred_cover_type", false)) {
anime.thumbnail_url = item.jsonObject["snapshot"]!!.jsonPrimitive.content
}
val animeId = item.jsonObject["anime_id"]!!.jsonPrimitive.int
anime.setUrlWithoutDomain("$baseUrl/anime/?anime_id=$animeId")
anime.artist = item.jsonObject["fansub"]!!.jsonPrimitive.content
@ -317,9 +321,22 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
preferences.edit().putBoolean(key, new).commit()
}
}
val snapshotPref = SwitchPreferenceCompat(screen.context).apply {
key = "preferred_cover_type"
title = "Use Snapshot as Cover"
summary = """Enable this if you are experiencing lag loading pages.
|To get real cover click on the anime to fetch the details""".trimMargin()
setDefaultValue(false)
setOnPreferenceChangeListener { _, newValue ->
val new = newValue as Boolean
preferences.edit().putBoolean(key, new).commit()
}
}
screen.addPreference(videoQualityPref)
screen.addPreference(domainPref)
screen.addPreference(subPref)
screen.addPreference(linkPref)
screen.addPreference(snapshotPref)
}
}