pull/1110/head
gedoor 4 years ago
parent 8a04100945
commit 279355cf24
  1. 2
      app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/cache/CacheAdapter.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/changecover/CoverAdapter.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  7. 6
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  8. 2
      app/src/main/java/io/legado/app/ui/book/local/ImportBookAdapter.kt
  9. 4
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt
  10. 24
      app/src/main/java/io/legado/app/ui/book/read/config/AutoReadDialog.kt
  11. 2
      app/src/main/java/io/legado/app/ui/book/read/config/BgAdapter.kt
  12. 2
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  13. 18
      app/src/main/java/io/legado/app/ui/book/read/config/ClickActionConfigDialog.kt
  14. 88
      app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt
  15. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  16. 6
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt
  17. 6
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  18. 4
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  19. 4
      app/src/main/java/io/legado/app/ui/book/read/config/TipConfigDialog.kt
  20. 2
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  21. 6
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  22. 2
      app/src/main/java/io/legado/app/ui/book/search/BookAdapter.kt
  23. 2
      app/src/main/java/io/legado/app/ui/book/search/HistoryKeyAdapter.kt
  24. 8
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  25. 2
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentAdapter.kt
  26. 2
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt
  27. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt
  28. 2
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  29. 2
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt
  30. 4
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  31. 4
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt
  32. 2
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  33. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksAdapterGrid.kt
  34. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksAdapterList.kt
  35. 2
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  36. 4
      app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt
  37. 2
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt
  38. 4
      app/src/main/java/io/legado/app/ui/replace/edit/ReplaceEditActivity.kt
  39. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter.kt
  40. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter1.kt
  41. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesAdapter2.kt
  42. 2
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  43. 2
      app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesAdapter.kt
  44. 2
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt
  45. 4
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  46. 2
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceAdapter.kt
  47. 2
      app/src/main/java/io/legado/app/ui/widget/KeyboardToolPop.kt
  48. 8
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt
  49. 2
      app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt
  50. 2
      app/src/main/java/io/legado/app/ui/widget/font/FontAdapter.kt
  51. 2
      app/src/main/java/io/legado/app/ui/widget/prefs/IconListPreference.kt

@ -56,7 +56,7 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
readRecord.tvBookName.setText(R.string.all_read_time) readRecord.tvBookName.setText(R.string.all_read_time)
adapter = RecordAdapter(this@ReadRecordActivity) adapter = RecordAdapter(this@ReadRecordActivity)
recyclerView.adapter = adapter recyclerView.adapter = adapter

