Reader cleanup
This commit is contained in:
parent
60f1c6a2b4
commit
efba76380a
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.source
|
||||
|
||||
import android.content.Context
|
||||
import com.github.junrar.Archive
|
||||
import com.google.gson.JsonParser
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
@ -17,8 +16,11 @@ import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.storage.EpubFile
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okio.buffer
|
||||
import okio.source
|
||||
import rx.Observable
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -169,29 +171,13 @@ class LocalSource(private val context: Context) : CatalogueSource {
|
||||
|
||||
@Serializable
|
||||
data class MangaJson(
|
||||
val title: String,
|
||||
val author: String?,
|
||||
val artist: String?,
|
||||
val description: String?,
|
||||
val genre: List<String>?,
|
||||
val status: Int
|
||||
) {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as MangaJson
|
||||
|
||||
if (title != other.title) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return title.hashCode()
|
||||
}
|
||||
}
|
||||
val title: String? = null,
|
||||
val author: String? = null,
|
||||
val artist: String? = null,
|
||||
val description: String? = null,
|
||||
val genre: List<String>? = null,
|
||||
val status: Int? = null
|
||||
)
|
||||
// SY <--
|
||||
|
||||
override fun fetchLatestUpdates(page: Int) = fetchSearchManga(page, "", LATEST_FILTERS)
|
||||
@ -203,16 +189,19 @@ class LocalSource(private val context: Context) : CatalogueSource {
|
||||
.flatten()
|
||||
.firstOrNull { it.extension == "json" }
|
||||
?.apply {
|
||||
val reader = this.inputStream().bufferedReader()
|
||||
val json = JsonParser.parseReader(reader).asJsonObject
|
||||
val json = json.decodeFromString<MangaJson>(
|
||||
this.inputStream()
|
||||
.source()
|
||||
.buffer()
|
||||
.use { it.readUtf8() }
|
||||
)
|
||||
|
||||
manga.title = json["title"]?.asString ?: manga.title
|
||||
manga.author = json["author"]?.asString ?: manga.author
|
||||
manga.artist = json["artist"]?.asString ?: manga.artist
|
||||
manga.description = json["description"]?.asString ?: manga.description
|
||||
manga.genre = json["genre"]?.asJsonArray?.joinToString(", ") { it.asString }
|
||||
?: manga.genre
|
||||
manga.status = json["status"]?.asInt ?: manga.status
|
||||
manga.title = json.title ?: manga.title
|
||||
manga.author = json.author ?: manga.author
|
||||
manga.artist = json.artist ?: manga.artist
|
||||
manga.description = json.description ?: manga.description
|
||||
manga.genre = json.genre?.joinToString(", ") ?: manga.genre
|
||||
manga.status = json.status ?: manga.status
|
||||
}
|
||||
|
||||
return Observable.just(manga)
|
||||
|
@ -126,6 +126,7 @@ class EHentai(
|
||||
val linkElement = body.selectFirst(".gl3c > a, .gl2e > div > a")
|
||||
val infoElement = body.selectFirst(".gl3e")
|
||||
|
||||
// why is column2 null
|
||||
val favElement = column2.children().find { it.attr("style").startsWith("border-color") }
|
||||
val infoElements = infoElement?.select("div")
|
||||
val parsedTags = mutableListOf<RaisedTag>()
|
||||
|
@ -3,12 +3,9 @@ package exh.debug
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.util.Log
|
||||
import android.widget.HorizontalScrollView
|
||||
import android.widget.TextView
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.onClick
|
||||
@ -36,22 +33,26 @@ class SettingsDebugController : SettingsController() {
|
||||
isPersistent = false
|
||||
|
||||
onClick {
|
||||
val view = TextView(context)
|
||||
view.setHorizontallyScrolling(true)
|
||||
view.setTextIsSelectable(true)
|
||||
|
||||
val hView = HorizontalScrollView(context)
|
||||
hView.addView(view)
|
||||
|
||||
try {
|
||||
val result = it.call(DebugFunctions)
|
||||
view.text = "Function returned result:\n\n$result"
|
||||
val text = "Function returned result:\n\n$result"
|
||||
MaterialDialog(context)
|
||||
.customView(view = hView, scrollable = true)
|
||||
.title(text = title.toString())
|
||||
.message(text = text) {
|
||||
messageTextView.apply {
|
||||
setHorizontallyScrolling(true)
|
||||
setTextIsSelectable(true)
|
||||
}
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
view.text = "Function threw exception:\n\n${Log.getStackTraceString(t)}"
|
||||
val text = "Function threw exception:\n\n${Log.getStackTraceString(t)}"
|
||||
MaterialDialog(context)
|
||||
.customView(view = hView, scrollable = true)
|
||||
.message(text = text) {
|
||||
messageTextView.apply {
|
||||
setHorizontallyScrolling(true)
|
||||
setTextIsSelectable(true)
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user