pull/1319/head
gedoor 3 years ago
parent aaab823f6c
commit a21458914e
  1. 3
      app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  3. 3
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  4. 3
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  5. 3
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  6. 3
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  7. 3
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  8. 3
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  9. 6
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt
  10. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  11. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  12. 3
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  13. 1
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt
  14. 3
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  15. 6
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  16. 8
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  17. 17
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  18. 11
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt
  19. 3
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  20. 8
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  21. 3
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  22. 3
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt
  23. 3
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  24. 8
      app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt
  25. 8
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt
  26. 11
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  27. 8
      app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt
  28. 4
      app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt
  29. 8
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  30. 19
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  31. 3
      app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt
  32. 3
      app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt
  33. 3
      app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt
  34. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  35. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  36. 3
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt
  37. 3
      app/src/main/java/io/legado/app/ui/widget/dialog/TextListDialog.kt
  38. 7
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -27,7 +27,7 @@ import java.util.*
class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() { class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
lateinit var adapter: RecordAdapter private val adapter by lazy { RecordAdapter(this) }
private var sortMode = 0 private var sortMode = 0
override val binding by viewBinding(ActivityReadRecordBinding::inflate) override val binding by viewBinding(ActivityReadRecordBinding::inflate)
@ -58,7 +58,6 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
private fun initView() = binding.run { 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)
recyclerView.adapter = adapter recyclerView.adapter = adapter
readRecord.tvRemove.setOnClickListener { readRecord.tvRemove.setOnClickListener {
alert(R.string.delete, R.string.sure_del) { alert(R.string.delete, R.string.sure_del) {

@ -58,7 +58,7 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val viewModel by viewModels<ImportBookSourceViewModel>() private val viewModel by viewModels<ImportBookSourceViewModel>()
private lateinit var adapter: SourcesAdapter private val adapter by lazy { SourcesAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -89,7 +89,6 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
binding.toolBar.setTitle(R.string.import_book_source) binding.toolBar.setTitle(R.string.import_book_source)
binding.rotateLoading.show() binding.rotateLoading.show()
initMenu() initMenu()
adapter = SourcesAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.tvCancel.visible() binding.tvCancel.visible()

@ -51,7 +51,7 @@ class ImportReplaceRuleDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickLis
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val viewModel by viewModels<ImportReplaceRuleViewModel>() private val viewModel by viewModels<ImportReplaceRuleViewModel>()
lateinit var adapter: SourcesAdapter private val adapter by lazy { SourcesAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -82,7 +82,6 @@ class ImportReplaceRuleDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickLis
binding.toolBar.setTitle(R.string.import_replace_rule) binding.toolBar.setTitle(R.string.import_replace_rule)
binding.rotateLoading.show() binding.rotateLoading.show()
initMenu() initMenu()
adapter = SourcesAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.tvCancel.visible() binding.tvCancel.visible()

@ -55,7 +55,7 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val viewModel by viewModels<ImportRssSourceViewModel>() private val viewModel by viewModels<ImportRssSourceViewModel>()
lateinit var adapter: SourcesAdapter private val adapter by lazy { SourcesAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -86,7 +86,6 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
binding.toolBar.setTitle(R.string.import_rss_source) binding.toolBar.setTitle(R.string.import_rss_source)
binding.rotateLoading.show() binding.rotateLoading.show()
initMenu() initMenu()
adapter = SourcesAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.tvCancel.visible() binding.tvCancel.visible()

@ -45,7 +45,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
override val groupList: ArrayList<BookGroup> = arrayListOf() override val groupList: ArrayList<BookGroup> = arrayListOf()
private val groupRequestCode = 22 private val groupRequestCode = 22
private val addToGroupRequestCode = 34 private val addToGroupRequestCode = 34
private lateinit var adapter: ArrangeBookAdapter private val adapter by lazy { ArrangeBookAdapter(this, this) }
private var booksFlowJob: Job? = null private var booksFlowJob: Job? = null
private var menu: Menu? = null private var menu: Menu? = null
private var groupId: Long = -1 private var groupId: Long = -1
@ -90,7 +90,6 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
adapter = ArrangeBookAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
val itemTouchCallback = ItemTouchCallback(adapter) val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = getPrefInt(PreferKey.bookshelfSort) == 3 itemTouchCallback.isCanDrag = getPrefInt(PreferKey.bookshelfSort) == 3

@ -44,7 +44,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private val exportBookPathKey = "exportBookPath" private val exportBookPathKey = "exportBookPath"
private val exportTypes = arrayListOf("txt", "epub") private val exportTypes = arrayListOf("txt", "epub")
lateinit var adapter: CacheAdapter private val adapter by lazy { CacheAdapter(this, this) }
private var booksFlowJob: Job? = null private var booksFlowJob: Job? = null
private var menu: Menu? = null private var menu: Menu? = null
private var exportPosition = -1 private var exportPosition = -1
@ -147,7 +147,6 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private fun initRecyclerView() { private fun initRecyclerView() {
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
adapter = CacheAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
} }

@ -40,7 +40,7 @@ class ChangeCoverDialog : BaseDialogFragment(),
private val binding by viewBinding(DialogChangeCoverBinding::bind) private val binding by viewBinding(DialogChangeCoverBinding::bind)
private var callBack: CallBack? = null private var callBack: CallBack? = null
private val viewModel: ChangeCoverViewModel by viewModels() private val viewModel: ChangeCoverViewModel by viewModels()
lateinit var adapter: CoverAdapter private val adapter by lazy { CoverAdapter(requireContext(), this) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -73,7 +73,6 @@ class ChangeCoverDialog : BaseDialogFragment(),
private fun initView() { private fun initView() {
binding.recyclerView.layoutManager = GridLayoutManager(requireContext(), 3) binding.recyclerView.layoutManager = GridLayoutManager(requireContext(), 3)
adapter = CoverAdapter(requireContext(), this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
viewModel.loadDbSearchBook() viewModel.loadDbSearchBook()
} }

@ -51,7 +51,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
private val groups = linkedSetOf<String>() private val groups = linkedSetOf<String>()
private var callBack: CallBack? = null private var callBack: CallBack? = null
private val viewModel: ChangeSourceViewModel by viewModels() private val viewModel: ChangeSourceViewModel by viewModels()
lateinit var adapter: ChangeSourceAdapter private val adapter by lazy { ChangeSourceAdapter(requireContext(), viewModel, this) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -97,7 +97,6 @@ class ChangeSourceDialog : BaseDialogFragment(),
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = ChangeSourceAdapter(requireContext(), viewModel, this)
binding.recyclerView.layoutManager = LinearLayoutManager(context) binding.recyclerView.layoutManager = LinearLayoutManager(context)
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -20,8 +20,8 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
override val binding by viewBinding(ActivityExploreShowBinding::inflate) override val binding by viewBinding(ActivityExploreShowBinding::inflate)
override val viewModel by viewModels<ExploreShowViewModel>() override val viewModel by viewModels<ExploreShowViewModel>()
private lateinit var adapter: ExploreShowAdapter private val adapter by lazy { ExploreShowAdapter(this, this) }
private lateinit var loadMoreView: LoadMoreView private val loadMoreView by lazy { LoadMoreView(this) }
private var isLoading = true private var isLoading = true
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -35,10 +35,8 @@ class ExploreShowActivity : VMBaseActivity<ActivityExploreShowBinding, ExploreSh
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = ExploreShowAdapter(this, this)
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
loadMoreView = LoadMoreView(this)
adapter.addFooterView { adapter.addFooterView {
ViewLoadMoreBinding.bind(loadMoreView) ViewLoadMoreBinding.bind(loadMoreView)
} }

@ -34,8 +34,8 @@ import kotlinx.coroutines.launch
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val viewModel: GroupViewModel by viewModels() private val viewModel: GroupViewModel by viewModels()
private lateinit var adapter: GroupAdapter
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val adapter by lazy { GroupAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -60,7 +60,6 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
private fun initView() { private fun initView() {
adapter = GroupAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -51,7 +51,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
private val binding by viewBinding(DialogBookGroupPickerBinding::bind) private val binding by viewBinding(DialogBookGroupPickerBinding::bind)
private var requestCode: Int = -1 private var requestCode: Int = -1
private val viewModel: GroupViewModel by viewModels() private val viewModel: GroupViewModel by viewModels()
private lateinit var adapter: GroupAdapter private val adapter by lazy { GroupAdapter(requireContext()) }
private var callBack: CallBack? = null private var callBack: CallBack? = null
private var groupId: Long = 0 private var groupId: Long = 0
@ -85,7 +85,6 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
binding.toolBar.inflateMenu(R.menu.book_group_manage) binding.toolBar.inflateMenu(R.menu.book_group_manage)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
adapter = GroupAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -46,7 +46,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private var rootDoc: DocumentFile? = null private var rootDoc: DocumentFile? = null
private val subDocs = arrayListOf<DocumentFile>() private val subDocs = arrayListOf<DocumentFile>()
private lateinit var adapter: ImportBookAdapter private val adapter by lazy { ImportBookAdapter(this, this) }
private var sdPath = FileUtils.getSdCardPath() private var sdPath = FileUtils.getSdCardPath()
private var path = sdPath private var path = sdPath
private val selectFolder = registerForActivityResult(HandleFileContract()) { uri -> private val selectFolder = registerForActivityResult(HandleFileContract()) { uri ->
@ -111,7 +111,6 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private fun initView() { private fun initView() {
binding.layTop.setBackgroundColor(backgroundColor) binding.layTop.setBackgroundColor(backgroundColor)
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
adapter = ImportBookAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.selectActionBar.setMainActionText(R.string.add_to_shelf) binding.selectActionBar.setMainActionText(R.string.add_to_shelf)
binding.selectActionBar.inflateMenu(R.menu.import_book_sel) binding.selectActionBar.inflateMenu(R.menu.import_book_sel)

@ -32,6 +32,7 @@ import java.util.*
class TextActionMenu(private val context: Context, private val callBack: CallBack) : class TextActionMenu(private val context: Context, private val callBack: CallBack) :
PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT), PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT),
TextToSpeech.OnInitListener { TextToSpeech.OnInitListener {
private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context)) private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context))
private val adapter = Adapter(context) private val adapter = Adapter(context)
private val menuItems: List<MenuItemImpl> private val menuItems: List<MenuItemImpl>

@ -39,7 +39,7 @@ class BgTextConfigDialog : BaseDialogFragment() {
private val binding by viewBinding(DialogReadBgTextBinding::bind) private val binding by viewBinding(DialogReadBgTextBinding::bind)
private val configFileName = "readConfig.zip" private val configFileName = "readConfig.zip"
private lateinit var adapter: BgAdapter private val adapter by lazy { BgAdapter(requireContext(), secondaryTextColor) }
private var primaryTextColor = 0 private var primaryTextColor = 0
private var secondaryTextColor = 0 private var secondaryTextColor = 0
private val importFormNet = "网络导入" private val importFormNet = "网络导入"
@ -111,7 +111,6 @@ class BgTextConfigDialog : BaseDialogFragment() {
ivExport.setColorFilter(primaryTextColor) ivExport.setColorFilter(primaryTextColor)
ivDelete.setColorFilter(primaryTextColor) ivDelete.setColorFilter(primaryTextColor)
tvBgImage.setTextColor(primaryTextColor) tvBgImage.setTextColor(primaryTextColor)
adapter = BgAdapter(requireContext(), secondaryTextColor)
recyclerView.adapter = adapter recyclerView.adapter = adapter
adapter.addHeaderView { adapter.addHeaderView {
ItemBgImageBinding.inflate(layoutInflater, it, false).apply { ItemBgImageBinding.inflate(layoutInflater, it, false).apply {

@ -35,10 +35,11 @@ import splitties.init.appCtx
class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val ttsUrlKey = "ttsUrlKey"
lateinit var adapter: Adapter
private val viewModel: SpeakEngineViewModel by viewModels() private val viewModel: SpeakEngineViewModel by viewModels()
private val ttsUrlKey = "ttsUrlKey"
private val adapter by lazy { Adapter(requireContext()) }
private var engineId = appCtx.getPrefLong(PreferKey.speakEngine) private var engineId = appCtx.getPrefLong(PreferKey.speakEngine)
private val importDocResult = registerForActivityResult(HandleFileContract()) { private val importDocResult = registerForActivityResult(HandleFileContract()) {
it?.let { it?.let {
@ -84,7 +85,6 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
toolBar.setTitle(R.string.speak_engine) toolBar.setTitle(R.string.speak_engine)
ATH.applyEdgeEffectColor(recyclerView) ATH.applyEdgeEffectColor(recyclerView)
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
adapter = Adapter(requireContext())
recyclerView.adapter = adapter recyclerView.adapter = adapter
tvFooterLeft.setText(R.string.system_tts) tvFooterLeft.setText(R.string.system_tts)
tvFooterLeft.visible() tvFooterLeft.visible()

@ -36,12 +36,13 @@ import kotlinx.coroutines.launch
import java.util.* import java.util.*
class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val importTocRuleKey = "tocRuleUrl" private val importTocRuleKey = "tocRuleUrl"
private lateinit var adapter: TocRegexAdapter
var selectedName: String? = null
private var durRegex: String? = null
private val viewModel: TocRegexViewModel by viewModels() private val viewModel: TocRegexViewModel by viewModels()
private val binding by viewBinding(DialogTocRegexBinding::bind) private val binding by viewBinding(DialogTocRegexBinding::bind)
private val adapter by lazy { TocRegexAdapter(requireContext()) }
var selectedName: String? = null
private var durRegex: String? = null
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -69,7 +70,6 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
} }
private fun initView() = binding.run { private fun initView() = binding.run {
adapter = TocRegexAdapter(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter
val itemTouchCallback = ItemTouchCallback(adapter) val itemTouchCallback = ItemTouchCallback(adapter)

@ -42,11 +42,13 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
override val binding by viewBinding(ActivityBookSearchBinding::inflate) override val binding by viewBinding(ActivityBookSearchBinding::inflate)
override val viewModel by viewModels<SearchViewModel>() override val viewModel by viewModels<SearchViewModel>()
lateinit var adapter: SearchAdapter private val adapter by lazy { SearchAdapter(this, this) }
private lateinit var bookAdapter: BookAdapter private val bookAdapter by lazy { BookAdapter(this, this) }
private lateinit var historyKeyAdapter: HistoryKeyAdapter private val historyKeyAdapter by lazy { HistoryKeyAdapter(this, this) }
private lateinit var loadMoreView: LoadMoreView private val loadMoreView by lazy { LoadMoreView(this) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private var historyFlowJob: Job? = null private var historyFlowJob: Job? = null
private var booksFlowJob: Job? = null private var booksFlowJob: Job? = null
private var menu: Menu? = null private var menu: Menu? = null
@ -55,7 +57,6 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
binding.llHistory.setBackgroundColor(backgroundColor) binding.llHistory.setBackgroundColor(backgroundColor)
searchView = binding.titleBar.findViewById(R.id.search_view)
initRecyclerView() initRecyclerView()
initSearchView() initSearchView()
initOtherView() initOtherView()
@ -142,13 +143,10 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
ATH.applyEdgeEffectColor(binding.rvBookshelfSearch) ATH.applyEdgeEffectColor(binding.rvBookshelfSearch)
ATH.applyEdgeEffectColor(binding.rvHistoryKey) ATH.applyEdgeEffectColor(binding.rvHistoryKey)
bookAdapter = BookAdapter(this, this)
binding.rvBookshelfSearch.layoutManager = FlexboxLayoutManager(this) binding.rvBookshelfSearch.layoutManager = FlexboxLayoutManager(this)
binding.rvBookshelfSearch.adapter = bookAdapter binding.rvBookshelfSearch.adapter = bookAdapter
historyKeyAdapter = HistoryKeyAdapter(this, this)
binding.rvHistoryKey.layoutManager = FlexboxLayoutManager(this) binding.rvHistoryKey.layoutManager = FlexboxLayoutManager(this)
binding.rvHistoryKey.adapter = historyKeyAdapter binding.rvHistoryKey.adapter = historyKeyAdapter
adapter = SearchAdapter(this, this)
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
@ -166,7 +164,6 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
} }
} }
}) })
loadMoreView = LoadMoreView(this)
binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)

@ -35,15 +35,16 @@ class SearchContentActivity :
override val binding by viewBinding(ActivitySearchContentBinding::inflate) override val binding by viewBinding(ActivitySearchContentBinding::inflate)
override val viewModel by viewModels<SearchContentViewModel>() override val viewModel by viewModels<SearchContentViewModel>()
lateinit var adapter: SearchContentAdapter private val adapter by lazy { SearchContentAdapter(this, this) }
private lateinit var mLayoutManager: UpLinearLayoutManager private val mLayoutManager by lazy { UpLinearLayoutManager(this) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private var searchResultCounts = 0 private var searchResultCounts = 0
private var durChapterIndex = 0 private var durChapterIndex = 0
private var searchResultList: MutableList<SearchResult> = mutableListOf() private var searchResultList: MutableList<SearchResult> = mutableListOf()
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
val bbg = bottomBackground val bbg = bottomBackground
val btc = getPrimaryTextColor(ColorUtils.isColorLight(bbg)) val btc = getPrimaryTextColor(ColorUtils.isColorLight(bbg))
binding.llSearchBaseInfo.setBackgroundColor(bbg) binding.llSearchBaseInfo.setBackgroundColor(bbg)
@ -81,8 +82,6 @@ class SearchContentActivity :
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = SearchContentAdapter(this, this)
mLayoutManager = UpLinearLayoutManager(this)
binding.recyclerView.layoutManager = mLayoutManager binding.recyclerView.layoutManager = mLayoutManager
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -24,7 +24,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
override val binding by viewBinding(ActivitySourceDebugBinding::inflate) override val binding by viewBinding(ActivitySourceDebugBinding::inflate)
override val viewModel by viewModels<BookSourceDebugModel>() override val viewModel by viewModels<BookSourceDebugModel>()
private lateinit var adapter: BookSourceDebugAdapter private val adapter by lazy { BookSourceDebugAdapter(this) }
private val searchView: SearchView by lazy { private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view) binding.titleBar.findViewById(R.id.search_view)
} }
@ -52,7 +52,6 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = BookSourceDebugAdapter(this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.rotateLoading.loadingColor = accentColor binding.rotateLoading.loadingColor = accentColor
} }

@ -49,8 +49,10 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
override val binding by viewBinding(ActivityBookSourceBinding::inflate) override val binding by viewBinding(ActivityBookSourceBinding::inflate)
override val viewModel by viewModels<BookSourceViewModel>() override val viewModel by viewModels<BookSourceViewModel>()
private val importRecordKey = "bookSourceRecordKey" private val importRecordKey = "bookSourceRecordKey"
private lateinit var adapter: BookSourceAdapter private val adapter by lazy { BookSourceAdapter(this, this) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private var sourceFlowJob: Job? = null private var sourceFlowJob: Job? = null
private val groups = linkedSetOf<String>() private val groups = linkedSetOf<String>()
private var groupMenu: SubMenu? = null private var groupMenu: SubMenu? = null
@ -86,7 +88,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
} }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
initRecyclerView() initRecyclerView()
initSearchView() initSearchView()
upBookSource() upBookSource()
@ -179,7 +180,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
adapter = BookSourceAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
// When this page is opened, it is in selection mode // When this page is opened, it is in selection mode
val dragSelectTouchHelper = val dragSelectTouchHelper =

@ -34,8 +34,8 @@ import kotlinx.coroutines.launch
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val viewModel: BookSourceViewModel by activityViewModels() private val viewModel: BookSourceViewModel by activityViewModels()
private lateinit var adapter: GroupAdapter
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val adapter by lazy { GroupAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -58,7 +58,6 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
binding.toolBar.inflateMenu(R.menu.group_manage) binding.toolBar.inflateMenu(R.menu.group_manage)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
adapter = GroupAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -24,7 +24,7 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
TocViewModel.BookmarkCallBack { TocViewModel.BookmarkCallBack {
override val viewModel by activityViewModels<TocViewModel>() override val viewModel by activityViewModels<TocViewModel>()
private val binding by viewBinding(FragmentBookmarkBinding::bind) private val binding by viewBinding(FragmentBookmarkBinding::bind)
private lateinit var adapter: BookmarkAdapter private val adapter by lazy { BookmarkAdapter(requireContext(), this) }
private var bookmarkFlowJob: Job? = null private var bookmarkFlowJob: Job? = null
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
@ -37,7 +37,6 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = BookmarkAdapter(requireContext(), this)
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter

@ -34,7 +34,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
TocViewModel.ChapterListCallBack { TocViewModel.ChapterListCallBack {
override val viewModel by activityViewModels<TocViewModel>() override val viewModel by activityViewModels<TocViewModel>()
private val binding by viewBinding(FragmentChapterListBinding::bind) private val binding by viewBinding(FragmentChapterListBinding::bind)
lateinit var adapter: ChapterListAdapter private val adapter by lazy { ChapterListAdapter(requireContext(), this) }
private var durChapterIndex = 0 private var durChapterIndex = 0
private lateinit var mLayoutManager: UpLinearLayoutManager private lateinit var mLayoutManager: UpLinearLayoutManager
private var tocFlowJob: Job? = null private var tocFlowJob: Job? = null
@ -56,7 +56,6 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
} }
private fun initRecyclerView() { private fun initRecyclerView() {
adapter = ChapterListAdapter(requireContext(), this)
mLayoutManager = UpLinearLayoutManager(requireContext()) mLayoutManager = UpLinearLayoutManager(requireContext())
binding.recyclerView.layoutManager = mLayoutManager binding.recyclerView.layoutManager = mLayoutManager
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext())) binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))

@ -1,5 +1,6 @@
package io.legado.app.ui.config package io.legado.app.ui.config
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
@ -22,7 +23,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private lateinit var adapter: Adapter private val adapter by lazy { Adapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -47,7 +48,6 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
} }
private fun initView() = binding.run { private fun initView() = binding.run {
adapter = Adapter()
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter
@ -93,8 +93,8 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
requireContext().share(json, "主题分享") requireContext().share(json, "主题分享")
} }
inner class Adapter : inner class Adapter(context: Context) :
RecyclerAdapter<ThemeConfig.Config, ItemThemeConfigBinding>(requireContext()) { RecyclerAdapter<ThemeConfig.Config, ItemThemeConfigBinding>(context) {
override fun getViewBinding(parent: ViewGroup): ItemThemeConfigBinding { override fun getViewBinding(parent: ViewGroup): ItemThemeConfigBinding {
return ItemThemeConfigBinding.inflate(inflater, parent, false) return ItemThemeConfigBinding.inflate(inflater, parent, false)

@ -37,8 +37,10 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
SearchView.OnQueryTextListener { SearchView.OnQueryTextListener {
private val binding by viewBinding(FragmentBookshelfBinding::bind) private val binding by viewBinding(FragmentBookshelfBinding::bind)
private lateinit var adapter: FragmentStatePagerAdapter private val adapter by lazy { TabFragmentPageAdapter(childFragmentManager) }
private lateinit var tabLayout: TabLayout private val tabLayout: TabLayout by lazy {
binding.titleBar.findViewById(R.id.tab_layout)
}
private val bookGroups = mutableListOf<BookGroup>() private val bookGroups = mutableListOf<BookGroup>()
private val fragmentMap = hashMapOf<Long, BooksFragment>() private val fragmentMap = hashMapOf<Long, BooksFragment>()
@ -51,7 +53,6 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
} }
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
tabLayout = binding.titleBar.findViewById(R.id.tab_layout)
setSupportToolbar(binding.titleBar.toolbar) setSupportToolbar(binding.titleBar.toolbar)
initView() initView()
initBookGroupData() initBookGroupData()
@ -67,7 +68,6 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
tabLayout.setSelectedTabIndicatorColor(requireContext().accentColor) tabLayout.setSelectedTabIndicatorColor(requireContext().accentColor)
tabLayout.setupWithViewPager(binding.viewPagerBookshelf) tabLayout.setupWithViewPager(binding.viewPagerBookshelf)
binding.viewPagerBookshelf.offscreenPageLimit = 1 binding.viewPagerBookshelf.offscreenPageLimit = 1
adapter = TabFragmentPageAdapter(childFragmentManager)
binding.viewPagerBookshelf.adapter = adapter binding.viewPagerBookshelf.adapter = adapter
} }

@ -38,15 +38,16 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
ExploreAdapter.CallBack { ExploreAdapter.CallBack {
override val viewModel by viewModels<ExploreViewModel>() override val viewModel by viewModels<ExploreViewModel>()
private val binding by viewBinding(FragmentExploreBinding::bind) private val binding by viewBinding(FragmentExploreBinding::bind)
private lateinit var adapter: ExploreAdapter private val adapter by lazy { ExploreAdapter(requireContext(), lifecycleScope, this) }
private lateinit var linearLayoutManager: LinearLayoutManager private val linearLayoutManager by lazy { LinearLayoutManager(context) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private val groups = linkedSetOf<String>() private val groups = linkedSetOf<String>()
private var exploreFlowJob: Job? = null private var exploreFlowJob: Job? = null
private var groupsMenu: SubMenu? = null private var groupsMenu: SubMenu? = null
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
setSupportToolbar(binding.titleBar.toolbar) setSupportToolbar(binding.titleBar.toolbar)
initSearchView() initSearchView()
initRecyclerView() initRecyclerView()
@ -86,9 +87,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.rvFind) ATH.applyEdgeEffectColor(binding.rvFind)
linearLayoutManager = LinearLayoutManager(context)
binding.rvFind.layoutManager = linearLayoutManager binding.rvFind.layoutManager = linearLayoutManager
adapter = ExploreAdapter(requireContext(), lifecycleScope, this)
binding.rvFind.adapter = adapter binding.rvFind.adapter = adapter
adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {

@ -40,14 +40,15 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
RssAdapter.CallBack { RssAdapter.CallBack {
private val binding by viewBinding(FragmentRssBinding::bind) private val binding by viewBinding(FragmentRssBinding::bind)
override val viewModel by viewModels<RssSourceViewModel>() override val viewModel by viewModels<RssSourceViewModel>()
private lateinit var adapter: RssAdapter private val adapter by lazy { RssAdapter(requireContext(), this) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private var rssFlowJob: Job? = null private var rssFlowJob: Job? = null
private val groups = linkedSetOf<String>() private val groups = linkedSetOf<String>()
private var groupsMenu: SubMenu? = null private var groupsMenu: SubMenu? = null
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
setSupportToolbar(binding.titleBar.toolbar) setSupportToolbar(binding.titleBar.toolbar)
initSearchView() initSearchView()
initRecyclerView() initRecyclerView()
@ -106,7 +107,6 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = RssAdapter(requireContext(), this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
adapter.addHeaderView { adapter.addHeaderView {
ItemRssBinding.inflate(layoutInflater, it, false).apply { ItemRssBinding.inflate(layoutInflater, it, false).apply {

@ -30,9 +30,10 @@ import kotlinx.coroutines.launch
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val viewModel: ReplaceRuleViewModel by activityViewModels() private val viewModel: ReplaceRuleViewModel by activityViewModels()
private lateinit var adapter: GroupAdapter
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val adapter by lazy { GroupAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -60,7 +61,6 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
toolBar.inflateMenu(R.menu.group_manage) toolBar.inflateMenu(R.menu.group_manage)
toolBar.menu.applyTint(requireContext()) toolBar.menu.applyTint(requireContext())
toolBar.setOnMenuItemClickListener(this@GroupManageDialog) toolBar.setOnMenuItemClickListener(this@GroupManageDialog)
adapter = GroupAdapter(requireContext())
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter

@ -50,8 +50,10 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
override val binding by viewBinding(ActivityReplaceRuleBinding::inflate) override val binding by viewBinding(ActivityReplaceRuleBinding::inflate)
override val viewModel by viewModels<ReplaceRuleViewModel>() override val viewModel by viewModels<ReplaceRuleViewModel>()
private val importRecordKey = "replaceRuleRecordKey" private val importRecordKey = "replaceRuleRecordKey"
private lateinit var adapter: ReplaceRuleAdapter private val adapter by lazy { ReplaceRuleAdapter(this, this) }
private lateinit var searchView: SearchView private val searchView: SearchView by lazy {
binding.titleBar.findViewById(R.id.search_view)
}
private var groups = hashSetOf<String>() private var groups = hashSetOf<String>()
private var groupMenu: SubMenu? = null private var groupMenu: SubMenu? = null
private var replaceRuleFlowJob: Job? = null private var replaceRuleFlowJob: Job? = null
@ -90,7 +92,6 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
} }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
searchView = binding.titleBar.findViewById(R.id.search_view)
initRecyclerView() initRecyclerView()
initSearchView() initSearchView()
initSelectActionView() initSelectActionView()
@ -112,7 +113,6 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
binding.recyclerView.layoutManager = LinearLayoutManager(this) binding.recyclerView.layoutManager = LinearLayoutManager(this)
adapter = ReplaceRuleAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
val itemTouchCallback = ItemTouchCallback(adapter) val itemTouchCallback = ItemTouchCallback(adapter)

@ -43,8 +43,16 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
private val binding by viewBinding(FragmentRssArticlesBinding::bind) private val binding by viewBinding(FragmentRssArticlesBinding::bind)
private val activityViewModel by activityViewModels<RssSortViewModel>() private val activityViewModel by activityViewModels<RssSortViewModel>()
override val viewModel by viewModels<RssArticlesViewModel>() override val viewModel by viewModels<RssArticlesViewModel>()
lateinit var adapter: BaseRssArticlesAdapter<*> private val adapter: BaseRssArticlesAdapter<*> by lazy {
private lateinit var loadMoreView: LoadMoreView when (activityViewModel.rssSource?.articleStyle) {
1 -> RssArticlesAdapter1(requireContext(), this@RssArticlesFragment)
2 -> RssArticlesAdapter2(requireContext(), this@RssArticlesFragment)
else -> RssArticlesAdapter(requireContext(), this@RssArticlesFragment)
}
}
private val loadMoreView: LoadMoreView by lazy {
LoadMoreView(requireContext())
}
private var articlesFlowJob: Job? = null private var articlesFlowJob: Job? = null
override val isGridLayout: Boolean override val isGridLayout: Boolean
get() = activityViewModel.isGridLayout get() = activityViewModel.isGridLayout
@ -64,15 +72,8 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
} else { } else {
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
LinearLayoutManager(requireContext()) LinearLayoutManager(requireContext())
}
adapter = when (activityViewModel.rssSource?.articleStyle) {
1 -> RssArticlesAdapter1(requireContext(), this@RssArticlesFragment)
2 -> RssArticlesAdapter2(requireContext(), this@RssArticlesFragment)
else -> RssArticlesAdapter(requireContext(), this@RssArticlesFragment)
} }
recyclerView.adapter = adapter recyclerView.adapter = adapter
loadMoreView = LoadMoreView(requireContext())
adapter.addFooterView { adapter.addFooterView {
ViewLoadMoreBinding.bind(loadMoreView) ViewLoadMoreBinding.bind(loadMoreView)
} }

@ -29,7 +29,7 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
override val binding by viewBinding(ActivityRssArtivlesBinding::inflate) override val binding by viewBinding(ActivityRssArtivlesBinding::inflate)
override val viewModel by viewModels<RssSortViewModel>() override val viewModel by viewModels<RssSortViewModel>()
private lateinit var adapter: TabFragmentPageAdapter private val adapter by lazy { TabFragmentPageAdapter() }
private val sortList = mutableListOf<Pair<String, String>>() private val sortList = mutableListOf<Pair<String, String>>()
private val fragmentMap = hashMapOf<String, Fragment>() private val fragmentMap = hashMapOf<String, Fragment>()
private val editSourceResult = registerForActivityResult( private val editSourceResult = registerForActivityResult(
@ -43,7 +43,6 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
} }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
adapter = TabFragmentPageAdapter()
binding.viewPager.adapter = adapter binding.viewPager.adapter = adapter
binding.tabLayout.setupWithViewPager(binding.viewPager) binding.tabLayout.setupWithViewPager(binding.viewPager)
viewModel.titleLiveData.observe(this, { viewModel.titleLiveData.observe(this, {

@ -18,7 +18,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
RssFavoritesAdapter.CallBack { RssFavoritesAdapter.CallBack {
override val binding by viewBinding(ActivityRssFavoritesBinding::inflate) override val binding by viewBinding(ActivityRssFavoritesBinding::inflate)
private lateinit var adapter: RssFavoritesAdapter private val adapter by lazy { RssFavoritesAdapter(this, this) }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initView() initView()
@ -29,7 +29,6 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
binding.recyclerView.let { binding.recyclerView.let {
it.layoutManager = LinearLayoutManager(this) it.layoutManager = LinearLayoutManager(this)
it.addItemDecoration(VerticalDivider(this)) it.addItemDecoration(VerticalDivider(this))
adapter = RssFavoritesAdapter(this, this)
it.adapter = adapter it.adapter = adapter
} }
} }

@ -22,7 +22,7 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
override val binding by viewBinding(ActivitySourceDebugBinding::inflate) override val binding by viewBinding(ActivitySourceDebugBinding::inflate)
override val viewModel by viewModels<RssSourceDebugModel>() override val viewModel by viewModels<RssSourceDebugModel>()
private lateinit var adapter: RssSourceDebugAdapter private val adapter by lazy { RssSourceDebugAdapter(this) }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initRecyclerView() initRecyclerView()
@ -57,7 +57,6 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = RssSourceDebugAdapter(this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
binding.rotateLoading.loadingColor = accentColor binding.rotateLoading.loadingColor = accentColor
} }

@ -32,8 +32,8 @@ import kotlinx.coroutines.launch
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val viewModel: RssSourceViewModel by activityViewModels() private val viewModel: RssSourceViewModel by activityViewModels()
private lateinit var adapter: GroupAdapter
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val adapter by lazy { GroupAdapter(requireContext()) }
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -55,7 +55,6 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
toolBar.inflateMenu(R.menu.group_manage) toolBar.inflateMenu(R.menu.group_manage)
toolBar.menu.applyTint(requireContext()) toolBar.menu.applyTint(requireContext())
toolBar.setOnMenuItemClickListener(this@GroupManageDialog) toolBar.setOnMenuItemClickListener(this@GroupManageDialog)
adapter = GroupAdapter(requireContext())
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
recyclerView.adapter = adapter recyclerView.adapter = adapter

@ -46,7 +46,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
override val binding by viewBinding(ActivityRssSourceBinding::inflate) override val binding by viewBinding(ActivityRssSourceBinding::inflate)
override val viewModel by viewModels<RssSourceViewModel>() override val viewModel by viewModels<RssSourceViewModel>()
private val importRecordKey = "rssSourceRecordKey" private val importRecordKey = "rssSourceRecordKey"
private lateinit var adapter: RssSourceAdapter private val adapter by lazy { RssSourceAdapter(this, this) }
private var sourceFlowJob: Job? = null private var sourceFlowJob: Job? = null
private var groups = hashSetOf<String>() private var groups = hashSetOf<String>()
private var groupMenu: SubMenu? = null private var groupMenu: SubMenu? = null
@ -142,7 +142,6 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
private fun initRecyclerView() { private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView) ATH.applyEdgeEffectColor(binding.recyclerView)
binding.recyclerView.addItemDecoration(VerticalDivider(this)) binding.recyclerView.addItemDecoration(VerticalDivider(this))
adapter = RssSourceAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
// When this page is opened, it is in selection mode // When this page is opened, it is in selection mode
val dragSelectTouchHelper: DragSelectTouchHelper = val dragSelectTouchHelper: DragSelectTouchHelper =

@ -30,7 +30,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
RuleSubAdapter.Callback { RuleSubAdapter.Callback {
override val binding by viewBinding(ActivityRuleSubBinding::inflate) override val binding by viewBinding(ActivityRuleSubBinding::inflate)
private lateinit var adapter: RuleSubAdapter private val adapter by lazy { RuleSubAdapter(this, this) }
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
initView() initView()
@ -53,7 +53,6 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
} }
private fun initView() { private fun initView() {
adapter = RuleSubAdapter(this, this)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
val itemTouchCallback = ItemTouchCallback(adapter) val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = true itemTouchCallback.isCanDrag = true

@ -30,7 +30,7 @@ class TextListDialog : BaseDialogFragment() {
} }
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
lateinit var adapter: TextAdapter private val adapter by lazy { TextAdapter(requireContext()) }
private var values: ArrayList<String>? = null private var values: ArrayList<String>? = null
override fun onStart() { override fun onStart() {
@ -53,7 +53,6 @@ class TextListDialog : BaseDialogFragment() {
values = it.getStringArrayList("values") values = it.getStringArrayList("values")
} }
recyclerView.layoutManager = LinearLayoutManager(requireContext()) recyclerView.layoutManager = LinearLayoutManager(requireContext())
adapter = TextAdapter(requireContext())
recyclerView.adapter = adapter recyclerView.adapter = adapter
adapter.setItems(values) adapter.setItems(values)
} }

@ -37,8 +37,8 @@ class FontSelectDialog : BaseDialogFragment(),
private val fontFolder by lazy { private val fontFolder by lazy {
FileUtils.createFolderIfNotExist(appCtx.filesDir, "Fonts") FileUtils.createFolderIfNotExist(appCtx.filesDir, "Fonts")
} }
private var adapter: FontAdapter? = null
private val binding by viewBinding(DialogFontSelectBinding::bind) private val binding by viewBinding(DialogFontSelectBinding::bind)
private val adapter by lazy { FontAdapter(requireContext(), this) }
private val selectFontDir = registerForActivityResult(HandleFileContract()) { uri -> private val selectFontDir = registerForActivityResult(HandleFileContract()) { uri ->
uri ?: return@registerForActivityResult uri ?: return@registerForActivityResult
if (uri.toString().isContentScheme()) { if (uri.toString().isContentScheme()) {
@ -83,7 +83,6 @@ class FontSelectDialog : BaseDialogFragment(),
binding.toolBar.inflateMenu(R.menu.font_select) binding.toolBar.inflateMenu(R.menu.font_select)
binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener(this) binding.toolBar.setOnMenuItemClickListener(this)
adapter = FontAdapter(requireContext(), this)
binding.recyclerView.layoutManager = LinearLayoutManager(context) binding.recyclerView.layoutManager = LinearLayoutManager(context)
binding.recyclerView.adapter = adapter binding.recyclerView.adapter = adapter
@ -165,7 +164,7 @@ class FontSelectDialog : BaseDialogFragment(),
} }
mergeFontItems(fontItems, getLocalFonts()) mergeFontItems(fontItems, getLocalFonts())
}.onSuccess { }.onSuccess {
adapter?.setItems(it) adapter.setItems(it)
}.onError { }.onError {
toastOnUi("getFontFiles:${it.localizedMessage}") toastOnUi("getFontFiles:${it.localizedMessage}")
} }
@ -200,7 +199,7 @@ class FontSelectDialog : BaseDialogFragment(),
} }
mergeFontItems(fontItems, getLocalFonts()) mergeFontItems(fontItems, getLocalFonts())
}.onSuccess { }.onSuccess {
adapter?.setItems(it) adapter.setItems(it)
}.onError { }.onError {
toastOnUi("getFontFiles:${it.localizedMessage}") toastOnUi("getFontFiles:${it.localizedMessage}")
} }

Loading…
Cancel
Save