pull/36/head
kunfei 5 years ago
parent 5c594ffbd5
commit a73dd8a20d
  1. 10
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 19
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt

@ -232,13 +232,11 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
}
}
override fun curOrigin(): String? {
return viewModel.bookData.value?.origin
}
override val curOrigin: String?
get() = viewModel.bookData.value?.origin
override fun oldBook(): Book? {
return viewModel.bookData.value
}
override val oldBook: Book?
get() = viewModel.bookData.value
override fun changeTo(book: Book) {
upLoading(true)

@ -330,13 +330,11 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
return viewModel.chapterSize
}
override fun curOrigin(): String? {
return viewModel.bookData.value?.origin
}
override val curOrigin: String?
get() = viewModel.bookData.value?.origin
override fun oldBook(): Book? {
return viewModel.bookData.value
}
override val oldBook: Book?
get() = viewModel.bookData.value
override fun changeTo(book: Book) {
viewModel.changeTo(book)

@ -35,6 +35,7 @@ class ChangeSourceDialog : DialogFragment(),
}
}
private var callBack: CallBack? = null
private lateinit var viewModel: ChangeSourceViewModel
private lateinit var changeSourceAdapter: ChangeSourceAdapter
@ -49,6 +50,7 @@ class ChangeSourceDialog : DialogFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
callBack = activity as? CallBack
viewModel.searchStateData.observe(viewLifecycleOwner, Observer {
refresh_progress_bar.isAutoLoading = it
})
@ -114,10 +116,8 @@ class ChangeSourceDialog : DialogFragment(),
}
override fun changeTo(searchBook: SearchBook) {
val activity = activity
if (activity is CallBack) {
val book = searchBook.toBook()
activity.oldBook()?.let { oldBook ->
callBack?.oldBook?.let { oldBook ->
book.durChapterIndex = oldBook.durChapterIndex
book.durChapterPos = oldBook.durChapterPos
book.durChapterTitle = oldBook.durChapterTitle
@ -127,18 +127,13 @@ class ChangeSourceDialog : DialogFragment(),
if (book.coverUrl.isNullOrEmpty()) {
book.coverUrl = oldBook.getDisplayCover()
}
activity.changeTo(book)
}
callBack?.changeTo(book)
}
dismiss()
}
override fun curOrigin(): String {
val activity = activity
if (activity is CallBack) {
return activity.curOrigin() ?: ""
}
return ""
return callBack?.curOrigin ?: ""
}
override fun adapter(): ChangeSourceAdapter {
@ -146,8 +141,8 @@ class ChangeSourceDialog : DialogFragment(),
}
interface CallBack {
fun curOrigin(): String?
fun oldBook(): Book?
val curOrigin: String?
val oldBook: Book?
fun changeTo(book: Book)
}

Loading…
Cancel
Save