diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt index a032cbb82..dd5d9410d 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMH.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.multisrc.sinmh +import android.util.Log import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList @@ -120,6 +121,21 @@ abstract class SinMH( } private lateinit var categories: List + private var isFetchingCategories = false + + private fun tryFetchCategories() { + if (isFetchingCategories) return + isFetchingCategories = true + thread { + try { + fetchCategories() + } catch (e: Exception) { + Log.e("SinMH", "Failed to fetch categories ($e)") + } finally { + isFetchingCategories = false + } + } + } protected open fun fetchCategories() { val document = client.newCall(GET("$baseUrl/list/", headers)).execute().asJsoup() @@ -133,16 +149,17 @@ abstract class SinMH( } init { - thread { - fetchCategories() - } + tryFetchCategories() } override fun getFilterList() = if (::categories.isInitialized) FilterList( Filter.Header("如果使用文本搜索,将会忽略分类筛选"), *categories.map(Category::toUriPartFilter).toTypedArray() - ) else FilterList( - Filter.Header("分类尚未获取,请返回上一页后重试") - ) + ) else { + tryFetchCategories() + FilterList( + Filter.Header("分类尚未获取,请返回上一页后重试") + ) + } } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt index 27eb3c0fa..cd0929b94 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/sinmh/SinMHGenerator.kt @@ -6,7 +6,7 @@ import generator.ThemeSourceGenerator class SinMHGenerator : ThemeSourceGenerator { override val themeClass = "SinMH" override val themePkg = "sinmh" - override val baseVersionCode = 1 + override val baseVersionCode = 2 override val sources = listOf( SingleLang( name = "Gufeng Manhua", baseUrl = "https://www.gufengmh9.com", lang = "zh", diff --git a/src/ja/mangacross/build.gradle b/src/ja/mangacross/build.gradle index 1d9ee00db..f29c4a904 100644 --- a/src/ja/mangacross/build.gradle +++ b/src/ja/mangacross/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Manga Cross' pkgNameSuffix = 'ja.mangacross' extClass = '.MangaCross' - extVersionCode = 1 + extVersionCode = 2 } apply from: "$rootDir/common.gradle" diff --git a/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCross.kt b/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCross.kt index 1cd207fe9..395beadbc 100644 --- a/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCross.kt +++ b/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCross.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.extension.ja.mangacross +import android.util.Log import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter @@ -79,22 +80,38 @@ class MangaCross : HttpSource() { override fun imageUrlParse(response: Response) = throw UnsupportedOperationException("Not used.") private lateinit var tags: List> + private var isFetchingTags = false + + private fun fetchTags() { + if (isFetchingTags) return + isFetchingTags = true + thread { + try { + val response = client.newCall(GET("$baseUrl/api/menus.json", headers)).execute() + val filterList = json.decodeFromString(response.body!!.string()).toFilterList() + tags = listOf(Pair("None", null)) + filterList + } catch (e: Exception) { + Log.e("MangaCross", "Failed to fetch filters ($e)") + } finally { + isFetchingTags = false + } + } + } init { - thread { - val response = client.newCall(GET("$baseUrl/api/menus.json", headers)).execute() - val filterList = json.decodeFromString(response.body!!.string()).toFilterList() - tags = listOf(Pair("None", null)) + filterList - } + fetchTags() } override fun getFilterList() = if (::tags.isInitialized) FilterList( Filter.Header("NOTE: Ignored if using text search!"), TagFilter("Tag", tags) - ) else FilterList( - Filter.Header("Tags not fetched yet. Go back and retry."), - ) + ) else { + fetchTags() + FilterList( + Filter.Header("Tags not fetched yet. Go back and retry."), + ) + } private class TagFilter(displayName: String, private val tags: List>) : Filter.Select(displayName, tags.map { it.first }.toTypedArray()) { diff --git a/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCrossDto.kt b/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCrossDto.kt index 308df90fd..ae8297167 100644 --- a/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCrossDto.kt +++ b/src/ja/mangacross/src/eu/kanade/tachiyomi/extension/ja/mangacross/MangaCrossDto.kt @@ -128,8 +128,9 @@ data class MCEpisode( fun getNextDatePrefix(): String? = when { !episode_next_date.isNullOrEmpty() -> { - val date = parseJSTDate(episode_next_date) - date.setTime(date.getTime() + 10 * 3600 * 1000) // 10 am JST + val date = parseJSTDate(episode_next_date).apply { + time += 10 * 3600 * 1000 // 10 am JST + } "【Next: ${localDate.format(date)}】" } !next_date_customize_text.isNullOrEmpty() -> "【$next_date_customize_text】"