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