mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Prompt user to open WebView on HTTP errors
This commit is contained in:
		| @@ -352,10 +352,7 @@ open class BrowseCatalogueController(bundle: Bundle) : | ||||
|         snack?.dismiss() | ||||
|  | ||||
|         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) { | ||||
|             snack = catalogue_view.snack(getErrorMessage(error), Snackbar.LENGTH_INDEFINITE) { | ||||
|                 setAction(R.string.action_retry) { | ||||
|                     // If not the first page, show bottom progress bar. | ||||
|                     if (adapter.mainItemCount > 0) { | ||||
| @@ -370,6 +367,18 @@ open class BrowseCatalogueController(bundle: Bundle) : | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun getErrorMessage(error: Throwable): String { | ||||
|         if (error is NoResultsException) { | ||||
|             return catalogue_view.context.getString(R.string.no_results_found) | ||||
|         } | ||||
|  | ||||
|         return when { | ||||
|             error.message == null -> "" | ||||
|             error.message!!.startsWith("HTTP error") -> "${error.message}: ${catalogue_view.context.getString(R.string.http_error_hint)}" | ||||
|             else -> error.message!! | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets a new progress item and reenables the scroll listener. | ||||
|      */ | ||||
|   | ||||
| @@ -378,6 +378,7 @@ | ||||
|     <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="http_error_hint">Check website in WebView</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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user