Procházet zdrojové kódy

Localize "Page list is empty" exception message

arkon před 4 roky
rodič
revize
2194c4ba28

+ 2 - 1
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 }

+ 2 - 1
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
                 }

+ 2 - 1
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<Application>()
         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)

+ 4 - 1
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)

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -559,6 +559,7 @@
     <string name="transition_no_previous">There\'s no previous chapter</string>
     <string name="transition_pages_loading">Loading pages…</string>
     <string name="transition_pages_error">Failed to load pages: %1$s</string>
+    <string name="page_list_empty_error">No pages found</string>
 
     <!-- Updates fragment -->
     <string name="updating_library">Updating library</string>