pull/32/head
kunfei 5 years ago
parent b3ea9f420b
commit 8975e23e19
  1. 7
      app/src/main/java/io/legado/app/help/MediaHelp.kt
  2. 14
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt

@ -19,7 +19,6 @@ object MediaHelp {
or PlaybackStateCompat.ACTION_STOP
or PlaybackStateCompat.ACTION_SEEK_TO)
@RequiresApi(Build.VERSION_CODES.O)
fun getFocusRequest(audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener): AudioFocusRequest {
val mPlaybackAttributes = AudioAttributes.Builder()
@ -34,13 +33,11 @@ object MediaHelp {
}
fun playSilentSound(mContext: Context) {
try {
kotlin.runCatching {
// Stupid Android 8 "Oreo" hack to make media buttons work
val mMediaPlayer = MediaPlayer.create(mContext, R.raw.silent_sound)
mMediaPlayer.setOnCompletionListener { it.release() }
mMediaPlayer.setOnCompletionListener { mMediaPlayer.release() }
mMediaPlayer.start()
} catch (ignored: Exception) {
}
}
}

@ -169,11 +169,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
this.pageFactory = factory
//可做成异步回调
pageFactory?.let {
prevPage?.setContent(it.previousPage())
curPage?.setContent(it.currentPage())
nextPage?.setContent(it.nextPage())
}
upContent()
}
override fun hasNext(): Boolean {
@ -185,10 +181,10 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
}
fun upContent() {
callback?.let {
it.textChapter()?.let { textChapter ->
curPage?.setContent(textChapter.page(it.durChapterIndex()))
}
pageFactory?.let {
prevPage?.setContent(it.previousPage())
curPage?.setContent(it.currentPage())
nextPage?.setContent(it.nextPage())
}
}

Loading…
Cancel
Save