From 3e1dc9f400e0763ed8442ba587604958f9562cc2 Mon Sep 17 00:00:00 2001 From: len Date: Tue, 29 Nov 2016 22:32:44 +0100 Subject: [PATCH] Add property to get the number of a page --- .../main/java/eu/kanade/tachiyomi/data/download/Downloader.kt | 2 +- .../main/java/eu/kanade/tachiyomi/data/source/model/Page.kt | 3 +++ .../main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 2 +- .../main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index d2928eb3d..5c28ec345 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -302,7 +302,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro if (page.imageUrl == null) return Observable.just(page) - val filename = String.format("%03d", page.index + 1) + val filename = String.format("%03d", page.number) val tmpFile = tmpDir.findFile("$filename.tmp") // Delete temp file if it exists. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/source/model/Page.kt b/app/src/main/java/eu/kanade/tachiyomi/data/source/model/Page.kt index ac1dc84d4..2aa3c04b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/source/model/Page.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/source/model/Page.kt @@ -12,6 +12,9 @@ class Page( @Transient var uri: Uri? = null ) : ProgressListener { + val number: Int + get() = index + 1 + @Transient lateinit var chapter: ReaderChapter @Transient @Volatile var status: Int = 0 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index a2980ac4e..ee01d9026 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -331,7 +331,7 @@ class ReaderActivity : BaseRxActivity() { fun onPageChanged(page: Page) { presenter.onPageChanged(page) - val pageNumber = page.index + 1 + val pageNumber = page.number val pageCount = page.chapter.pages!!.size page_number.text = "$pageNumber/$pageCount" if (page_seekbar.rotation != 180f) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 82d117da6..87c869e93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -579,7 +579,7 @@ class ReaderPresenter : BasePresenter() { // Build destination file. val ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime) ?: "jpg" val filename = DiskUtil.buildValidFilename( - "${manga.title} - ${chapter.name}") + " - ${page.index + 1}.$ext" + "${manga.title} - ${chapter.name}") + " - ${page.number}.$ext" val destFile = File(destDir, filename) context.contentResolver.openInputStream(page.uri).use { input ->