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