From 586130c2fe5679ebea8b5c567f66dd1a104e137a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 7 Feb 2020 10:57:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/group/GroupSelectDialog.kt | 21 ++++++++++++------- .../app/ui/book/info/BookInfoActivity.kt | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt index 6dbdbd17b..86fc619e3 100644 --- a/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt @@ -42,15 +42,17 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { companion object { const val tag = "groupSelectDialog" - fun show(manager: FragmentManager) { - val fragment = GroupSelectDialog() - fragment.show( - manager, - tag - ) + fun show(manager: FragmentManager, requestCode: Int = -1) { + val fragment = GroupSelectDialog().apply { + val bundle = Bundle() + bundle.putInt("requestCode", requestCode) + arguments = bundle + } + fragment.show(manager, tag) } } + private var requestCode: Int = -1 private lateinit var viewModel: BookshelfViewModel private lateinit var adapter: GroupAdapter private var callBack: CallBack? = null @@ -74,6 +76,9 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) callBack = activity as? CallBack + arguments?.getInt("requestCode")?.let { + requestCode = it + } initData() } @@ -157,7 +162,7 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { tv_edit.onClick { editGroup(item) } tv_del.onClick { viewModel.delGroup(item) } this.onClick { - callBack?.upGroup(item) + callBack?.upGroup(requestCode, item) dismiss() } } @@ -181,6 +186,6 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener { } interface CallBack { - fun upGroup(group: BookGroup) + fun upGroup(requestCode: Int, group: BookGroup) } } \ No newline at end of file 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 cf86b2f04..9efde78b9 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 @@ -306,7 +306,7 @@ class BookInfoActivity : return viewModel.durChapterIndex } - override fun upGroup(group: BookGroup) { + override fun upGroup(requestCode: Int, group: BookGroup) { viewModel.groupData.postValue(group) viewModel.bookData.value?.group = group.groupId if (viewModel.inBookshelf) {