mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-26 23:28:58 +03:00
Reader fixes and minor changes
This commit is contained in:
parent
18cdddf433
commit
1ac8ef5341
6 changed files with 70 additions and 35 deletions
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.data.source.model.MangasPage
|
|||
import eu.kanade.tachiyomi.data.source.model.Page
|
||||
import eu.kanade.tachiyomi.data.source.online.LoginSource
|
||||
import eu.kanade.tachiyomi.data.source.online.ParsedOnlineSource
|
||||
import eu.kanade.tachiyomi.util.selectText
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
|
@ -51,30 +52,13 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
|
||||
override fun headersBuilder() = super.headersBuilder()
|
||||
.add("Cookie", "lang_option=English")
|
||||
|
||||
private val pageHeaders = super.headersBuilder()
|
||||
.add("Referer", "http://bato.to/reader")
|
||||
.build()
|
||||
|
||||
override fun popularMangaInitialUrl() = "$baseUrl/search_ajax?order_cond=views&order=desc&p=1"
|
||||
|
||||
override fun searchMangaInitialUrl(query: String) = "$baseUrl/search_ajax?name=${Uri.encode(query)}&p=1"
|
||||
|
||||
override fun mangaDetailsRequest(manga: Manga): Request {
|
||||
val mangaId = manga.url.substringAfterLast("r")
|
||||
return GET("$baseUrl/comic_pop?id=$mangaId", headers)
|
||||
}
|
||||
|
||||
override fun pageListRequest(chapter: Chapter): Request {
|
||||
val id = chapter.url.substringAfterLast("#")
|
||||
return GET("$baseUrl/areader?id=$id&p=1", headers)
|
||||
}
|
||||
|
||||
override fun imageUrlRequest(page: Page): Request {
|
||||
val pageUrl = page.url
|
||||
val start = pageUrl.indexOf("#") + 1
|
||||
val end = pageUrl.indexOf("_", start)
|
||||
val id = pageUrl.substring(start, end)
|
||||
return GET("$baseUrl/areader?id=$id&p=${pageUrl.substring(end+1)}", headers)
|
||||
}
|
||||
|
||||
override fun popularMangaParse(response: Response, page: MangasPage) {
|
||||
val document = Jsoup.parse(response.body().string())
|
||||
for (element in document.select(popularMangaSelector())) {
|
||||
|
@ -101,6 +85,8 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
|
||||
override fun popularMangaNextPageSelector() = "#show_more_row"
|
||||
|
||||
override fun searchMangaInitialUrl(query: String) = "$baseUrl/search_ajax?name=${Uri.encode(query)}&p=1"
|
||||
|
||||
override fun searchMangaParse(response: Response, page: MangasPage, query: String) {
|
||||
val document = Jsoup.parse(response.body().string())
|
||||
for (element in document.select(searchMangaSelector())) {
|
||||
|
@ -124,15 +110,20 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
|
||||
override fun searchMangaNextPageSelector() = popularMangaNextPageSelector()
|
||||
|
||||
override fun mangaDetailsRequest(manga: Manga): Request {
|
||||
val mangaId = manga.url.substringAfterLast("r")
|
||||
return GET("$baseUrl/comic_pop?id=$mangaId", headers)
|
||||
}
|
||||
|
||||
override fun mangaDetailsParse(document: Document, manga: Manga) {
|
||||
val tbody = document.select("tbody").first()
|
||||
val artistElement = tbody.select("tr:contains(Author/Artist:)").first()
|
||||
|
||||
manga.author = artistElement.select("td:eq(1)").first()?.text()
|
||||
manga.artist = artistElement.select("td:eq(2)").first()?.text() ?: manga.author
|
||||
manga.description = tbody.select("tr:contains(Description:) > td:eq(1)").first()?.text()
|
||||
manga.author = artistElement.selectText("td:eq(1)")
|
||||
manga.artist = artistElement.selectText("td:eq(2)") ?: manga.author
|
||||
manga.description = tbody.selectText("tr:contains(Description:) > td:eq(1)")
|
||||
manga.thumbnail_url = document.select("img[src^=http://img.bato.to/forums/uploads/]").first()?.attr("src")
|
||||
manga.status = parseStatus(document.select("tr:contains(Status:) > td:eq(1)").first()?.text())
|
||||
manga.status = parseStatus(document.selectText("tr:contains(Status:) > td:eq(1)"))
|
||||
manga.genre = tbody.select("tr:contains(Genres:) img").map { it.attr("alt") }.joinToString(", ")
|
||||
}
|
||||
|
||||
|
@ -147,7 +138,7 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
val matcher = staffNotice.matcher(body)
|
||||
if (matcher.find()) {
|
||||
val notice = Html.fromHtml(matcher.group(1)).toString().trim()
|
||||
throw RuntimeException(notice)
|
||||
throw Exception(notice)
|
||||
}
|
||||
|
||||
val document = Jsoup.parse(body)
|
||||
|
@ -197,6 +188,11 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
return date.time
|
||||
}
|
||||
|
||||
override fun pageListRequest(chapter: Chapter): Request {
|
||||
val id = chapter.url.substringAfterLast("#")
|
||||
return GET("$baseUrl/areader?id=$id&p=1", pageHeaders)
|
||||
}
|
||||
|
||||
override fun pageListParse(document: Document, pages: MutableList<Page>) {
|
||||
val selectElement = document.select("#page_select").first()
|
||||
if (selectElement != null) {
|
||||
|
@ -212,6 +208,14 @@ class Batoto(context: Context, override val id: Int) : ParsedOnlineSource(contex
|
|||
}
|
||||
}
|
||||
|
||||
override fun imageUrlRequest(page: Page): Request {
|
||||
val pageUrl = page.url
|
||||
val start = pageUrl.indexOf("#") + 1
|
||||
val end = pageUrl.indexOf("_", start)
|
||||
val id = pageUrl.substring(start, end)
|
||||
return GET("$baseUrl/areader?id=$id&p=${pageUrl.substring(end+1)}", pageHeaders)
|
||||
}
|
||||
|
||||
override fun imageUrlParse(document: Document): String {
|
||||
return document.select("#comic_page").first().attr("src")
|
||||
}
|
||||
|
|
|
@ -226,19 +226,24 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
// Ignore
|
||||
}
|
||||
|
||||
fun onChapterReady(manga: Manga, chapter: Chapter, currentPage: Page?) {
|
||||
val activePage = currentPage ?: chapter.pages.last()
|
||||
|
||||
fun onMangaOpen(manga: Manga) {
|
||||
if (viewer == null) {
|
||||
viewer = getOrCreateViewer(manga)
|
||||
}
|
||||
viewer?.onPageListReady(chapter, activePage)
|
||||
|
||||
if (viewer is RightToLeftReader && page_seekbar.rotation != 180f) {
|
||||
// Invert the seekbar for the right to left reader
|
||||
page_seekbar.rotation = 180f
|
||||
}
|
||||
setToolbarTitle(manga.title)
|
||||
please_wait.visibility = View.VISIBLE
|
||||
please_wait.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in_long))
|
||||
}
|
||||
|
||||
fun onChapterReady(manga: Manga, chapter: Chapter, currentPage: Page?) {
|
||||
please_wait.visibility = View.GONE
|
||||
val activePage = currentPage ?: chapter.pages.last()
|
||||
|
||||
viewer?.onPageListReady(chapter, activePage)
|
||||
setActiveChapter(chapter, activePage.pageNumber)
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,11 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||
|
||||
private var appenderSubscription: Subscription? = null
|
||||
|
||||
private val GET_PAGE_LIST = 1
|
||||
private val GET_ADJACENT_CHAPTERS = 2
|
||||
private val GET_MANGA_SYNC = 3
|
||||
private val PRELOAD_NEXT_CHAPTER = 4
|
||||
private val PREPARE_READER = 1
|
||||
private val GET_PAGE_LIST = 2
|
||||
private val GET_ADJACENT_CHAPTERS = 3
|
||||
private val GET_MANGA_SYNC = 4
|
||||
private val PRELOAD_NEXT_CHAPTER = 5
|
||||
|
||||
private val MANGA_KEY = "manga_key"
|
||||
private val CHAPTER_KEY = "chapter_key"
|
||||
|
@ -83,6 +84,10 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||
|
||||
initializeSubjects()
|
||||
|
||||
restartableLatestCache(PREPARE_READER,
|
||||
{ Observable.just(manga) },
|
||||
{ view, manga -> view.onMangaOpen(manga) })
|
||||
|
||||
startableLatestCache(GET_ADJACENT_CHAPTERS,
|
||||
{ getAdjacentChaptersObservable() },
|
||||
{ view, pair -> view.onAdjacentChapters(pair.first, pair.second) })
|
||||
|
@ -102,6 +107,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
|
|||
{ view, error -> view.onChapterError(error) })
|
||||
|
||||
if (savedState == null) {
|
||||
start(PREPARE_READER)
|
||||
loadChapter(chapter)
|
||||
if (prefs.autoUpdateMangaSync()) {
|
||||
start(GET_MANGA_SYNC)
|
||||
|
|
|
@ -98,7 +98,11 @@ class WebtoonReader : BaseReader() {
|
|||
.doOnNext { setDecoderClass(it) }
|
||||
.skip(1)
|
||||
.distinctUntilChanged()
|
||||
.subscribe { recycler.adapter = adapter })
|
||||
.subscribe {
|
||||
val activePage = layoutManager.findFirstVisibleItemPosition()
|
||||
recycler.adapter = adapter
|
||||
setActivePage(activePage)
|
||||
})
|
||||
|
||||
setPagesOnAdapter()
|
||||
return recycler
|
||||
|
|
9
app/src/main/res/anim/fade_in_long.xml
Normal file
9
app/src/main/res/anim/fade_in_long.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha
|
||||
android:fromAlpha="0.0"
|
||||
android:toAlpha="1.0"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:duration="2000"
|
||||
android:fillAfter="true"/>
|
||||
</set>
|
|
@ -9,6 +9,13 @@
|
|||
android:layout_height="match_parent">
|
||||
</FrameLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/please_wait"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/page_number"
|
||||
style="@style/TextAppearance.Regular.Caption"
|
||||
|
|
Loading…
Reference in a new issue