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