优化
This commit is contained in:
@@ -55,7 +55,7 @@ class ChangeBookSourceAdapter(
|
|||||||
tvOrigin.text = item.originName
|
tvOrigin.text = item.originName
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvLast.text = item.getDisplayLastChapterTitle()
|
tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
if (callBack.bookUrl == item.bookUrl) {
|
if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.visible()
|
ivChecked.visible()
|
||||||
} else {
|
} else {
|
||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
@@ -65,7 +65,7 @@ class ChangeBookSourceAdapter(
|
|||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvOrigin.text = item.originName
|
"name" -> tvOrigin.text = item.originName
|
||||||
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
"upCurSource" -> if (callBack.bookUrl == item.bookUrl) {
|
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.visible()
|
ivChecked.visible()
|
||||||
} else {
|
} else {
|
||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
@@ -126,7 +126,7 @@ class ChangeBookSourceAdapter(
|
|||||||
}
|
}
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
getItem(holder.layoutPosition)?.let {
|
getItem(holder.layoutPosition)?.let {
|
||||||
if (it.bookUrl != callBack.bookUrl) {
|
if (it.bookUrl != callBack.oldBookUrl) {
|
||||||
callBack.changeTo(it)
|
callBack.changeTo(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ class ChangeBookSourceAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CallBack {
|
interface CallBack {
|
||||||
val bookUrl: String?
|
val oldBookUrl: String?
|
||||||
fun changeTo(searchBook: SearchBook)
|
fun changeTo(searchBook: SearchBook)
|
||||||
fun topSource(searchBook: SearchBook)
|
fun topSource(searchBook: SearchBook)
|
||||||
fun bottomSource(searchBook: SearchBook)
|
fun bottomSource(searchBook: SearchBook)
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
|
|||||||
|
|
||||||
private fun scrollToDurSource() {
|
private fun scrollToDurSource() {
|
||||||
adapter.getItems().forEachIndexed { index, searchBook ->
|
adapter.getItems().forEachIndexed { index, searchBook ->
|
||||||
if (searchBook.bookUrl == bookUrl) {
|
if (searchBook.bookUrl == oldBookUrl) {
|
||||||
(binding.recyclerView.layoutManager as LinearLayoutManager)
|
(binding.recyclerView.layoutManager as LinearLayoutManager)
|
||||||
.scrollToPositionWithOffset(index, 60.dpToPx())
|
.scrollToPositionWithOffset(index, 60.dpToPx())
|
||||||
return
|
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
|
get() = callBack?.oldBook?.bookUrl
|
||||||
|
|
||||||
override fun topSource(searchBook: SearchBook) {
|
override fun topSource(searchBook: SearchBook) {
|
||||||
@@ -287,7 +287,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
|
|||||||
|
|
||||||
override fun deleteSource(searchBook: SearchBook) {
|
override fun deleteSource(searchBook: SearchBook) {
|
||||||
viewModel.del(searchBook)
|
viewModel.del(searchBook)
|
||||||
if (bookUrl == searchBook.bookUrl) {
|
if (oldBookUrl == searchBook.bookUrl) {
|
||||||
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
|
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
|
||||||
callBack?.changeTo(source, book, toc)
|
callBack?.changeTo(source, book, toc)
|
||||||
}
|
}
|
||||||
@@ -349,7 +349,7 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
|
|||||||
adapter.notifyItemRangeChanged(
|
adapter.notifyItemRangeChanged(
|
||||||
0,
|
0,
|
||||||
adapter.itemCount,
|
adapter.itemCount,
|
||||||
bundleOf(Pair("upCurSource", bookUrl))
|
bundleOf(Pair("upCurSource", oldBookUrl))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class ChangeChapterSourceAdapter(
|
|||||||
tvOrigin.text = item.originName
|
tvOrigin.text = item.originName
|
||||||
tvAuthor.text = item.author
|
tvAuthor.text = item.author
|
||||||
tvLast.text = item.getDisplayLastChapterTitle()
|
tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
if (callBack.bookUrl == item.bookUrl) {
|
if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.visible()
|
ivChecked.visible()
|
||||||
} else {
|
} else {
|
||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
@@ -65,7 +65,7 @@ class ChangeChapterSourceAdapter(
|
|||||||
when (it) {
|
when (it) {
|
||||||
"name" -> tvOrigin.text = item.originName
|
"name" -> tvOrigin.text = item.originName
|
||||||
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
"latest" -> tvLast.text = item.getDisplayLastChapterTitle()
|
||||||
"upCurSource" -> if (callBack.bookUrl == item.bookUrl) {
|
"upCurSource" -> if (callBack.oldBookUrl == item.bookUrl) {
|
||||||
ivChecked.visible()
|
ivChecked.visible()
|
||||||
} else {
|
} else {
|
||||||
ivChecked.invisible()
|
ivChecked.invisible()
|
||||||
@@ -163,7 +163,7 @@ class ChangeChapterSourceAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CallBack {
|
interface CallBack {
|
||||||
val bookUrl: String?
|
val oldBookUrl: String?
|
||||||
fun openToc(searchBook: SearchBook)
|
fun openToc(searchBook: SearchBook)
|
||||||
fun topSource(searchBook: SearchBook)
|
fun topSource(searchBook: SearchBook)
|
||||||
fun bottomSource(searchBook: SearchBook)
|
fun bottomSource(searchBook: SearchBook)
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|||||||
|
|
||||||
private fun scrollToDurSource() {
|
private fun scrollToDurSource() {
|
||||||
searchBookAdapter.getItems().forEachIndexed { index, searchBook ->
|
searchBookAdapter.getItems().forEachIndexed { index, searchBook ->
|
||||||
if (searchBook.bookUrl == bookUrl) {
|
if (searchBook.bookUrl == oldBookUrl) {
|
||||||
(binding.recyclerView.layoutManager as LinearLayoutManager)
|
(binding.recyclerView.layoutManager as LinearLayoutManager)
|
||||||
.scrollToPositionWithOffset(index, 60.dpToPx())
|
.scrollToPositionWithOffset(index, 60.dpToPx())
|
||||||
return
|
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
|
get() = callBack?.oldBook?.bookUrl
|
||||||
|
|
||||||
override fun topSource(searchBook: SearchBook) {
|
override fun topSource(searchBook: SearchBook) {
|
||||||
@@ -304,7 +304,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|||||||
|
|
||||||
override fun deleteSource(searchBook: SearchBook) {
|
override fun deleteSource(searchBook: SearchBook) {
|
||||||
viewModel.del(searchBook)
|
viewModel.del(searchBook)
|
||||||
if (bookUrl == searchBook.bookUrl) {
|
if (oldBookUrl == searchBook.bookUrl) {
|
||||||
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
|
viewModel.autoChangeSource(callBack?.oldBook?.type) { book, toc, source ->
|
||||||
callBack?.changeTo(source, book, toc)
|
callBack?.changeTo(source, book, toc)
|
||||||
}
|
}
|
||||||
@@ -360,7 +360,7 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
|||||||
searchBookAdapter.notifyItemRangeChanged(
|
searchBookAdapter.notifyItemRangeChanged(
|
||||||
0,
|
0,
|
||||||
searchBookAdapter.itemCount,
|
searchBookAdapter.itemCount,
|
||||||
bundleOf(Pair("upCurSource", bookUrl))
|
bundleOf(Pair("upCurSource", oldBookUrl))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user