From 2194c4ba284581e22dbf15bc69086b2334fb101e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 31 May 2020 11:26:36 -0400 Subject: [PATCH] Localize "Page list is empty" exception message --- .../eu/kanade/tachiyomi/data/download/DownloadManager.kt | 3 ++- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 3 ++- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 3 ++- .../eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt | 5 ++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index e21c8bf9d9..c64c953e43 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.download import android.content.Context import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.BehaviorRelay +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download @@ -152,7 +153,7 @@ class DownloadManager(private val context: Context) { .filter { "image" in it.type.orEmpty() } if (files.isEmpty()) { - throw Exception("Page list is empty") + throw Exception(context.getString(R.string.page_list_empty_error)) } files.sortedBy { it.name } 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 ec8abac843..df7bcbf690 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 @@ -5,6 +5,7 @@ import android.webkit.MimeTypeMap import com.hippo.unifile.UniFile import com.jakewharton.rxrelay.BehaviorRelay import com.jakewharton.rxrelay.PublishRelay +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga @@ -276,7 +277,7 @@ class Downloader( download.source.fetchPageList(download.chapter) .doOnNext { pages -> if (pages.isEmpty()) { - throw Exception("Page list is empty") + throw Exception(context.getString(R.string.page_list_empty_error)) } download.pages = pages } 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 77a435b4eb..1f93754e80 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 @@ -225,8 +225,9 @@ class ReaderPresenter( this.manga = manga if (chapterId == -1L) chapterId = initialChapterId + val context = Injekt.get() val source = sourceManager.getOrStub(manga.source) - loader = ChapterLoader(downloadManager, manga, source) + loader = ChapterLoader(context, downloadManager, manga, source) Observable.just(manga).subscribeLatestCache(ReaderActivity::setManga) viewerChaptersRelay.subscribeLatestCache(ReaderActivity::setChapters) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt index 9551ff90af..64c80c0de2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/ChapterLoader.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.ui.reader.loader +import android.content.Context +import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.source.LocalSource @@ -16,6 +18,7 @@ import timber.log.Timber * Loader used to retrieve the [PageLoader] for a given chapter. */ class ChapterLoader( + private val context: Context, private val downloadManager: DownloadManager, private val manga: Manga, private val source: Source @@ -46,7 +49,7 @@ class ChapterLoader( .observeOn(AndroidSchedulers.mainThread()) .doOnNext { pages -> if (pages.isEmpty()) { - throw Exception("Page list is empty") + throw Exception(context.getString(R.string.page_list_empty_error)) } chapter.state = ReaderChapter.State.Loaded(pages) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6a723be7d2..f40790a945 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -559,6 +559,7 @@ There\'s no previous chapter Loading pages… Failed to load pages: %1$s + No pages found Updating library