diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index c5657da1e..ce1f7e710 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -416,7 +416,7 @@ class ReadBookActivity : ReadBookBaseActivity(), * view触摸,文字选择 */ @SuppressLint("ClickableViewAccessibility") - override fun onTouch(v: View, event: MotionEvent): Boolean = with(binding) { + override fun onTouch(v: View, event: MotionEvent): Boolean = binding.run { when (event.action) { MotionEvent.ACTION_DOWN -> textActionMenu.dismiss() MotionEvent.ACTION_MOVE -> { @@ -439,7 +439,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * 更新文字选择开始位置 */ - override fun upSelectedStart(x: Float, y: Float, top: Float) = with(binding) { + override fun upSelectedStart(x: Float, y: Float, top: Float) = binding.run { cursorLeft.x = x - cursorLeft.width cursorLeft.y = y cursorLeft.visible(true) @@ -450,7 +450,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * 更新文字选择结束位置 */ - override fun upSelectedEnd(x: Float, y: Float) = with(binding) { + override fun upSelectedEnd(x: Float, y: Float) = binding.run { cursorRight.x = x cursorRight.y = y cursorRight.visible(true) @@ -459,7 +459,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * 取消文字选择 */ - override fun onCancelSelect() = with(binding) { + override fun onCancelSelect() = binding.run { cursorLeft.invisible() cursorRight.invisible() textActionMenu.dismiss() @@ -468,7 +468,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * 显示文本操作菜单 */ - override fun showTextActionMenu() = with(binding) { + override fun showTextActionMenu() = binding.run { textActionMenu.contentView.measure( View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED @@ -543,7 +543,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * 文本选择菜单操作完成 */ - override fun onMenuActionFinally() = with(binding) { + override fun onMenuActionFinally() = binding.run { textActionMenu.dismiss() readView.curPage.cancelSelect() readView.isTextSelected = false @@ -796,7 +796,7 @@ class ReadBookActivity : ReadBookBaseActivity(), /** * colorSelectDialog */ - override fun onColorSelected(dialogId: Int, color: Int) = with(ReadBookConfig.durConfig) { + override fun onColorSelected(dialogId: Int, color: Int) = ReadBookConfig.durConfig.run { when (dialogId) { TEXT_COLOR -> { setCurTextColor(color) @@ -899,7 +899,7 @@ class ReadBookActivity : ReadBookBaseActivity(), } } - override fun observeLiveBus() = with(binding) { + override fun observeLiveBus() = binding.run { super.observeLiveBus() observeEvent(EventBus.TIME_CHANGED) { readView.upTime() } observeEvent(EventBus.BATTERY_CHANGED) { readView.upBattery(it) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index a4e62fbce..671b7ba5d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -52,7 +52,7 @@ class ReadMenu @JvmOverloads constructor( bindEvent() } - private fun initView() = with(binding) { + private fun initView() = binding.run { if (AppConfig.isNightTheme) { fabNightTheme.setImageResource(R.drawable.ic_daytime) } else { @@ -134,7 +134,7 @@ class ReadMenu @JvmOverloads constructor( return context.getPrefBoolean("brightnessAuto", true) || !showBrightnessView } - private fun bindEvent() = with(binding) { + private fun bindEvent() = binding.run { tvChapterName.setOnClickListener { callBack.openSourceEditActivity() } @@ -304,7 +304,7 @@ class ReadMenu @JvmOverloads constructor( binding.seekReadPage.progress = seek } - fun setAutoPage(autoPage: Boolean) = with(binding) { + fun setAutoPage(autoPage: Boolean) = binding.run { if (autoPage) { fabAutoPage.setImageResource(R.drawable.ic_auto_page_stop) fabAutoPage.contentDescription = context.getString(R.string.auto_next_page_stop)