From f2b5b95cc91f7986763074fd56b9a20b669e2f8f Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 25 Jan 2020 09:59:46 +0800 Subject: [PATCH] up --- .../legado/app/ui/book/info/BookInfoActivity.kt | 16 +++++++++++++--- .../legado/app/ui/book/read/ReadBookActivity.kt | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index c55c1812c..220328ab3 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -32,6 +32,7 @@ import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_book_info.* import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity +import org.jetbrains.anko.startActivityForResult import org.jetbrains.anko.toast @@ -41,6 +42,9 @@ class BookInfoActivity : ChapterListAdapter.CallBack, ChangeSourceDialog.CallBack { + private val requestCodeChapterList = 568 + private val requestCodeSourceEdit = 562 + override val viewModel: BookInfoViewModel get() = getViewModel(BookInfoViewModel::class.java) @@ -70,7 +74,10 @@ class BookInfoActivity : R.id.menu_edit -> { if (viewModel.inBookshelf) { viewModel.bookData.value?.let { - startActivity(Pair("bookUrl", it.bookUrl)) + startActivityForResult( + requestCodeSourceEdit, + Pair("bookUrl", it.bookUrl) + ) } } else { toast(R.string.after_add_bookshelf) @@ -284,8 +291,11 @@ class BookInfoActivity : override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) - if (resultCode == Activity.RESULT_OK) { - viewModel.initData(intent) + when (requestCode) { + requestCodeSourceEdit -> if (resultCode == Activity.RESULT_OK) { + viewModel.initData(intent) + } + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 9045305b5..7437c3cae 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -66,7 +66,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo ColorPickerDialogListener { private val requestCodeChapterList = 568 private val requestCodeEditSource = 111 - private val requestCodeReplace = 31242 + private val requestCodeReplace = 312 override val viewModel: ReadBookViewModel get() = getViewModel(ReadBookViewModel::class.java)