pull/32/head
kunfei 5 years ago
parent 8b81829bd7
commit 845e8a3b18
  1. 7
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt
  2. 5
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt

@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.view_title_bar.*
import org.jetbrains.anko.sdk27.listeners.onClick
import org.jetbrains.anko.startActivity
class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info) {
class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info), ChangeSourceDialog.CallBack {
override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java)
@ -29,6 +29,10 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
viewModel.isLoadingData.observe(this, Observer { upLoading(it) })
viewModel.loadBook(intent)
initView()
savedInstanceState?.let {
changeSourceDialog = supportFragmentManager.findFragmentByTag("changeSourceDialog") as? ChangeSourceDialog
changeSourceDialog?.callBack = this
}
}
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
@ -121,6 +125,7 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
if (changeSourceDialog == null) {
viewModel.bookData.value?.let {
changeSourceDialog = ChangeSourceDialog.newInstance(it.name, it.author)
changeSourceDialog?.callBack = this
}
}
changeSourceDialog?.show(supportFragmentManager, "changeSource")

@ -27,6 +27,7 @@ class ChangeSourceDialog : DialogFragment() {
}
private lateinit var viewModel: ChangeSourceViewModel
var callBack: CallBack? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
viewModel = getViewModel(ChangeSourceViewModel::class.java)
@ -88,4 +89,8 @@ class ChangeSourceDialog : DialogFragment() {
}
public interface CallBack {
}
}
Loading…
Cancel
Save