pull/32/head
kunfei 5 years ago
parent b0492a2138
commit 3c79168697
  1. 94
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 25
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt

@ -54,6 +54,7 @@ import org.jetbrains.anko.toast
class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_read_book),
PageView.CallBack,
ReadMenu.Callback,
ChangeSourceDialog.CallBack,
ReadBookViewModel.CallBack,
ColorPickerDialogListener {
@ -87,12 +88,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
Help.upSystemUiVisibility(window, !read_menu.isVisible)
upSystemUiVisibility()
}
override fun onResume() {
super.onResume()
Help.upSystemUiVisibility(window, !read_menu.isVisible)
upSystemUiVisibility()
timeElectricityReceiver = TimeElectricityReceiver.register(this)
}
@ -102,7 +103,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
unregisterReceiver(it)
timeElectricityReceiver = null
}
Help.upSystemUiVisibility(window, !read_menu.isVisible)
upSystemUiVisibility()
}
/**
@ -125,57 +126,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
startActivity(intent)
}
}
read_menu.setListener(object : ReadMenu.Callback {
override fun setScreenBrightness(value: Int) {
this@ReadBookActivity.setScreenBrightness(value)
}
override fun autoPage() {
}
override fun skipToPage(page: Int) {
viewModel.durPageIndex = page
page_view.upContent()
curPageChanged()
}
override fun skipPreChapter() {
moveToPrevChapter(false)
page_view.upContent()
}
override fun skipNextChapter() {
moveToNextChapter()
page_view.upContent()
}
override fun openReplaceRule() {
startActivity<ReplaceRuleActivity>()
}
override fun openChapterList() {
viewModel.bookData.value?.let {
startActivity<ChapterListActivity>(Pair("bookUrl", it.bookUrl))
}
}
override fun showReadStyle() {
ReadStyleDialog().show(supportFragmentManager, "readStyle")
}
override fun showMoreSetting() {
MoreConfigDialog().show(supportFragmentManager, "moreConfig")
}
override fun menuShow() {
Help.upSystemUiVisibility(window, !read_menu.isVisible)
}
override fun menuHide() {
Help.upSystemUiVisibility(window, !read_menu.isVisible)
}
})
}
fun showPaddingConfig() {
@ -445,6 +395,38 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
override fun autoPage() {
}
override fun skipToPage(page: Int) {
viewModel.durPageIndex = page
page_view.upContent()
curPageChanged()
}
override fun openReplaceRule() {
startActivity<ReplaceRuleActivity>()
}
override fun openChapterList() {
viewModel.bookData.value?.let {
startActivity<ChapterListActivity>(Pair("bookUrl", it.bookUrl))
}
}
override fun showReadStyle() {
ReadStyleDialog().show(supportFragmentManager, "readStyle")
}
override fun showMoreSetting() {
MoreConfigDialog().show(supportFragmentManager, "moreConfig")
}
override fun upSystemUiVisibility() {
Help.upSystemUiVisibility(window, !read_menu.isVisible)
}
/**
* 朗读按钮
*/
@ -479,7 +461,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
/**
* 设置屏幕亮度
*/
private fun setScreenBrightness(value: Int) {
override fun setScreenBrightness(value: Int) {
var brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
if (this.getPrefBoolean("brightnessAuto").not()) {
brightness = value.toFloat()
@ -560,7 +542,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
observeEvent<Boolean>(Bus.UP_CONFIG) {
Help.upSystemUiVisibility(window, !read_menu.isVisible)
upSystemUiVisibility()
page_view.upBg()
content_view.upStyle()
page_view.upStyle()

@ -17,9 +17,8 @@ import kotlinx.android.synthetic.main.view_read_menu.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
class ReadMenu : FrameLayout {
private var callback: Callback? = null
var cnaShowMenu: Boolean = false
private var callback: Callback? = null
private lateinit var menuTopIn: Animation
private lateinit var menuTopOut: Animation
private lateinit var menuBottomIn: Animation
@ -37,6 +36,7 @@ class ReadMenu : FrameLayout {
)
init {
callback = activity as? Callback
inflate(context, R.layout.view_read_menu, this)
if (context.isNightTheme) {
fabNightTheme.setImageResource(R.drawable.ic_daytime)
@ -48,6 +48,7 @@ class ReadMenu : FrameLayout {
vwNavigationBar.onClick { }
seek_brightness.progress = context.getPrefInt("brightness", 100)
upBrightness()
bindEvent()
}
private fun upBrightness() {
@ -61,11 +62,6 @@ class ReadMenu : FrameLayout {
callback?.setScreenBrightness(context.getPrefInt("brightness", 100))
}
fun setListener(callback: Callback) {
this.callback = callback
bindEvent()
}
fun runMenuIn() {
this.visible()
title_bar.visible()
@ -138,10 +134,10 @@ class ReadMenu : FrameLayout {
}
//上一章
tv_pre.onClick { callback?.skipPreChapter() }
tv_pre.onClick { callback?.moveToPrevChapter(false) }
//下一章
tv_next.onClick { callback?.skipNextChapter() }
tv_next.onClick { callback?.moveToNextChapter() }
//目录
ll_catalog.onClick {
@ -177,7 +173,7 @@ class ReadMenu : FrameLayout {
menuBottomIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuTopIn.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
callback?.menuShow()
callback?.upSystemUiVisibility()
}
override fun onAnimationEnd(animation: Animation) {
@ -211,7 +207,7 @@ class ReadMenu : FrameLayout {
bottom_menu.invisible()
cnaShowMenu = false
onMenuOutEnd?.invoke()
callback?.menuHide()
callback?.upSystemUiVisibility()
}
override fun onAnimationRepeat(animation: Animation) {
@ -234,14 +230,13 @@ class ReadMenu : FrameLayout {
fun setScreenBrightness(value: Int)
fun autoPage()
fun skipToPage(page: Int)
fun skipPreChapter()
fun skipNextChapter()
fun moveToPrevChapter(last: Boolean)
fun moveToNextChapter()
fun openReplaceRule()
fun openChapterList()
fun showReadStyle()
fun showMoreSetting()
fun menuShow()
fun menuHide()
fun upSystemUiVisibility()
}
}

Loading…
Cancel
Save