Sfoglia il codice sorgente

Extract some hardcoded strings (closes #1989)

Eugene 5 anni fa
parent
commit
0416a2ff15

+ 14 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt

@@ -341,19 +341,22 @@ open class BrowseCatalogueController(bundle: Bundle) :
         adapter.onLoadMoreComplete(null)
         hideProgressBar()
 
-        val message = if (error is NoResultsException) "No results found" else (error.message ?: "")
-
         snack?.dismiss()
-        snack = catalogue_view?.snack(message, Snackbar.LENGTH_INDEFINITE) {
-            setAction(R.string.action_retry) {
-                // If not the first page, show bottom progress bar.
-                if (adapter.mainItemCount > 0) {
-                    val item = progressItem ?: return@setAction
-                    adapter.addScrollableFooterWithDelay(item, 0, true)
-                } else {
-                    showProgressBar()
+
+        if (catalogue_view != null) {
+            val message = if (error is NoResultsException) catalogue_view.context.getString(R.string.no_results_found) else (error.message ?: "")
+
+            snack = catalogue_view.snack(message, Snackbar.LENGTH_INDEFINITE) {
+                setAction(R.string.action_retry) {
+                    // If not the first page, show bottom progress bar.
+                    if (adapter.mainItemCount > 0) {
+                        val item = progressItem ?: return@setAction
+                        adapter.addScrollableFooterWithDelay(item, 0, true)
+                    } else {
+                        showProgressBar()
+                    }
+                    presenter.requestNext()
                 }
-                presenter.requestNext()
             }
         }
     }

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/migration/SelectionHeader.kt

@@ -5,7 +5,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
 import eu.davidea.flexibleadapter.items.AbstractHeaderItem
 import eu.kanade.tachiyomi.R
 import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
-import kotlinx.android.synthetic.main.catalogue_main_controller_card.*
+import kotlinx.android.synthetic.main.catalogue_main_controller_card.title
 
 /**
  * Item that contains the selection header.
@@ -36,7 +36,7 @@ class SelectionHeader : AbstractHeaderItem<SelectionHeader.Holder>() {
 
     class Holder(view: View, adapter: FlexibleAdapter<*>) : BaseFlexibleViewHolder(view, adapter) {
         init {
-            title.text = "Please select a source to migrate from"
+            title.text = view.context.getString(R.string.migration_selection_prompt)
         }
     }
 

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

@@ -323,6 +323,7 @@
     <string name="select_source">Select a source</string>
     <string name="no_valid_sources">Please enable at least one valid source</string>
     <string name="no_more_results">No more results</string>
+    <string name="no_results_found">No results found</string>
     <string name="local_source">Local manga</string>
     <string name="other_source">Other</string>
     <string name="invalid_combination">Default can\'t be selected with other categories</string>
@@ -455,6 +456,7 @@
     <!-- Source migration screen -->
     <string name="migration_info">Tap to select the source to migrate from</string>
     <string name="migration_dialog_what_to_include">Select data to include</string>
+    <string name="migration_selection_prompt">Select a source to migrate from</string>
     <string name="select">Select</string>
     <string name="migrate">Migrate</string>
     <string name="copy">Copy</string>