优化
This commit is contained in:
@@ -81,7 +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
|
private var cover: Bitmap = BitmapFactory.decodeResource(resources, R.drawable.icon_read_book)
|
||||||
var pageChanged = false
|
var pageChanged = false
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
@@ -112,7 +112,10 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
.submit()
|
.submit()
|
||||||
.get()
|
.get()
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
|
val tmpCover = cover
|
||||||
cover = it
|
cover = it
|
||||||
|
upNotification()
|
||||||
|
tmpCover.recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,6 +139,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED)
|
upMediaSessionPlaybackState(PlaybackStateCompat.STATE_STOPPED)
|
||||||
mediaSessionCompat.release()
|
mediaSessionCompat.release()
|
||||||
ReadBook.uploadProgress()
|
ReadBook.uploadProgress()
|
||||||
|
cover.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
@@ -395,12 +399,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
.setContentIntent(
|
.setContentIntent(
|
||||||
activityPendingIntent<ReadBookActivity>("activity")
|
activityPendingIntent<ReadBookActivity>("activity")
|
||||||
)
|
)
|
||||||
if (cover != null) {
|
builder.setLargeIcon(cover)
|
||||||
builder.setLargeIcon(cover)
|
|
||||||
} else {
|
|
||||||
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.icon_read_book)
|
|
||||||
builder.setLargeIcon(bitmap)
|
|
||||||
}
|
|
||||||
if (pause) {
|
if (pause) {
|
||||||
builder.addAction(
|
builder.addAction(
|
||||||
R.drawable.ic_play_24dp,
|
R.drawable.ic_play_24dp,
|
||||||
|
|||||||
Reference in New Issue
Block a user