This commit is contained in:
kunfei 2023-07-07 20:08:42 +08:00
parent fc9ca8049e
commit bb577bfa00
2 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,8 @@ package io.legado.app.constant
import android.util.Log
import io.legado.app.BuildConfig
import io.legado.app.help.config.AppConfig
import io.legado.app.utils.toastOnUi
import splitties.init.appCtx
object AppLog {
@ -11,8 +13,11 @@ object AppLog {
val logs get() = mLogs.toList()
@Synchronized
fun put(message: String?, throwable: Throwable? = null) {
fun put(message: String?, throwable: Throwable? = null, toast: Boolean = false) {
message ?: return
if (toast) {
appCtx.toastOnUi(message)
}
if (mLogs.size > 100) {
mLogs.removeLastOrNull()
}
@ -29,7 +34,7 @@ object AppLog {
}
fun putDebug(message: String?, throwable: Throwable? = null) {
if (AppConfig.recordLog || BuildConfig.DEBUG) {
if (AppConfig.recordLog) {
put(message, throwable)
}
}

View File

@ -425,6 +425,10 @@ abstract class BaseReadAloudService : BaseService(),
builder
}.onSuccess {
startForeground(AppConst.notificationIdRead, it.build())
}.onError {
AppLog.put("创建朗读通知出错,${it.localizedMessage}", it, true)
//创建通知出错不结束服务就会崩溃,服务必须绑定通知
stopSelf()
}
}