fix: various small fixes
This commit is contained in:
parent
4ccf6fa1c8
commit
e5ec6a6526
8 changed files with 44 additions and 21 deletions
|
@ -11,6 +11,7 @@ import ani.dantotsu.util.Logger
|
|||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.Serializable
|
||||
import java.net.URLDecoder
|
||||
|
@ -147,10 +148,11 @@ abstract class BaseParser {
|
|||
* @return Triple<Int, Int?, String> : First Int is the status code, Second Int is the response time in milliseconds, Third String is the response message.
|
||||
*/
|
||||
fun ping(): Triple<Int, Int?, String> {
|
||||
val client = okHttpClient
|
||||
val client = OkHttpClient()
|
||||
var statusCode = 0
|
||||
var responseTime: Int? = null
|
||||
var responseMessage = ""
|
||||
println("Pinging $name at $hostUrl")
|
||||
try {
|
||||
val request = Request.Builder()
|
||||
.url(hostUrl)
|
||||
|
@ -158,7 +160,7 @@ abstract class BaseParser {
|
|||
responseTime = measureTimeMillis {
|
||||
client.newCall(request).execute().use { response ->
|
||||
statusCode = response.code
|
||||
responseMessage = response.message
|
||||
responseMessage = response.message.ifEmpty { "None" }
|
||||
}
|
||||
}.toInt()
|
||||
} catch (e: Exception) {
|
||||
|
|
|
@ -95,11 +95,11 @@ class ExtensionTestItem(
|
|||
}
|
||||
|
||||
private suspend fun runAnimeTest(extension: AnimeParser) {
|
||||
pingResult = extension.ping()
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
if (testType == "ping") {
|
||||
pingResult = extension.ping()
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
@ -137,11 +137,11 @@ class ExtensionTestItem(
|
|||
}
|
||||
|
||||
private suspend fun runMangaTest(extension: MangaParser) {
|
||||
pingResult = extension.ping()
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
if (testType == "ping") {
|
||||
pingResult = extension.ping()
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
@ -179,10 +179,10 @@ class ExtensionTestItem(
|
|||
}
|
||||
|
||||
private suspend fun runNovelTest(extension: NovelParser) {
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
if (testType == "ping") {
|
||||
withContext(Dispatchers.Main) {
|
||||
pingResult()
|
||||
}
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class ExtensionTestItem(
|
|||
|
||||
private fun pingResult() {
|
||||
if (::binding.isInitialized.not()) return
|
||||
if (extensionType == "novel") {
|
||||
if (extensionType == "novel" && testType != "basic") {
|
||||
binding.pingResultText.isVisible = true
|
||||
binding.pingResultText.text = context.getString(R.string.test_not_supported)
|
||||
binding.pingResultText.setCompoundDrawablesWithIntrinsicBounds(
|
||||
|
|
|
@ -96,6 +96,11 @@ class ExtensionTestSettingsBottomDialog : BottomSheetDialogFragment() {
|
|||
testType = "full"
|
||||
}
|
||||
}
|
||||
binding.extensionTypeTextView.setOnLongClickListener {
|
||||
binding.searchTextView.visibility = View.VISIBLE
|
||||
binding.searchView.visibility = View.VISIBLE
|
||||
true
|
||||
}
|
||||
setupAdapter()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue