|
|
|
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
|
import io.legado.app.constant.AppPattern |
|
|
|
|
import io.legado.app.constant.EventBus |
|
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
|
import io.legado.app.data.appDb |
|
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
@ -218,12 +219,12 @@ class ChangeSourceDialog : BaseDialogFragment(), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun deleteSource(searchBook: SearchBook) { |
|
|
|
|
viewModel.del(searchBook) |
|
|
|
|
if (bookUrl == searchBook.bookUrl) { |
|
|
|
|
viewModel.firstSourceOrNull(searchBook)?.let { |
|
|
|
|
changeSource(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
viewModel.del(searchBook) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun changeSource(searchBook: SearchBook) { |
|
|
|
@ -259,6 +260,15 @@ class ChangeSourceDialog : BaseDialogFragment(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun observeLiveBus() { |
|
|
|
|
observeEvent<String>(EventBus.SOURCE_CHANGED) { |
|
|
|
|
val payload = Bundle().apply { |
|
|
|
|
putString("upCurSource", bookUrl) |
|
|
|
|
} |
|
|
|
|
adapter.notifyItemRangeChanged(0, adapter.itemCount, payload) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
|
val oldBook: Book? |
|
|
|
|
fun changeTo(book: Book) |
|
|
|
|