diff --git a/app/src/main/java/io/legado/app/base/BaseViewModel.kt b/app/src/main/java/io/legado/app/base/BaseViewModel.kt index 3610a00a5..c8332e0cc 100644 --- a/app/src/main/java/io/legado/app/base/BaseViewModel.kt +++ b/app/src/main/java/io/legado/app/base/BaseViewModel.kt @@ -45,9 +45,9 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio } } - open fun toast(message: CharSequence) { + open fun toast(message: CharSequence?) { launch { - context.toast(message) + context.toast(message ?: toString()) } } @@ -57,9 +57,9 @@ open class BaseViewModel(application: Application) : AndroidViewModel(applicatio } } - open fun longToast(message: CharSequence) { + open fun longToast(message: CharSequence?) { launch { - context.toast(message) + context.toast(message ?: toString()) } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 1572dfc99..0b611dd82 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -266,7 +266,7 @@ class AudioPlayService : BaseService(), removeLoading(chapter.index) } }?.onError { - contentLoadFinish(chapter, it.localizedMessage) + contentLoadFinish(chapter, it.localizedMessage ?: toString()) removeLoading(chapter.index) } } diff --git a/app/src/main/java/io/legado/app/web/utils/ReturnData.kt b/app/src/main/java/io/legado/app/web/utils/ReturnData.kt index 5ea07243f..682c4be15 100644 --- a/app/src/main/java/io/legado/app/web/utils/ReturnData.kt +++ b/app/src/main/java/io/legado/app/web/utils/ReturnData.kt @@ -20,7 +20,7 @@ class ReturnData { return errorMsg } - fun setErrorMsg(errorMsg: String): ReturnData { + fun setErrorMsg(errorMsg: String?): ReturnData { this.isSuccess = false this.errorMsg = errorMsg return this