mirror of
https://github.com/gedoor/legado.git
synced 2025-01-07 03:06:58 +08:00
优化
This commit is contained in:
parent
8ccd05070c
commit
94ef331b22
@ -806,15 +806,15 @@ class AnalyzeUrl(
|
||||
fun setBody(value: String?) {
|
||||
body = when {
|
||||
value.isNullOrBlank() -> null
|
||||
value.isJsonObject() -> GSON.fromJsonObject<Map<String, Any>>(value)
|
||||
value.isJsonArray() -> GSON.fromJsonArray<Map<String, Any>>(value)
|
||||
value.isJsonObject() -> GSON.fromJsonObject<Map<String, Any>>(value).getOrNull()
|
||||
value.isJsonArray() -> GSON.fromJsonArray<Map<String, Any>>(value).getOrNull()
|
||||
else -> value
|
||||
}
|
||||
}
|
||||
|
||||
fun getBody(): String? {
|
||||
return body?.let {
|
||||
if (it is String) it else GSON.toJson(it)
|
||||
it as? String ?: GSON.toJson(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import io.legado.app.constant.NotificationId
|
||||
import io.legado.app.constant.Status
|
||||
import io.legado.app.help.MediaHelp
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.exoplayer.ExoPlayerHelper
|
||||
import io.legado.app.help.glide.ImageLoader
|
||||
import io.legado.app.model.AudioPlay
|
||||
@ -109,6 +110,7 @@ class AudioPlayService : BaseService(),
|
||||
private var needResumeOnAudioFocusGain = false
|
||||
private var position = AudioPlay.book?.durChapterPos ?: 0
|
||||
private var dsJob: Job? = null
|
||||
private var upNotificationJob: Coroutine<*>? = null
|
||||
private var upPlayProgressJob: Job? = null
|
||||
private var playSpeed: Float = 1f
|
||||
private var cover: Bitmap =
|
||||
@ -196,6 +198,9 @@ class AudioPlayService : BaseService(),
|
||||
AudioPlay.status = Status.STOP
|
||||
postEvent(EventBus.AUDIO_STATE, Status.STOP)
|
||||
AudioPlay.unregisterService()
|
||||
upNotificationJob?.invokeOnCompletion {
|
||||
notificationManager.cancel(NotificationId.AudioPlayService)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -602,7 +607,7 @@ class AudioPlayService : BaseService(),
|
||||
}
|
||||
|
||||
private fun upAudioPlayNotification() {
|
||||
execute {
|
||||
upNotificationJob = execute {
|
||||
try {
|
||||
val notification = createNotification()
|
||||
notificationManager.notify(NotificationId.AudioPlayService, notification.build())
|
||||
|
@ -34,6 +34,7 @@ import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.constant.Status
|
||||
import io.legado.app.help.MediaHelp
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.help.glide.ImageLoader
|
||||
import io.legado.app.lib.permission.Permissions
|
||||
import io.legado.app.lib.permission.PermissionsCompat
|
||||
@ -123,6 +124,7 @@ abstract class BaseReadAloudService : BaseService(),
|
||||
private var needResumeOnCallStateIdle = false
|
||||
private var registeredPhoneStateListener = false
|
||||
private var dsJob: Job? = null
|
||||
private var upNotificationJob: Coroutine<*>? = null
|
||||
private var cover: Bitmap =
|
||||
BitmapFactory.decodeResource(appCtx.resources, R.drawable.icon_read_book)
|
||||
var pageChanged = false
|
||||
@ -198,6 +200,9 @@ abstract class BaseReadAloudService : BaseService(),
|
||||
mediaSessionCompat.release()
|
||||
ReadBook.uploadProgress()
|
||||
unregisterPhoneStateListener(phoneStateListener)
|
||||
upNotificationJob?.invokeOnCompletion {
|
||||
notificationManager.cancel(NotificationId.ReadAloudService)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
@ -504,7 +509,7 @@ abstract class BaseReadAloudService : BaseService(),
|
||||
}
|
||||
|
||||
private fun upReadAloudNotification() {
|
||||
execute {
|
||||
upNotificationJob = execute {
|
||||
try {
|
||||
val notification = createNotification()
|
||||
notificationManager.notify(NotificationId.ReadAloudService, notification.build())
|
||||
|
@ -40,7 +40,7 @@ object LogUtils {
|
||||
}
|
||||
|
||||
val logger: Logger by lazy {
|
||||
Logger.getLogger("Leagdo").apply {
|
||||
Logger.getLogger("Legado").apply {
|
||||
fileHandler?.let {
|
||||
addHandler(it)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user