+
+ Chapter 1: Nightmare Begins
+A frail-looking young man with pale skin was sitting on a rusty bench.
+ + +No chapters found for this novel.
Error loading novel details.
Unable to load chapter content.
Please check your network connection and try again.
Error loading chapter.
${trimmed}
") + } + } + textBuilder.toString() + } catch (e: Exception) { + e.printStackTraceDebug() + null + } + } + + fun updateScrollProgress(percent: Float) { + _scrollProgress.value = percent + saveReadingProgress(percent) + } + + private fun saveReadingProgress(percent: Float) { + val cur = _manga.value ?: return + val chap = _currentChapter.value ?: return + viewModelScope.launch(Dispatchers.IO) { + val chaps = _chapters.value + historyRepository.addOrUpdate( + manga = cur.copy(chapters = chaps), + chapterId = chap.id, + page = _currentChapterIndex.value, + scroll = (percent * 100).toInt(), + percent = percent, + force = false, + ) + } + } + + fun getPdfHelper(): PdfRendererHelper? = pdfHelper + + fun getEpubParser(): EpubParser? = epubParser +} diff --git a/app/src/main/kotlin/io/github/landwarderer/futon/novel/ui/reader/pdf/PdfPageAdapter.kt b/app/src/main/kotlin/io/github/landwarderer/futon/novel/ui/reader/pdf/PdfPageAdapter.kt new file mode 100644 index 0000000000..9420c14be0 --- /dev/null +++ b/app/src/main/kotlin/io/github/landwarderer/futon/novel/ui/reader/pdf/PdfPageAdapter.kt @@ -0,0 +1,99 @@ +package io.github.landwarderer.futon.novel.ui.reader.pdf + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.core.view.isVisible +import androidx.recyclerview.widget.RecyclerView +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import io.github.landwarderer.futon.core.util.ext.printStackTraceDebug +import io.github.landwarderer.futon.databinding.ItemPdfPageBinding +import io.github.landwarderer.futon.novel.data.pdf.PdfRendererHelper + +class PdfPageAdapter( + private val scope: CoroutineScope, + private val getPdfHelper: () -> PdfRendererHelper?, + private val onPageClick: (() -> Unit)? = null, +) : RecyclerView.Adapter
+
+
+
+
+
+
+
+ 
Growing up in poverty, Sunny was chosen by the Nightmare Spell...
+A frail-looking young man with pale skin was sitting on a rusty bench.
+ + +Jake, an apparently normal office worker, finds himself thrust into a vast multiverse filled with gods, beasts, and magic.
" + } + """.trimIndent() + + private fun buildChaptersJson(): String = """ + { + "page": 1, + "total_pages": 1, + "total_chapters": 2, + "chapters": [ + { + "chapter_id": 1, + "title": "Chapter 1: The Initiation", + "volume": 1 + }, + { + "chapter_id": 2, + "title": "Chapter 2: The Tutorial Begins", + "volume": 1 + } + ] + } + """.trimIndent() + + private fun buildChapter1Json(): String = """ + { + "chapter_id": 1, + "title": "Chapter 1: The Initiation", + "body": "Jake woke up with a pounding headache.
" + } + """.trimIndent() + + private fun buildSitemapIndexXml(): String = """ + +
+
+ Subaru Natsuki is summoned to another fantasy world.
+
Subaru Natsuki was an ordinary high school student who found himself suddenly summoned to an alternate fantasy world with no explanation whatsoever. There was no summoner in sight, nor any grand quest thrust upon him. Just a bustling marketplace full of demi-humans, lizard folk, and magic carriages moving about. Thinking he had obtained typical protagonist powers, he quickly learned that his only ability was to return by death.
+He walked around the capital city trying to make sense of his surroundings, checking his belongings which consisted only of a convenience store plastic bag containing instant ramen, chips, and his uncharged flip phone.
+
+ As dusk fell over the capital city of Lugnica, dark shadows began to loom across the cobblestone alleys...
+This is the sacred text of the chapter.
+ +
+
+
+
+
+
+ 
He has locked himself in the royal library.
+