pull/1576/head^2
kunfei 3 years ago
parent ebdef8f73f
commit 45b6f77ebe
  1. 2
      app/src/main/java/io/legado/app/service/CheckSourceService.kt
  2. 8
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  3. 8
      app/src/main/java/io/legado/app/utils/ToastUtils.kt

@ -146,7 +146,7 @@ class CheckSourceService : BaseService() {
if (source.hasGroup("搜索失效") && url.isNullOrBlank()) {
throw NoStackTraceException("搜索内容为空并且没有发现")
}
books = WebBook.exploreBookAwait(this, source, url)
books = WebBook.exploreBookAwait(this, source, url!!)
if (books.isEmpty()) {
throw NoStackTraceException("发现书籍为空")
}

@ -137,7 +137,13 @@ class FileAssociationActivity :
}
}
}.onFailure {
toastOnUi(it.localizedMessage)
when (it) {
is SecurityException -> localBookTreeSelect.launch {
title = "选择保存书籍的文件夹"
mode = HandleFileContract.DIR_SYS
}
else -> toastOnUi(it.localizedMessage)
}
}
}
}

@ -10,6 +10,7 @@ private var toast: Toast? = null
fun Context.toastOnUi(message: Int) {
runOnUI {
kotlin.runCatching {
if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_SHORT)
} else {
@ -19,9 +20,11 @@ fun Context.toastOnUi(message: Int) {
toast?.show()
}
}
}
fun Context.toastOnUi(message: CharSequence?) {
runOnUI {
kotlin.runCatching {
if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_SHORT)
} else {
@ -31,9 +34,11 @@ fun Context.toastOnUi(message: CharSequence?) {
toast?.show()
}
}
}
fun Context.longToastOnUi(message: Int) {
runOnUI {
kotlin.runCatching {
if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_LONG)
} else {
@ -43,9 +48,11 @@ fun Context.longToastOnUi(message: Int) {
toast?.show()
}
}
}
fun Context.longToastOnUi(message: CharSequence?) {
runOnUI {
kotlin.runCatching {
if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_LONG)
} else {
@ -55,6 +62,7 @@ fun Context.longToastOnUi(message: CharSequence?) {
toast?.show()
}
}
}
fun Fragment.toastOnUi(message: Int) = requireActivity().toastOnUi(message)

Loading…
Cancel
Save