feat: 优化代码

pull/141/head
kunfei 5 years ago
parent 5cdcde0528
commit dda8ac997f
  1. 42
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt

@ -166,31 +166,29 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack {
}
@SuppressLint("InflateParams")
private fun showTitleConfig() {
private fun showTitleConfig() = ReadBookConfig.apply {
requireContext().alert(R.string.title) {
val rootView = LayoutInflater.from(requireContext())
.inflate(R.layout.dialog_title_config, null).apply {
ReadBookConfig.apply {
rg_title_mode.checkByIndex(titleMode)
dsb_title_size.progress = titleSize
dsb_title_top.progress = titleTopSpacing
dsb_title_bottom.progress = titleBottomSpacing
rg_title_mode.onCheckedChange { _, checkedId ->
titleMode = rg_title_mode.getIndexById(checkedId)
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_size.onChanged = {
titleSize = it
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_top.onChanged = {
titleTopSpacing = it
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_bottom.onChanged = {
titleBottomSpacing = it
postEvent(EventBus.UP_CONFIG, true)
}
rg_title_mode.checkByIndex(titleMode)
dsb_title_size.progress = titleSize
dsb_title_top.progress = titleTopSpacing
dsb_title_bottom.progress = titleBottomSpacing
rg_title_mode.onCheckedChange { _, checkedId ->
titleMode = rg_title_mode.getIndexById(checkedId)
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_size.onChanged = {
titleSize = it
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_top.onChanged = {
titleTopSpacing = it
postEvent(EventBus.UP_CONFIG, true)
}
dsb_title_bottom.onChanged = {
titleBottomSpacing = it
postEvent(EventBus.UP_CONFIG, true)
}
}
customView = rootView

Loading…
Cancel
Save