优化
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -80,6 +81,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
internal var pageIndex = 0
|
internal var pageIndex = 0
|
||||||
private var needResumeOnAudioFocusGain = false
|
private var needResumeOnAudioFocusGain = false
|
||||||
private var dsJob: Job? = null
|
private var dsJob: Job? = null
|
||||||
|
private var cover: Bitmap? = null
|
||||||
var pageChanged = false
|
var pageChanged = false
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
@@ -103,6 +105,15 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
if (AppConfig.ttsTimer > 0) {
|
if (AppConfig.ttsTimer > 0) {
|
||||||
toastOnUi("朗读定时 ${AppConfig.ttsTimer} 分钟")
|
toastOnUi("朗读定时 ${AppConfig.ttsTimer} 分钟")
|
||||||
}
|
}
|
||||||
|
execute {
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
ImageLoader
|
||||||
|
.loadBitmap(this@BaseReadAloudService, ReadBook.book?.getDisplayCover())
|
||||||
|
.submit()
|
||||||
|
.get()
|
||||||
|
}.onSuccess {
|
||||||
|
cover = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observeLiveBus() {
|
fun observeLiveBus() {
|
||||||
@@ -384,15 +395,11 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
.setContentIntent(
|
.setContentIntent(
|
||||||
activityPendingIntent<ReadBookActivity>("activity")
|
activityPendingIntent<ReadBookActivity>("activity")
|
||||||
)
|
)
|
||||||
kotlin.runCatching {
|
if (cover != null) {
|
||||||
ImageLoader
|
builder.setLargeIcon(cover)
|
||||||
.loadBitmap(this@BaseReadAloudService, ReadBook.book?.getDisplayCover())
|
} else {
|
||||||
.submit()
|
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.icon_read_book)
|
||||||
.get()
|
builder.setLargeIcon(bitmap)
|
||||||
}.getOrElse {
|
|
||||||
BitmapFactory.decodeResource(resources, R.drawable.icon_read_book)
|
|
||||||
}.let {
|
|
||||||
builder.setLargeIcon(it)
|
|
||||||
}
|
}
|
||||||
if (pause) {
|
if (pause) {
|
||||||
builder.addAction(
|
builder.addAction(
|
||||||
|
|||||||
Reference in New Issue
Block a user