|
@@ -59,6 +59,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|
|
registerForActivityResult(StartActivityContract(BookSourceEditActivity::class.java)) {
|
|
registerForActivityResult(StartActivityContract(BookSourceEditActivity::class.java)) {
|
|
|
viewModel.startSearch()
|
|
viewModel.startSearch()
|
|
|
}
|
|
}
|
|
|
|
|
+ private val searchBookAdapter by lazy {
|
|
|
|
|
+ ChangeChapterSourceAdapter(requireContext(), viewModel, this)
|
|
|
|
|
+ }
|
|
|
|
|
+ private val tocAdapter by lazy {
|
|
|
|
|
+ ChangeChapterTocAdapter(requireContext(), this)
|
|
|
|
|
+ }
|
|
|
private val tocSuccess: (toc: List<BookChapter>) -> Unit = {
|
|
private val tocSuccess: (toc: List<BookChapter>) -> Unit = {
|
|
|
tocAdapter.durChapterIndex =
|
|
tocAdapter.durChapterIndex =
|
|
|
BookHelp.getDurChapter(viewModel.chapterIndex, viewModel.chapterTitle, it)
|
|
BookHelp.getDurChapter(viewModel.chapterIndex, viewModel.chapterTitle, it)
|
|
@@ -71,12 +77,6 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|
|
callBack?.replaceContent(it)
|
|
callBack?.replaceContent(it)
|
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
|
}
|
|
}
|
|
|
- private val searchBookAdapter by lazy {
|
|
|
|
|
- ChangeChapterSourceAdapter(requireContext(), viewModel, this)
|
|
|
|
|
- }
|
|
|
|
|
- private val tocAdapter by lazy {
|
|
|
|
|
- ChangeChapterTocAdapter(requireContext(), this)
|
|
|
|
|
- }
|
|
|
|
|
private var searchBook: SearchBook? = null
|
|
private var searchBook: SearchBook? = null
|
|
|
|
|
|
|
|
override fun onStart() {
|
|
override fun onStart() {
|
|
@@ -199,6 +199,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|
|
|
|
|
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
|
override fun onMenuItemClick(item: MenuItem?): Boolean {
|
|
|
when (item?.itemId) {
|
|
when (item?.itemId) {
|
|
|
|
|
+ R.id.menu_scroll_to_dur -> scrollToDurSource()
|
|
|
R.id.menu_check_author -> {
|
|
R.id.menu_check_author -> {
|
|
|
AppConfig.changeSourceCheckAuthor = !item.isChecked
|
|
AppConfig.changeSourceCheckAuthor = !item.isChecked
|
|
|
item.isChecked = !item.isChecked
|
|
item.isChecked = !item.isChecked
|
|
@@ -230,6 +231,15 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private fun scrollToDurSource() {
|
|
|
|
|
+ searchBookAdapter.getItems().forEachIndexed { index, searchBook ->
|
|
|
|
|
+ if (searchBook.bookUrl == bookUrl) {
|
|
|
|
|
+ binding.recyclerView.scrollToPosition(index)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
override fun openToc(searchBook: SearchBook) {
|
|
override fun openToc(searchBook: SearchBook) {
|
|
|
this.searchBook = searchBook
|
|
this.searchBook = searchBook
|
|
|
tocAdapter.setItems(null)
|
|
tocAdapter.setItems(null)
|