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>() {
lateinit var adapter: RecordAdapter
private val adapter by lazy { RecordAdapter(this) }
private var sortMode = 0
override val binding by viewBinding(ActivityReadRecordBinding::inflate)
@ -58,7 +58,6 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
private fun initView() = binding.run {
readRecord.tvBookName.setText(R.string.all_read_time)
adapter = RecordAdapter(this@ReadRecordActivity)
recyclerView.adapter = adapter
readRecord.tvRemove.setOnClickListener {
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 viewModel by viewModels<ImportBookSourceViewModel>()
private lateinit var adapter: SourcesAdapter
private val adapter by lazy { SourcesAdapter(requireContext()) }
override fun onStart() {
super.onStart()
@ -89,7 +89,6 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
binding.toolBar.setTitle(R.string.import_book_source)
binding.rotateLoading.show()
initMenu()
adapter = SourcesAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.adapter = adapter
binding.tvCancel.visible()

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

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

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

@ -44,7 +44,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private val exportBookPathKey = "exportBookPath"
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 menu: Menu? = null
private var exportPosition = -1
@ -147,7 +147,6 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private fun initRecyclerView() {
binding.recyclerView.layoutManager = LinearLayoutManager(this)
adapter = CacheAdapter(this, this)
binding.recyclerView.adapter = adapter
}

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

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

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

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

@ -51,7 +51,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
private val binding by viewBinding(DialogBookGroupPickerBinding::bind)
private var requestCode: Int = -1
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 groupId: Long = 0
@ -85,7 +85,6 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
binding.toolBar.inflateMenu(R.menu.book_group_manage)
binding.toolBar.menu.applyTint(requireContext())
binding.toolBar.setOnMenuItemClickListener(this)
adapter = GroupAdapter(requireContext())
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter

@ -46,7 +46,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private var rootDoc: DocumentFile? = null
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 path = sdPath
private val selectFolder = registerForActivityResult(HandleFileContract()) { uri ->
@ -111,7 +111,6 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private fun initView() {
binding.layTop.setBackgroundColor(backgroundColor)
binding.recyclerView.layoutManager = LinearLayoutManager(this)
adapter = ImportBookAdapter(this, this)
binding.recyclerView.adapter = adapter
binding.selectActionBar.setMainActionText(R.string.add_to_shelf)
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) :
PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT),
TextToSpeech.OnInitListener {
private val binding = PopupActionMenuBinding.inflate(LayoutInflater.from(context))
private val adapter = Adapter(context)
private val menuItems: List<MenuItemImpl>

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

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

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

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

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

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

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

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

@ -24,7 +24,7 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
TocViewModel.BookmarkCallBack {
override val viewModel by activityViewModels<TocViewModel>()
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
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
@ -37,7 +37,6 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
private fun initRecyclerView() {
ATH.applyEdgeEffectColor(binding.recyclerView)
adapter = BookmarkAdapter(requireContext(), this)
binding.recyclerView.layoutManager = LinearLayoutManager(requireContext())
binding.recyclerView.addItemDecoration(VerticalDivider(requireContext()))
binding.recyclerView.adapter = adapter

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

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

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

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

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

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

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

@ -43,8 +43,16 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
private val binding by viewBinding(FragmentRssArticlesBinding::bind)
private val activityViewModel by activityViewModels<RssSortViewModel>()
override val viewModel by viewModels<RssArticlesViewModel>()
lateinit var adapter: BaseRssArticlesAdapter<*>
private lateinit var loadMoreView: LoadMoreView
private val adapter: BaseRssArticlesAdapter<*> by lazy {
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
override val isGridLayout: Boolean
get() = activityViewModel.isGridLayout
@ -64,15 +72,8 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
} else {
recyclerView.addItemDecoration(VerticalDivider(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
loadMoreView = LoadMoreView(requireContext())
adapter.addFooterView {
ViewLoadMoreBinding.bind(loadMoreView)
}

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

@ -18,7 +18,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
RssFavoritesAdapter.CallBack {
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?) {
initView()
@ -29,7 +29,6 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
binding.recyclerView.let {
it.layoutManager = LinearLayoutManager(this)
it.addItemDecoration(VerticalDivider(this))
adapter = RssFavoritesAdapter(this, this)
it.adapter = adapter
}
}

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

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

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

@ -30,7 +30,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
RuleSubAdapter.Callback {
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?) {
initView()
@ -53,7 +53,6 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
}
private fun initView() {
adapter = RuleSubAdapter(this, this)
binding.recyclerView.adapter = adapter
val itemTouchCallback = ItemTouchCallback(adapter)
itemTouchCallback.isCanDrag = true

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

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

Loading…
Cancel
Save