@ -31,7 +31,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) :
item: Book, item: Book,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
tvName.text = item.name tvName.text = item.name
tvAuthor.text = context.getString(R.string.author_show, item.getRealAuthor()) tvAuthor.text = context.getString(R.string.author_show, item.getRealAuthor())
@ -53,7 +53,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) :
} }
override fun registerListener(holder: ItemViewHolder, binding: ItemDownloadBinding) { override fun registerListener(holder: ItemViewHolder, binding: ItemDownloadBinding) {
with(binding) { binding.run {
ivDownload.setOnClickListener { ivDownload.setOnClickListener {
getItem(holder.layoutPosition)?.let { getItem(holder.layoutPosition)?.let {
if (downloadMap?.containsKey(it.bookUrl) == true) { if (downloadMap?.containsKey(it.bookUrl) == true) {

@ -34,7 +34,7 @@ class CoverAdapter(context: Context, val callBack: CallBack) :
binding: ItemCoverBinding, binding: ItemCoverBinding,
item: SearchBook, item: SearchBook,
payloads: MutableList<Any> payloads: MutableList<Any>
) = with(binding) { ) = binding.run {
ivCover.load(item.coverUrl, item.name, item.author) ivCover.load(item.coverUrl, item.name, item.author)
tvSource.text = item.originName tvSource.text = item.originName
} }

@ -160,7 +160,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
item: BookGroup, item: BookGroup,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
tvGroup.text = item.getManageName(context) tvGroup.text = item.getManageName(context)
swShow.isChecked = item.show swShow.isChecked = item.show
@ -168,7 +168,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
override fun registerListener(holder: ItemViewHolder, binding: ItemBookGroupManageBinding) { override fun registerListener(holder: ItemViewHolder, binding: ItemBookGroupManageBinding) {
with(binding) { binding.run {
tvEdit.setOnClickListener { getItem(holder.layoutPosition)?.let { editGroup(it) } } tvEdit.setOnClickListener { getItem(holder.layoutPosition)?.let { editGroup(it) } }
swShow.setOnCheckedChangeListener { buttonView, isChecked -> swShow.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) { if (buttonView.isPressed) {

@ -168,7 +168,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
item: BookGroup, item: BookGroup,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
cbGroup.text = item.groupName cbGroup.text = item.groupName
cbGroup.isChecked = (groupId and item.groupId) > 0 cbGroup.isChecked = (groupId and item.groupId) > 0
@ -176,7 +176,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
override fun registerListener(holder: ItemViewHolder, binding: ItemGroupSelectBinding) { override fun registerListener(holder: ItemViewHolder, binding: ItemGroupSelectBinding) {
with(binding) { binding.run {
cbGroup.setOnCheckedChangeListener { buttonView, isChecked -> cbGroup.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) { if (buttonView.isPressed) {
getItem(holder.layoutPosition)?.let { getItem(holder.layoutPosition)?.let {

@ -172,7 +172,7 @@ class BookInfoActivity :
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
private fun showBook(book: Book) = with(binding) { private fun showBook(book: Book) = binding.run {
showCover(book) showCover(book)
tvName.text = book.name tvName.text = book.name
tvAuthor.text = getString(R.string.author_show, book.getRealAuthor()) tvAuthor.text = getString(R.string.author_show, book.getRealAuthor())
@ -243,7 +243,7 @@ class BookInfoActivity :
} }
} }
private fun initOnClick() = with(binding) { private fun initOnClick() = binding.run {
ivCover.setOnClickListener { ivCover.setOnClickListener {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author) ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)

@ -55,7 +55,7 @@ class BookInfoEditActivity :
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
private fun initEvent() = with(binding) { private fun initEvent() = binding.run {
tvChangeCover.setOnClickListener { tvChangeCover.setOnClickListener {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author) ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
@ -70,7 +70,7 @@ class BookInfoEditActivity :
} }
} }
private fun upView(book: Book) = with(binding) { private fun upView(book: Book) = binding.run {
tieBookName.setText(book.name) tieBookName.setText(book.name)
tieBookAuthor.setText(book.author) tieBookAuthor.setText(book.author)
tieCoverUrl.setText(book.getDisplayCover()) tieCoverUrl.setText(book.getDisplayCover())
@ -84,7 +84,7 @@ class BookInfoEditActivity :
} }
} }
private fun saveData() = with(binding) { private fun saveData() = binding.run {
viewModel.book?.let { book -> viewModel.book?.let { book ->
book.name = tieBookName.text?.toString() ?: "" book.name = tieBookName.text?.toString() ?: ""
book.author = tieBookAuthor.text?.toString() ?: "" book.author = tieBookAuthor.text?.toString() ?: ""

@ -31,7 +31,7 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) :
item: DocItem, item: DocItem,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
if (item.isDir) { if (item.isDir) {
ivIcon.setImageResource(R.drawable.ic_folder) ivIcon.setImageResource(R.drawable.ic_folder)

@ -53,7 +53,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
initRecyclerView() initRecyclerView()
} }
private fun initRecyclerView() = with(binding) { private fun initRecyclerView() = binding.run {
recyclerView.adapter = adapter recyclerView.adapter = adapter
SupportMenuInflater(context).inflate(R.menu.content_select_action, menu) SupportMenuInflater(context).inflate(R.menu.content_select_action, menu)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -75,7 +75,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
item: MenuItemImpl, item: MenuItemImpl,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
textView.text = item.title textView.text = item.title
} }
} }

@ -52,21 +52,21 @@ class AutoReadDialog : BaseDialogFragment() {
return inflater.inflate(R.layout.dialog_auto_read, container) return inflater.inflate(R.layout.dialog_auto_read, container)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
val bg = requireContext().bottomBackground val bg = requireContext().bottomBackground
val isLight = ColorUtils.isColorLight(bg) val isLight = ColorUtils.isColorLight(bg)
val textColor = requireContext().getPrimaryTextColor(isLight) val textColor = requireContext().getPrimaryTextColor(isLight)
binding.root.setBackgroundColor(bg) root.setBackgroundColor(bg)
binding.tvReadSpeedTitle.setTextColor(textColor) tvReadSpeedTitle.setTextColor(textColor)
binding.tvReadSpeed.setTextColor(textColor) tvReadSpeed.setTextColor(textColor)
binding.ivCatalog.setColorFilter(textColor) ivCatalog.setColorFilter(textColor)
binding.tvCatalog.setTextColor(textColor) tvCatalog.setTextColor(textColor)
binding.ivMainMenu.setColorFilter(textColor) ivMainMenu.setColorFilter(textColor)
binding.tvMainMenu.setTextColor(textColor) tvMainMenu.setTextColor(textColor)
binding.ivAutoPageStop.setColorFilter(textColor) ivAutoPageStop.setColorFilter(textColor)
binding.tvAutoPageStop.setTextColor(textColor) tvAutoPageStop.setTextColor(textColor)
binding.ivSetting.setColorFilter(textColor) ivSetting.setColorFilter(textColor)
binding.tvSetting.setTextColor(textColor) tvSetting.setTextColor(textColor)
initOnChange() initOnChange()
initData() initData()
initEvent() initEvent()

@ -25,7 +25,7 @@ class BgAdapter(context: Context, val textColor: Int) :
item: String, item: String,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
ImageLoader.load( ImageLoader.load(
context, context,
context.assets.open("bg${File.separator}$item").readBytes() context.assets.open("bg${File.separator}$item").readBytes()

@ -98,7 +98,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
(activity as ReadBookActivity).bottomDialog-- (activity as ReadBookActivity).bottomDialog--
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
val bg = requireContext().bottomBackground val bg = requireContext().bottomBackground
val isLight = ColorUtils.isColorLight(bg) val isLight = ColorUtils.isColorLight(bg)
primaryTextColor = requireContext().getPrimaryTextColor(isLight) primaryTextColor = requireContext().getPrimaryTextColor(isLight)

@ -56,15 +56,15 @@ class ClickActionConfigDialog : BaseDialogFragment() {
initViewEvent() initViewEvent()
} }
private fun initData() = with(AppConfig) { private fun initData() = binding.run {
binding.tvTopLeft.text = actions[clickActionTL] tvTopLeft.text = actions[AppConfig.clickActionTL]
binding.tvTopCenter.text = actions[clickActionTC] tvTopCenter.text = actions[AppConfig.clickActionTC]
binding.tvTopRight.text = actions[clickActionTR] tvTopRight.text = actions[AppConfig.clickActionTR]
binding.tvMiddleLeft.text = actions[clickActionML] tvMiddleLeft.text = actions[AppConfig.clickActionML]
binding.tvMiddleRight.text = actions[clickActionMR] tvMiddleRight.text = actions[AppConfig.clickActionMR]
binding.tvBottomLeft.text = actions[clickActionBL] tvBottomLeft.text = actions[AppConfig.clickActionBL]
binding.tvBottomCenter.text = actions[clickActionBC] tvBottomCenter.text = actions[AppConfig.clickActionBC]
binding.tvBottomRight.text = actions[clickActionBR] tvBottomRight.text = actions[AppConfig.clickActionBR]
} }
private fun initViewEvent() { private fun initViewEvent() {

@ -49,84 +49,84 @@ class PaddingConfigDialog : BaseDialogFragment() {
ReadBookConfig.save() ReadBookConfig.save()
} }
private fun initData() = ReadBookConfig.apply { private fun initData() = binding.run {
//正文 //正文
binding.dsbPaddingTop.progress = paddingTop dsbPaddingTop.progress = ReadBookConfig.paddingTop
binding.dsbPaddingBottom.progress = paddingBottom dsbPaddingBottom.progress = ReadBookConfig.paddingBottom
binding.dsbPaddingLeft.progress = paddingLeft dsbPaddingLeft.progress = ReadBookConfig.paddingLeft
binding.dsbPaddingRight.progress = paddingRight dsbPaddingRight.progress = ReadBookConfig.paddingRight
//页眉 //页眉
binding.dsbHeaderPaddingTop.progress = headerPaddingTop dsbHeaderPaddingTop.progress = ReadBookConfig.headerPaddingTop
binding.dsbHeaderPaddingBottom.progress = headerPaddingBottom dsbHeaderPaddingBottom.progress = ReadBookConfig.headerPaddingBottom
binding.dsbHeaderPaddingLeft.progress = headerPaddingLeft dsbHeaderPaddingLeft.progress = ReadBookConfig.headerPaddingLeft
binding.dsbHeaderPaddingRight.progress = headerPaddingRight dsbHeaderPaddingRight.progress = ReadBookConfig.headerPaddingRight
//页脚 //页脚
binding.dsbFooterPaddingTop.progress = footerPaddingTop dsbFooterPaddingTop.progress = ReadBookConfig.footerPaddingTop
binding.dsbFooterPaddingBottom.progress = footerPaddingBottom dsbFooterPaddingBottom.progress = ReadBookConfig.footerPaddingBottom
binding.dsbFooterPaddingLeft.progress = footerPaddingLeft dsbFooterPaddingLeft.progress = ReadBookConfig.footerPaddingLeft
binding.dsbFooterPaddingRight.progress = footerPaddingRight dsbFooterPaddingRight.progress = ReadBookConfig.footerPaddingRight
binding.cbShowTopLine.isChecked = showHeaderLine cbShowTopLine.isChecked = ReadBookConfig.showHeaderLine
binding.cbShowBottomLine.isChecked = showFooterLine cbShowBottomLine.isChecked = ReadBookConfig.showFooterLine
} }
private fun initView() = with(ReadBookConfig) { private fun initView() = binding.run {
//正文 //正文
binding.dsbPaddingTop.onChanged = { dsbPaddingTop.onChanged = {
paddingTop = it ReadBookConfig.paddingTop = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbPaddingBottom.onChanged = { dsbPaddingBottom.onChanged = {
paddingBottom = it ReadBookConfig.paddingBottom = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbPaddingLeft.onChanged = { dsbPaddingLeft.onChanged = {
paddingLeft = it ReadBookConfig.paddingLeft = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbPaddingRight.onChanged = { dsbPaddingRight.onChanged = {
paddingRight = it ReadBookConfig.paddingRight = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
//页眉 //页眉
binding.dsbHeaderPaddingTop.onChanged = { dsbHeaderPaddingTop.onChanged = {
headerPaddingTop = it ReadBookConfig.headerPaddingTop = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbHeaderPaddingBottom.onChanged = { dsbHeaderPaddingBottom.onChanged = {
headerPaddingBottom = it ReadBookConfig.headerPaddingBottom = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbHeaderPaddingLeft.onChanged = { dsbHeaderPaddingLeft.onChanged = {
headerPaddingLeft = it ReadBookConfig.headerPaddingLeft = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbHeaderPaddingRight.onChanged = { dsbHeaderPaddingRight.onChanged = {
headerPaddingRight = it ReadBookConfig.headerPaddingRight = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
//页脚 //页脚
binding.dsbFooterPaddingTop.onChanged = { dsbFooterPaddingTop.onChanged = {
footerPaddingTop = it ReadBookConfig.footerPaddingTop = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbFooterPaddingBottom.onChanged = { dsbFooterPaddingBottom.onChanged = {
footerPaddingBottom = it ReadBookConfig.footerPaddingBottom = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbFooterPaddingLeft.onChanged = { dsbFooterPaddingLeft.onChanged = {
footerPaddingLeft = it ReadBookConfig.footerPaddingLeft = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.dsbFooterPaddingRight.onChanged = { dsbFooterPaddingRight.onChanged = {
footerPaddingRight = it ReadBookConfig.footerPaddingRight = it
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.cbShowTopLine.onCheckedChangeListener = { _, isChecked -> cbShowTopLine.onCheckedChangeListener = { _, isChecked ->
showHeaderLine = isChecked ReadBookConfig.showHeaderLine = isChecked
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
binding.cbShowBottomLine.onCheckedChangeListener = { _, isChecked -> cbShowBottomLine.onCheckedChangeListener = { _, isChecked ->
showFooterLine = isChecked ReadBookConfig.showFooterLine = isChecked
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
} }

@ -39,7 +39,7 @@ class ReadAloudConfigDialog : DialogFragment() {
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View {
val view = LinearLayout(requireContext()) val view = LinearLayout(requireContext())
view.setBackgroundColor(requireContext().backgroundColor) view.setBackgroundColor(requireContext().backgroundColor)
view.id = R.id.tag1 view.id = R.id.tag1

@ -60,7 +60,7 @@ class ReadAloudDialog : BaseDialogFragment() {
val bg = requireContext().bottomBackground val bg = requireContext().bottomBackground
val isLight = ColorUtils.isColorLight(bg) val isLight = ColorUtils.isColorLight(bg)
val textColor = requireContext().getPrimaryTextColor(isLight) val textColor = requireContext().getPrimaryTextColor(isLight)
with(binding) { binding.run {
rootView.setBackgroundColor(bg) rootView.setBackgroundColor(bg)
tvPre.setTextColor(textColor) tvPre.setTextColor(textColor)
tvNext.setTextColor(textColor) tvNext.setTextColor(textColor)
@ -85,7 +85,7 @@ class ReadAloudDialog : BaseDialogFragment() {
initEvent() initEvent()
} }
private fun initData() = with(binding) { private fun initData() = binding.run {
upPlayState() upPlayState()
upTimerText(BaseReadAloudService.timeMinute) upTimerText(BaseReadAloudService.timeMinute)
seekTimer.progress = BaseReadAloudService.timeMinute seekTimer.progress = BaseReadAloudService.timeMinute
@ -94,7 +94,7 @@ class ReadAloudDialog : BaseDialogFragment() {
seekTtsSpeechRate.progress = AppConfig.ttsSpeechRate seekTtsSpeechRate.progress = AppConfig.ttsSpeechRate
} }
private fun initEvent() = with(binding) { private fun initEvent() = binding.run {
llMainMenu.setOnClickListener { llMainMenu.setOnClickListener {
callBack?.showMenuBar() callBack?.showMenuBar()
dismissAllowingStateLoss() dismissAllowingStateLoss()

@ -66,7 +66,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
(activity as ReadBookActivity).bottomDialog-- (activity as ReadBookActivity).bottomDialog--
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
val bg = requireContext().bottomBackground val bg = requireContext().bottomBackground
val isLight = ColorUtils.isColorLight(bg) val isLight = ColorUtils.isColorLight(bg)
val textColor = requireContext().getPrimaryTextColor(isLight) val textColor = requireContext().getPrimaryTextColor(isLight)
@ -105,7 +105,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
styleAdapter.setItems(ReadBookConfig.configList) styleAdapter.setItems(ReadBookConfig.configList)
} }
private fun initViewEvent() = with(binding) { private fun initViewEvent() = binding.run {
chineseConverter.onChanged { chineseConverter.onChanged {
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)
} }
@ -178,7 +178,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
return true return true
} }
private fun upView() = with(binding) { private fun upView() = binding.run {
ReadBook.pageAnim().let { ReadBook.pageAnim().let {
if (it >= 0 && it < rgPageAnim.childCount) { if (it >= 0 && it < rgPageAnim.childCount) {
rgPageAnim.check(rgPageAnim[it].id) rgPageAnim.check(rgPageAnim[it].id)

@ -72,7 +72,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
initData() initData()
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
toolBar.setBackgroundColor(primaryColor) toolBar.setBackgroundColor(primaryColor)
toolBar.setTitle(R.string.speak_engine) toolBar.setTitle(R.string.speak_engine)
ATH.applyEdgeEffectColor(recyclerView) ATH.applyEdgeEffectColor(recyclerView)
@ -96,7 +96,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
} }
private fun initMenu() = with(binding) { private fun initMenu() = binding.run {
toolBar.inflateMenu(R.menu.speak_engine) toolBar.inflateMenu(R.menu.speak_engine)
toolBar.menu.applyTint(requireContext()) toolBar.menu.applyTint(requireContext())
toolBar.setOnMenuItemClickListener(this@SpeakEngineDialog) toolBar.setOnMenuItemClickListener(this@SpeakEngineDialog)

@ -46,7 +46,7 @@ class TipConfigDialog : BaseDialogFragment() {
} }
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
rgTitleMode.checkByIndex(ReadBookConfig.titleMode) rgTitleMode.checkByIndex(ReadBookConfig.titleMode)
dsbTitleSize.progress = ReadBookConfig.titleSize dsbTitleSize.progress = ReadBookConfig.titleSize
dsbTitleTop.progress = ReadBookConfig.titleTopSpacing dsbTitleTop.progress = ReadBookConfig.titleTopSpacing
@ -74,7 +74,7 @@ class TipConfigDialog : BaseDialogFragment() {
} }
} }
private fun initEvent() = with(binding) { private fun initEvent() = binding.run {
rgTitleMode.setOnCheckedChangeListener { _, checkedId -> rgTitleMode.setOnCheckedChangeListener { _, checkedId ->
ReadBookConfig.titleMode = rgTitleMode.getIndexById(checkedId) ReadBookConfig.titleMode = rgTitleMode.getIndexById(checkedId)
postEvent(EventBus.UP_CONFIG, true) postEvent(EventBus.UP_CONFIG, true)

@ -69,7 +69,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
initData() initData()
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
adapter = TocRegexAdapter(requireContext()) adapter = TocRegexAdapter(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter

@ -55,7 +55,7 @@ class PageView(context: Context) : FrameLayout(context) {
} }
} }
fun upStyle() = with(binding) { fun upStyle() = binding.run {
upTipStyle() upTipStyle()
ReadBookConfig.let { ReadBookConfig.let {
val tipColor = with(ReadTipConfig) { val tipColor = with(ReadTipConfig) {
@ -102,7 +102,7 @@ class PageView(context: Context) : FrameLayout(context) {
ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true ReadBookConfig.hideStatusBar || (activity as? BaseActivity<*>)?.isInMultiWindow == true
} }
private fun upTipStyle() = with(binding) { private fun upTipStyle() = binding.run {
ReadTipConfig.apply { ReadTipConfig.apply {
tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle tvHeaderLeft.isInvisible = tipHeaderLeft != chapterTitle
bvHeaderLeft.isInvisible = bvHeaderLeft.isInvisible =
@ -173,7 +173,7 @@ class PageView(context: Context) : FrameLayout(context) {
} }
} }
private fun getTipView(tip: Int): BatteryView? = with(binding) { private fun getTipView(tip: Int): BatteryView? = binding.run {
return when (tip) { return when (tip) {
ReadTipConfig.tipHeaderLeft -> ReadTipConfig.tipHeaderLeft ->
if (tip == ReadTipConfig.chapterTitle) tvHeaderLeft else bvHeaderLeft if (tip == ReadTipConfig.chapterTitle) tvHeaderLeft else bvHeaderLeft

@ -21,7 +21,7 @@ class BookAdapter(context: Context, val callBack: CallBack) :
item: Book, item: Book,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
textView.text = item.name textView.text = item.name
} }
} }

@ -27,7 +27,7 @@ class HistoryKeyAdapter(activity: SearchActivity, val callBack: CallBack) :
item: SearchKeyword, item: SearchKeyword,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
textView.text = item.word textView.text = item.word
} }
} }

@ -74,7 +74,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
} }
private fun bind(binding: ItemSearchBinding, searchBook: SearchBook) { private fun bind(binding: ItemSearchBinding, searchBook: SearchBook) {
with(binding) { binding.run {
tvName.text = searchBook.name tvName.text = searchBook.name
tvAuthor.text = context.getString(R.string.author_show, searchBook.author) tvAuthor.text = context.getString(R.string.author_show, searchBook.author)
bvOriginCount.setBadgeCount(searchBook.origins.size) bvOriginCount.setBadgeCount(searchBook.origins.size)
@ -87,7 +87,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
} }
private fun bindChange(binding: ItemSearchBinding, searchBook: SearchBook, bundle: Bundle) { private fun bindChange(binding: ItemSearchBinding, searchBook: SearchBook, bundle: Bundle) {
with(binding) { binding.run {
bundle.keySet().map { bundle.keySet().map {
when (it) { when (it) {
"origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size) "origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size)
@ -105,7 +105,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
} }
private fun upLasted(binding: ItemSearchBinding, latestChapterTitle: String?) { private fun upLasted(binding: ItemSearchBinding, latestChapterTitle: String?) {
with(binding) { binding.run {
if (latestChapterTitle.isNullOrEmpty()) { if (latestChapterTitle.isNullOrEmpty()) {
tvLasted.gone() tvLasted.gone()
} else { } else {
@ -116,7 +116,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
} }
} }
private fun upKind(binding: ItemSearchBinding, kinds: List<String>) = with(binding) { private fun upKind(binding: ItemSearchBinding, kinds: List<String>) = binding.run {
if (kinds.isEmpty()) { if (kinds.isEmpty()) {
llKind.gone() llKind.gone()
} else { } else {

@ -28,7 +28,7 @@ class SearchContentAdapter(context: Context, val callback: Callback) :
item: SearchResult, item: SearchResult,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val isDur = callback.durChapterIndex() == item.chapterIndex val isDur = callback.durChapterIndex() == item.chapterIndex
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
tvSearchResult.text = item.getHtmlCompat(textColor, accentColor) tvSearchResult.text = item.getHtmlCompat(textColor, accentColor)

@ -33,7 +33,7 @@ class BookSourceEditAdapter : RecyclerView.Adapter<BookSourceEditAdapter.MyViewH
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) { class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(editEntity: EditEntity) = with(binding) { fun bind(editEntity: EditEntity) = binding.run {
if (editText.getTag(R.id.tag1) == null) { if (editText.getTag(R.id.tag1) == null) {
val listener = object : View.OnAttachStateChangeListener { val listener = object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) { override fun onViewAttachedToWindow(v: View) {

@ -84,7 +84,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
item: BookSource, item: BookSource,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val payload = payloads.getOrNull(0) as? Bundle val payload = payloads.getOrNull(0) as? Bundle
if (payload == null) { if (payload == null) {
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))

@ -125,7 +125,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
item: String, item: String,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
tvGroup.text = item tvGroup.text = item
} }

@ -27,7 +27,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
item: BookChapter, item: BookChapter,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val isDur = callback.durChapterIndex() == item.index val isDur = callback.durChapterIndex() == item.index
val cached = callback.isLocalBook || cacheFileNames.contains(item.getFileName()) val cached = callback.isLocalBook || cacheFileNames.contains(item.getFileName())
if (payloads.isEmpty()) { if (payloads.isEmpty()) {

@ -39,7 +39,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
private var tocLiveData: LiveData<List<BookChapter>>? = null private var tocLiveData: LiveData<List<BookChapter>>? = null
private var scrollToDurChapter = false private var scrollToDurChapter = false
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = with(binding) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
viewModel.chapterCallBack = this@ChapterListFragment viewModel.chapterCallBack = this@ChapterListFragment
val bbg = bottomBackground val bbg = bottomBackground
val btc = requireContext().getPrimaryTextColor(ColorUtils.isColorLight(bbg)) val btc = requireContext().getPrimaryTextColor(ColorUtils.isColorLight(bbg))
@ -62,7 +62,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
ivChapterTop.setOnClickListener { mLayoutManager.scrollToPositionWithOffset(0, 0) } ivChapterTop.setOnClickListener { mLayoutManager.scrollToPositionWithOffset(0, 0) }
ivChapterBottom.setOnClickListener { ivChapterBottom.setOnClickListener {
if (adapter.itemCount > 0) { if (adapter.itemCount > 0) {

@ -46,14 +46,14 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
initData() initData()
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
adapter = Adapter() adapter = Adapter()
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter
} }
private fun initMenu() = with(binding) { private fun initMenu() = binding.run {
toolBar.setOnMenuItemClickListener(this@ThemeListDialog) toolBar.setOnMenuItemClickListener(this@ThemeListDialog)
toolBar.inflateMenu(R.menu.theme_list) toolBar.inflateMenu(R.menu.theme_list)
toolBar.menu.applyTint(requireContext()) toolBar.menu.applyTint(requireContext())

@ -82,7 +82,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
}, 3000) }, 3000)
} }
override fun onNavigationItemSelected(item: MenuItem): Boolean = with(binding) { override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run {
when (item.itemId) { when (item.itemId) {
R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false) R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false)
R.id.menu_discovery -> viewPagerMain.setCurrentItem(1, false) R.id.menu_discovery -> viewPagerMain.setCurrentItem(1, false)

@ -23,7 +23,7 @@ class BooksAdapterGrid(context: Context, private val callBack: CallBack) :
binding: ItemBookshelfGridBinding, binding: ItemBookshelfGridBinding,
item: Book, item: Book,
payloads: MutableList<Any> payloads: MutableList<Any>
) = with(binding) { ) = binding.run {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
tvName.text = item.name tvName.text = item.name

@ -23,7 +23,7 @@ class BooksAdapterList(context: Context, private val callBack: CallBack) :
binding: ItemBookshelfListBinding, binding: ItemBookshelfListBinding,
item: Book, item: Book,
payloads: MutableList<Any> payloads: MutableList<Any>
) = with(binding) { ) = binding.run {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
tvName.text = item.name tvName.text = item.name

@ -36,7 +36,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
item: BookSource, item: BookSource,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
if (holder.layoutPosition == itemCount - 1) { if (holder.layoutPosition == itemCount - 1) {
root.setPadding(16.dp, 12.dp, 16.dp, 12.dp) root.setPadding(16.dp, 12.dp, 16.dp, 12.dp)
} else { } else {

@ -53,7 +53,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
initData() initData()
} }
private fun initData() = with(binding) { private fun initData() = binding.run {
toolBar.title = getString(R.string.group_manage) toolBar.title = getString(R.string.group_manage)
toolBar.inflateMenu(R.menu.group_manage) toolBar.inflateMenu(R.menu.group_manage)
toolBar.menu.applyTint(requireContext()) toolBar.menu.applyTint(requireContext())
@ -126,7 +126,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
item: String, item: String,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
tvGroup.text = item tvGroup.text = item
} }

@ -108,7 +108,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) :
item: ReplaceRule, item: ReplaceRule,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))

@ -90,7 +90,7 @@ class ReplaceEditActivity :
return true return true
} }
private fun upReplaceView(replaceRule: ReplaceRule) = with(binding) { private fun upReplaceView(replaceRule: ReplaceRule) = binding.run {
etName.setText(replaceRule.name) etName.setText(replaceRule.name)
etGroup.setText(replaceRule.group) etGroup.setText(replaceRule.group)
etReplaceRule.setText(replaceRule.pattern) etReplaceRule.setText(replaceRule.pattern)
@ -99,7 +99,7 @@ class ReplaceEditActivity :
etScope.setText(replaceRule.scope) etScope.setText(replaceRule.scope)
} }
private fun getReplaceRule(): ReplaceRule = with(binding) { private fun getReplaceRule(): ReplaceRule = binding.run {
val replaceRule: ReplaceRule = viewModel.replaceRule ?: ReplaceRule() val replaceRule: ReplaceRule = viewModel.replaceRule ?: ReplaceRule()
replaceRule.name = etName.text.toString() replaceRule.name = etName.text.toString()
replaceRule.group = etGroup.text.toString() replaceRule.group = etGroup.text.toString()

@ -30,7 +30,7 @@ class RssArticlesAdapter(context: Context, callBack: CallBack) :
item: RssArticle, item: RssArticle,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
tvTitle.text = item.title tvTitle.text = item.title
tvPubDate.text = item.pubDate tvPubDate.text = item.pubDate
if (item.image.isNullOrBlank() && !callBack.isGridLayout) { if (item.image.isNullOrBlank() && !callBack.isGridLayout) {

@ -30,7 +30,7 @@ class RssArticlesAdapter1(context: Context, callBack: CallBack) :
item: RssArticle, item: RssArticle,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
tvTitle.text = item.title tvTitle.text = item.title
tvPubDate.text = item.pubDate tvPubDate.text = item.pubDate
if (item.image.isNullOrBlank() && !callBack.isGridLayout) { if (item.image.isNullOrBlank() && !callBack.isGridLayout) {

@ -30,7 +30,7 @@ class RssArticlesAdapter2(context: Context, callBack: CallBack) :
item: RssArticle, item: RssArticle,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
tvTitle.text = item.title tvTitle.text = item.title
tvPubDate.text = item.pubDate tvPubDate.text = item.pubDate
if (item.image.isNullOrBlank() && !callBack.isGridLayout) { if (item.image.isNullOrBlank() && !callBack.isGridLayout) {

@ -53,7 +53,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
initData() initData()
} }
private fun initView() = with(binding) { private fun initView() = binding.run {
refreshLayout.setColorSchemeColors(accentColor) refreshLayout.setColorSchemeColors(accentColor)
ATH.applyEdgeEffectColor(recyclerView) ATH.applyEdgeEffectColor(recyclerView)
recyclerView.layoutManager = if (activityViewModel.isGridLayout) { recyclerView.layoutManager = if (activityViewModel.isGridLayout) {

@ -29,7 +29,7 @@ class RssFavoritesAdapter(context: Context, val callBack: CallBack) :
item: RssStar, item: RssStar,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
tvTitle.text = item.title tvTitle.text = item.title
tvPubDate.text = item.pubDate tvPubDate.text = item.pubDate
if (item.image.isNullOrBlank()) { if (item.image.isNullOrBlank()) {

@ -33,7 +33,7 @@ class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHol
class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) { class MyViewHolder(val binding: ItemSourceEditBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(editEntity: EditEntity) = with(binding) { fun bind(editEntity: EditEntity) = binding.run {
if (editText.getTag(R.id.tag1) == null) { if (editText.getTag(R.id.tag1) == null) {
val listener = object : View.OnAttachStateChangeListener { val listener = object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) { override fun onViewAttachedToWindow(v: View) {

@ -47,7 +47,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
return inflater.inflate(R.layout.dialog_recycler_view, container) return inflater.inflate(R.layout.dialog_recycler_view, container)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = with(binding) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
toolBar.setBackgroundColor(primaryColor) toolBar.setBackgroundColor(primaryColor)
toolBar.title = getString(R.string.group_manage) toolBar.title = getString(R.string.group_manage)
toolBar.inflateMenu(R.menu.group_manage) toolBar.inflateMenu(R.menu.group_manage)
@ -128,7 +128,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
item: String, item: String,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
root.setBackgroundColor(context.backgroundColor) root.setBackgroundColor(context.backgroundColor)
tvGroup.text = item tvGroup.text = item
} }

@ -66,7 +66,7 @@ class RssSourceAdapter(context: Context, val callBack: CallBack) :
item: RssSource, item: RssSource,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val bundle = payloads.getOrNull(0) as? Bundle val bundle = payloads.getOrNull(0) as? Bundle
if (bundle == null) { if (bundle == null) {
root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f)) root.setBackgroundColor(ColorUtils.withAlpha(context.backgroundColor, 0.5f))

@ -52,7 +52,7 @@ class KeyboardToolPop(
item: String, item: String,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
textView.text = item textView.text = item
} }
} }

@ -46,12 +46,12 @@ class SelectActionBar @JvmOverloads constructor(
binding.ivMenuMore.setOnClickListener { selMenu?.show() } binding.ivMenuMore.setOnClickListener { selMenu?.show() }
} }
fun setMainActionText(text: String) = with(binding) { fun setMainActionText(text: String) = binding.run {
btnSelectActionMain.text = text btnSelectActionMain.text = text
btnSelectActionMain.visible() btnSelectActionMain.visible()
} }
fun setMainActionText(@StringRes id: Int) = with(binding) { fun setMainActionText(@StringRes id: Int) = binding.run {
btnSelectActionMain.setText(id) btnSelectActionMain.setText(id)
btnSelectActionMain.visible() btnSelectActionMain.visible()
} }
@ -71,7 +71,7 @@ class SelectActionBar @JvmOverloads constructor(
selMenu?.setOnMenuItemClickListener(listener) selMenu?.setOnMenuItemClickListener(listener)
} }
fun upCountView(selectCount: Int, allCount: Int) = with(binding) { fun upCountView(selectCount: Int, allCount: Int) = binding.run {
if (selectCount == 0) { if (selectCount == 0) {
cbSelectedAll.isChecked = false cbSelectedAll.isChecked = false
} else { } else {
@ -95,7 +95,7 @@ class SelectActionBar @JvmOverloads constructor(
setMenuClickable(selectCount > 0) setMenuClickable(selectCount > 0)
} }
private fun setMenuClickable(isClickable: Boolean) = with(binding) { private fun setMenuClickable(isClickable: Boolean) = binding.run {
btnRevertSelection.isEnabled = isClickable btnRevertSelection.isEnabled = isClickable
btnRevertSelection.isClickable = isClickable btnRevertSelection.isClickable = isClickable
btnSelectActionMain.isEnabled = isClickable btnSelectActionMain.isEnabled = isClickable

@ -47,7 +47,7 @@ class TextListDialog : BaseDialogFragment() {
return inflater.inflate(R.layout.dialog_recycler_view, container) return inflater.inflate(R.layout.dialog_recycler_view, container)
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = with(binding) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) = binding.run {
arguments?.let { arguments?.let {
toolBar.title = it.getString("title") toolBar.title = it.getString("title")
values = it.getStringArrayList("values") values = it.getStringArrayList("values")

@ -24,7 +24,7 @@ class FontAdapter(context: Context, val callBack: CallBack) :
item: DocItem, item: DocItem,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
kotlin.runCatching { kotlin.runCatching {
val typeface: Typeface? = if (item.isContentPath) { val typeface: Typeface? = if (item.isContentPath) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

@ -168,7 +168,7 @@ class IconListPreference(context: Context, attrs: AttributeSet) : ListPreference
item: CharSequence, item: CharSequence,
payloads: MutableList<Any> payloads: MutableList<Any>
) { ) {
with(binding) { binding.run {
val index = findIndexOfValue(item.toString()) val index = findIndexOfValue(item.toString())
dialogEntries?.let { dialogEntries?.let {
label.text = it[index] label.text = it[index]

Loading…
Cancel
Save