This commit is contained in:
kunfei 2023-02-28 18:37:22 +08:00
parent 785c02ca36
commit 75dbc75290
4 changed files with 15 additions and 15 deletions

View File

@ -55,7 +55,7 @@ class ChangeBookSourceAdapter(
tvOrigin.text = item.originName
tvAuthor.text = item.author
tvLast.text = item.getDisplayLastChapterTitle()
if (callBack.bookUrl == item.bookUrl) {
if (callBack.oldBookUrl == item.bookUrl) {
ivChecked.visible()
} else {
ivChecked.invisible()
@ -65,7 +65,7 @@ class ChangeBookSourceAdapter(
when (it) {
"name" -> tvOrigin.text = item.originName
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
"upCurSource" -> if (callBack.bookUrl == item.bookUrl) {
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
ivChecked.visible()
} else {
ivChecked.invisible()
@ -126,7 +126,7 @@ class ChangeBookSourceAdapter(
}
holder.itemView.setOnClickListener {
getItem(holder.layoutPosition)?.let {
if (it.bookUrl != callBack.bookUrl) {
if (it.bookUrl != callBack.oldBookUrl) {
callBack.changeTo(it)
}
}
@ -165,7 +165,7 @@ class ChangeBookSourceAdapter(
}
interface CallBack {
val bookUrl: String?
val oldBookUrl: String?
fun changeTo(searchBook: SearchBook)
fun topSource(searchBook: SearchBook)
fun bottomSource(searchBook: SearchBook)

View File

@ -235,7 +235,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
private fun scrollToDurSource() {
adapter.getItems().forEachIndexed { index, searchBook ->
if (searchBook.bookUrl == bookUrl) {
if (searchBook.bookUrl == oldBookUrl) {
(binding.recyclerView.layoutManager as LinearLayoutManager)
.scrollToPositionWithOffset(index, 60.dpToPx())
return
@ -264,7 +264,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
}
}
override val bookUrl: String?
override val oldBookUrl: String?
get() = callBack?.oldBook?.bookUrl
override fun topSource(searchBook: SearchBook) {
@ -287,7 +287,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
override fun deleteSource(searchBook: SearchBook) {
viewModel.del(searchBook)
if (bookUrl == searchBook.bookUrl) {
if (oldBookUrl == searchBook.bookUrl) {
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
callBack?.changeTo(source, book, toc)
}
@ -349,7 +349,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
adapter.notifyItemRangeChanged(
0,
adapter.itemCount,
bundleOf(Pair("upCurSource", bookUrl))
bundleOf(Pair("upCurSource", oldBookUrl))
)
}
}

View File

@ -55,7 +55,7 @@ class ChangeChapterSourceAdapter(
tvOrigin.text = item.originName
tvAuthor.text = item.author
tvLast.text = item.getDisplayLastChapterTitle()
if (callBack.bookUrl == item.bookUrl) {
if (callBack.oldBookUrl == item.bookUrl) {
ivChecked.visible()
} else {
ivChecked.invisible()
@ -65,7 +65,7 @@ class ChangeChapterSourceAdapter(
when (it) {
"name" -> tvOrigin.text = item.originName
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
"upCurSource" -> if (callBack.bookUrl == item.bookUrl) {
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
ivChecked.visible()
} else {
ivChecked.invisible()
@ -163,7 +163,7 @@ class ChangeChapterSourceAdapter(
}
interface CallBack {
val bookUrl: String?
val oldBookUrl: String?
fun openToc(searchBook: SearchBook)
fun topSource(searchBook: SearchBook)
fun bottomSource(searchBook: SearchBook)

View File

@ -255,7 +255,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
private fun scrollToDurSource() {
searchBookAdapter.getItems().forEachIndexed { index, searchBook ->
if (searchBook.bookUrl == bookUrl) {
if (searchBook.bookUrl == oldBookUrl) {
(binding.recyclerView.layoutManager as LinearLayoutManager)
.scrollToPositionWithOffset(index, 60.dpToPx())
return
@ -281,7 +281,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
}
}
override val bookUrl: String?
override val oldBookUrl: String?
get() = callBack?.oldBook?.bookUrl
override fun topSource(searchBook: SearchBook) {
@ -304,7 +304,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
override fun deleteSource(searchBook: SearchBook) {
viewModel.del(searchBook)
if (bookUrl == searchBook.bookUrl) {
if (oldBookUrl == searchBook.bookUrl) {
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
callBack?.changeTo(source, book, toc)
}
@ -360,7 +360,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
searchBookAdapter.notifyItemRangeChanged(
0,
searchBookAdapter.itemCount,
bundleOf(Pair("upCurSource", bookUrl))
bundleOf(Pair("upCurSource", oldBookUrl))
)
}
}