pull/32/head
kunfei 5 years ago
parent 02164d24c7
commit f4a21709e5
  1. 4
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceAdapter.kt
  2. 12
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  3. 2
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -20,7 +20,7 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
this.onClick { callBack.changeTo(item) } this.onClick { callBack.changeTo(item) }
tv_origin.text = item.originName tv_origin.text = item.originName
tv_last.text = item.latestChapterTitle tv_last.text = item.latestChapterTitle
if (callBack.curBookUrl() == item.bookUrl) { if (callBack.curOrigin() == item.origin) {
iv_checked.visible() iv_checked.visible()
} else { } else {
iv_checked.invisible() iv_checked.invisible()
@ -34,6 +34,6 @@ class ChangeSourceAdapter(context: Context, val callBack: CallBack) :
interface CallBack { interface CallBack {
fun changeTo(searchBook: SearchBook) fun changeTo(searchBook: SearchBook)
fun curBookUrl(): String fun curOrigin(): String
} }
} }

@ -24,12 +24,12 @@ class ChangeSourceDialog : DialogFragment(),
companion object { companion object {
const val tag = "changeSourceDialog" const val tag = "changeSourceDialog"
fun newInstance(name: String, author: String, bookUrl: String? = null): ChangeSourceDialog { fun newInstance(name: String, author: String, origin: String): ChangeSourceDialog {
val changeSourceDialog = ChangeSourceDialog() val changeSourceDialog = ChangeSourceDialog()
val bundle = Bundle() val bundle = Bundle()
bundle.putString("name", name) bundle.putString("name", name)
bundle.putString("author", author) bundle.putString("author", author)
bundle.putString("bookUrl", bookUrl) bundle.putString("origin", origin)
changeSourceDialog.arguments = bundle changeSourceDialog.arguments = bundle
return changeSourceDialog return changeSourceDialog
} }
@ -53,8 +53,8 @@ class ChangeSourceDialog : DialogFragment(),
bundle.getString("author")?.let { bundle.getString("author")?.let {
viewModel.author = it viewModel.author = it
} }
bundle.getString("bookUrl")?.let { bundle.getString("origin")?.let {
viewModel.curBookUrl = it viewModel.curOrigin = it
} }
} }
tool_bar.inflateMenu(R.menu.search_view) tool_bar.inflateMenu(R.menu.search_view)
@ -127,8 +127,8 @@ class ChangeSourceDialog : DialogFragment(),
dismiss() dismiss()
} }
override fun curBookUrl(): String { override fun curOrigin(): String {
return viewModel.curBookUrl return viewModel.curOrigin
} }
override fun adapter(): ChangeSourceAdapter { override fun adapter(): ChangeSourceAdapter {

@ -16,7 +16,7 @@ import org.jetbrains.anko.debug
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { class ChangeSourceViewModel(application: Application) : BaseViewModel(application) {
var callBack: CallBack? = null var callBack: CallBack? = null
var curBookUrl = "" var curOrigin = ""
var name: String = "" var name: String = ""
var author: String = "" var author: String = ""
var screenKey: String = "" var screenKey: String = ""

Loading…
Cancel
Save