pull/32/head
kunfei 5 years ago
parent 773c329d2b
commit 7f694ccdad
  1. 4
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt
  3. 12
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  4. 4
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt

@ -189,6 +189,10 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
} }
} }
override fun oldBook(): Book? {
return viewModel.bookData.value
}
override fun changeTo(book: Book) { override fun changeTo(book: Book) {
viewModel.changeTo(book) viewModel.changeTo(book)
} }

@ -82,12 +82,6 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
} }
fun changeTo(book: Book) { fun changeTo(book: Book) {
bookData.value?.let {
book.durChapterIndex = it.durChapterIndex
book.durChapterPos = it.durChapterPos
book.customCoverUrl = it.customCoverUrl
book.customIntro = it.customIntro
}
execute { execute {
if (inBookshelf) { if (inBookshelf) {
bookData.value?.let { bookData.value?.let {

@ -109,7 +109,16 @@ class ChangeSourceDialog : DialogFragment(),
} }
override fun changeTo(searchBook: SearchBook) { override fun changeTo(searchBook: SearchBook) {
callBack?.changeTo(searchBook.toBook()) callBack?.let {
val book = searchBook.toBook()
it.oldBook()?.let { oldBook ->
book.durChapterIndex = oldBook.durChapterIndex
book.durChapterPos = oldBook.durChapterPos
book.customCoverUrl = oldBook.customCoverUrl
book.customIntro = oldBook.customIntro
}
it.changeTo(book)
}
dismiss() dismiss()
} }
@ -122,6 +131,7 @@ class ChangeSourceDialog : DialogFragment(),
} }
interface CallBack { interface CallBack {
fun oldBook(): Book?
fun changeTo(book: Book) fun changeTo(book: Book)
} }

@ -267,6 +267,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
} }
} }
override fun oldBook(): Book? {
return viewModel.bookData.value
}
override fun changeTo(book: Book) { override fun changeTo(book: Book) {
} }

Loading…
Cancel
Save