Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Jul 7, 2023
1 parent fc9ca80 commit bb577bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/io/legado/app/constant/AppLog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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()
}
Expand All @@ -29,7 +34,7 @@ object AppLog {
}

fun putDebug(message: String?, throwable: Throwable? = null) {
if (AppConfig.recordLog || BuildConfig.DEBUG) {
if (AppConfig.recordLog) {
put(message, throwable)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ abstract class BaseReadAloudService : BaseService(),
builder
}.onSuccess {
startForeground(AppConst.notificationIdRead, it.build())
}.onError {
AppLog.put("创建朗读通知出错,${it.localizedMessage}", it, true)
//创建通知出错不结束服务就会崩溃,服务必须绑定通知
stopSelf()
}
}

Expand Down

0 comments on commit bb577bf

Please sign in to comment.