pull/1110/head
gedoor 3 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)
}
private fun initView() = with(binding) {
private fun initView() = binding.run {
readRecord.tvBookName.setText(R.string.all_read_time)
adapter = RecordAdapter(this@ReadRecordActivity)
recyclerView.adapter = adapter

@ -31,7 +31,7 @@ class CacheAdapter(context: Context, private val callBack: CallBack) :
item: Book,
payloads: MutableList<Any>
) {
with(binding) {
binding.run {
if (payloads.isEmpty()) {
tvName.text = item.name
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) {
with(binding) {
binding.run {
ivDownload.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (downloadMap?.containsKey(it.bookUrl) == true) {

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

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

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

@ -172,7 +172,7 @@ class BookInfoActivity :
return super.onCompatOptionsItemSelected(item)
}
private fun showBook(book: Book) = with(binding) {
private fun showBook(book: Book) = binding.run {
showCover(book)
tvName.text = book.name
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 {
viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)

@ -55,7 +55,7 @@ class BookInfoEditActivity :
return super.onCompatOptionsItemSelected(item)
}
private fun initEvent() = with(binding) {
private fun initEvent() = binding.run {
tvChangeCover.setOnClickListener {
viewModel.bookData.value?.let {
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)
tieBookAuthor.setText(book.author)
tieCoverUrl.setText(book.getDisplayCover())
@ -84,7 +84,7 @@ class BookInfoEditActivity :
}
}
private fun saveData() = with(binding) {
private fun saveData() = binding.run {
viewModel.book?.let { book ->
book.name = tieBookName.text?.toString() ?: ""
book.author = tieBookAuthor.text?.toString() ?: ""

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

@ -53,7 +53,7 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
initRecyclerView()
}
private fun initRecyclerView() = with(binding) {
private fun initRecyclerView() = binding.run {
recyclerView.adapter = adapter
SupportMenuInflater(context).inflate(R.menu.content_select_action, menu)
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,
payloads: MutableList<Any>
) {
with(binding) {
binding.run {
textView.text = item.title
}
}

@ -52,21 +52,21 @@ class AutoReadDialog : BaseDialogFragment() {
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 isLight = ColorUtils.isColorLight(bg)
val textColor = requireContext().getPrimaryTextColor(isLight)
binding.root.setBackgroundColor(bg)
binding.tvReadSpeedTitle.setTextColor(textColor)
binding.tvReadSpeed.setTextColor(textColor)
binding.ivCatalog.setColorFilter(textColor)
binding.tvCatalog.setTextColor(textColor)
binding.ivMainMenu.setColorFilter(textColor)
binding.tvMainMenu.setTextColor(textColor)
binding.ivAutoPageStop.setColorFilter(textColor)
binding.tvAutoPageStop.setTextColor(textColor)
binding.ivSetting.setColorFilter(textColor)
binding.tvSetting.setTextColor(textColor)
root.setBackgroundColor(bg)
tvReadSpeedTitle.setTextColor(textColor)
tvReadSpeed.setTextColor(textColor)
ivCatalog.setColorFilter(textColor)
tvCatalog.setTextColor(textColor)
ivMainMenu.setColorFilter(textColor)
tvMainMenu.setTextColor(textColor)
ivAutoPageStop.setColorFilter(textColor)
tvAutoPageStop.setTextColor(textColor)
ivSetting.setColorFilter(textColor)
tvSetting.setTextColor(textColor)
initOnChange()
initData()
initEvent()

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

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

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

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

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

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

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

@ -72,7 +72,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
initData()
}
private fun initView() = with(binding) {
private fun initView() = binding.run {
toolBar.setBackgroundColor(primaryColor)
toolBar.setTitle(R.string.speak_engine)
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.menu.applyTint(requireContext())
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)
dsbTitleSize.progress = ReadBookConfig.titleSize
dsbTitleTop.progress = ReadBookConfig.titleTopSpacing
@ -74,7 +74,7 @@ class TipConfigDialog : BaseDialogFragment() {
}
}
private fun initEvent() = with(binding) {
private fun initEvent() = binding.run {
rgTitleMode.setOnCheckedChangeListener { _, checkedId ->
ReadBookConfig.titleMode = rgTitleMode.getIndexById(checkedId)
postEvent(EventBus.UP_CONFIG, true)

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

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

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

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

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

@ -28,7 +28,7 @@ class SearchContentAdapter(context: Context, val callback: Callback) :
item: SearchResult,
payloads: MutableList<Any>
) {
with(binding) {
binding.run {
val isDur = callback.durChapterIndex() == item.chapterIndex
if (payloads.isEmpty()) {
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) {
fun bind(editEntity: EditEntity) = with(binding) {
fun bind(editEntity: EditEntity) = binding.run {
if (editText.getTag(R.id.tag1) == null) {
val listener = object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) {

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

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

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

@ -39,7 +39,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
private var tocLiveData: LiveData<List<BookChapter>>? = null
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
val bbg = bottomBackground
val btc = requireContext().getPrimaryTextColor(ColorUtils.isColorLight(bbg))
@ -62,7 +62,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
binding.recyclerView.adapter = adapter
}
private fun initView() = with(binding) {
private fun initView() = binding.run {
ivChapterTop.setOnClickListener { mLayoutManager.scrollToPositionWithOffset(0, 0) }
ivChapterBottom.setOnClickListener {
if (adapter.itemCount > 0) {

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -33,7 +33,7 @@ class RssSourceEditAdapter : RecyclerView.Adapter<RssSourceEditAdapter.MyViewHol
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) {
val listener = object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) {

@ -47,7 +47,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
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.title = getString(R.string.group_manage)
toolBar.inflateMenu(R.menu.group_manage)
@ -128,7 +128,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
item: String,
payloads: MutableList<Any>
) {
with(binding) {
binding.run {
root.setBackgroundColor(context.backgroundColor)
tvGroup.text = item
}

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

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

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

@ -47,7 +47,7 @@ class TextListDialog : BaseDialogFragment() {
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 {
toolBar.title = it.getString("title")
values = it.getStringArrayList("values")

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

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

Loading…
Cancel
Save