This commit is contained in:
kunfei
2022-02-02 21:34:20 +08:00
parent ebdef8f73f
commit 45b6f77ebe
3 changed files with 40 additions and 26 deletions
@@ -146,7 +146,7 @@ class CheckSourceService : BaseService() {
if (source.hasGroup("搜索失效") && url.isNullOrBlank()) { if (source.hasGroup("搜索失效") && url.isNullOrBlank()) {
throw NoStackTraceException("搜索内容为空并且没有发现") throw NoStackTraceException("搜索内容为空并且没有发现")
} }
books = WebBook.exploreBookAwait(this, source, url) books = WebBook.exploreBookAwait(this, source, url!!)
if (books.isEmpty()) { if (books.isEmpty()) {
throw NoStackTraceException("发现书籍为空") throw NoStackTraceException("发现书籍为空")
} }
@@ -137,7 +137,13 @@ class FileAssociationActivity :
} }
} }
}.onFailure { }.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) { fun Context.toastOnUi(message: Int) {
runOnUI { runOnUI {
kotlin.runCatching {
if (toast == null) { if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_SHORT) toast = Toast.makeText(this, message, Toast.LENGTH_SHORT)
} else { } else {
@@ -18,10 +19,12 @@ fun Context.toastOnUi(message: Int) {
} }
toast?.show() toast?.show()
} }
}
} }
fun Context.toastOnUi(message: CharSequence?) { fun Context.toastOnUi(message: CharSequence?) {
runOnUI { runOnUI {
kotlin.runCatching {
if (toast == null) { if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_SHORT) toast = Toast.makeText(this, message, Toast.LENGTH_SHORT)
} else { } else {
@@ -30,10 +33,12 @@ fun Context.toastOnUi(message: CharSequence?) {
} }
toast?.show() toast?.show()
} }
}
} }
fun Context.longToastOnUi(message: Int) { fun Context.longToastOnUi(message: Int) {
runOnUI { runOnUI {
kotlin.runCatching {
if (toast == null) { if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_LONG) toast = Toast.makeText(this, message, Toast.LENGTH_LONG)
} else { } else {
@@ -42,10 +47,12 @@ fun Context.longToastOnUi(message: Int) {
} }
toast?.show() toast?.show()
} }
}
} }
fun Context.longToastOnUi(message: CharSequence?) { fun Context.longToastOnUi(message: CharSequence?) {
runOnUI { runOnUI {
kotlin.runCatching {
if (toast == null) { if (toast == null) {
toast = Toast.makeText(this, message, Toast.LENGTH_LONG) toast = Toast.makeText(this, message, Toast.LENGTH_LONG)
} else { } else {
@@ -54,6 +61,7 @@ fun Context.longToastOnUi(message: CharSequence?) {
} }
toast?.show() toast?.show()
} }
}
} }