From 5b7c6bcaabbe12faf86cbae8c28236eee6d7042a Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 30 Jan 2020 13:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/base/BaseActivity.kt | 9 ++++++--- .../java/io/legado/app/ui/book/info/BookInfoActivity.kt | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/BaseActivity.kt b/app/src/main/java/io/legado/app/base/BaseActivity.kt index 048036892..e0d4713d7 100644 --- a/app/src/main/java/io/legado/app/base/BaseActivity.kt +++ b/app/src/main/java/io/legado/app/base/BaseActivity.kt @@ -52,9 +52,12 @@ abstract class BaseActivity( } ?: super.onCreateOptionsMenu(menu) } - override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { - menu.applyOpenTint(this) - return super.onMenuOpened(featureId, menu) + override fun onMenuOpened(featureId: Int, menu: Menu?): Boolean { + menu?.let { + menu.applyOpenTint(this) + return super.onMenuOpened(featureId, menu) + } + return true } open fun onCompatCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 57839f1c9..fb689519c 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -98,8 +98,8 @@ class BookInfoActivity : return super.onCompatOptionsItemSelected(item) } - override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { - menu.findItem(R.id.menu_can_update)?.isChecked = + override fun onMenuOpened(featureId: Int, menu: Menu?): Boolean { + menu?.findItem(R.id.menu_can_update)?.isChecked = viewModel.bookData.value?.canUpdate ?: true return super.onMenuOpened(featureId, menu) }