diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index b43433de7..eb59a6dce 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.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(R.layout.activity_book_info) { +class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info), ChangeSourceDialog.CallBack { override val viewModel: BookInfoViewModel get() = getViewModel(BookInfoViewModel::class.java) @@ -29,6 +29,10 @@ class BookInfoActivity : VMBaseActivity(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(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") diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index b4d2f4589..e563be35f 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -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 { + + } + } \ No newline at end of file