From 8975e23e198b4880dfef0d60c3b3ac20f6daee4e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 25 Aug 2019 21:07:43 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/MediaHelp.kt | 7 ++----- .../java/io/legado/app/ui/widget/page/PageView.kt | 14 +++++--------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/MediaHelp.kt b/app/src/main/java/io/legado/app/help/MediaHelp.kt index a7235a342..b59a88e88 100644 --- a/app/src/main/java/io/legado/app/help/MediaHelp.kt +++ b/app/src/main/java/io/legado/app/help/MediaHelp.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) { } - } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt index d598d5626..6d665ceef 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt @@ -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()) } }