mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
fc9ca8049e
commit
bb577bfa00
@ -3,6 +3,8 @@ package io.legado.app.constant
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import io.legado.app.BuildConfig
|
import io.legado.app.BuildConfig
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
|
import io.legado.app.utils.toastOnUi
|
||||||
|
import splitties.init.appCtx
|
||||||
|
|
||||||
object AppLog {
|
object AppLog {
|
||||||
|
|
||||||
@ -11,8 +13,11 @@ object AppLog {
|
|||||||
val logs get() = mLogs.toList()
|
val logs get() = mLogs.toList()
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun put(message: String?, throwable: Throwable? = null) {
|
fun put(message: String?, throwable: Throwable? = null, toast: Boolean = false) {
|
||||||
message ?: return
|
message ?: return
|
||||||
|
if (toast) {
|
||||||
|
appCtx.toastOnUi(message)
|
||||||
|
}
|
||||||
if (mLogs.size > 100) {
|
if (mLogs.size > 100) {
|
||||||
mLogs.removeLastOrNull()
|
mLogs.removeLastOrNull()
|
||||||
}
|
}
|
||||||
@ -29,7 +34,7 @@ object AppLog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun putDebug(message: String?, throwable: Throwable? = null) {
|
fun putDebug(message: String?, throwable: Throwable? = null) {
|
||||||
if (AppConfig.recordLog || BuildConfig.DEBUG) {
|
if (AppConfig.recordLog) {
|
||||||
put(message, throwable)
|
put(message, throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -425,6 +425,10 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
builder
|
builder
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
startForeground(AppConst.notificationIdRead, it.build())
|
startForeground(AppConst.notificationIdRead, it.build())
|
||||||
|
}.onError {
|
||||||
|
AppLog.put("创建朗读通知出错,${it.localizedMessage}", it, true)
|
||||||
|
//创建通知出错不结束服务就会崩溃,服务必须绑定通知
|
||||||
|
stopSelf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user