pull/94/head
kunfei 5 years ago
parent dbee2f6c04
commit 586130c2fe
  1. 21
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@ -42,15 +42,17 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
companion object { companion object {
const val tag = "groupSelectDialog" const val tag = "groupSelectDialog"
fun show(manager: FragmentManager) { fun show(manager: FragmentManager, requestCode: Int = -1) {
val fragment = GroupSelectDialog() val fragment = GroupSelectDialog().apply {
fragment.show( val bundle = Bundle()
manager, bundle.putInt("requestCode", requestCode)
tag arguments = bundle
) }
fragment.show(manager, tag)
} }
} }
private var requestCode: Int = -1
private lateinit var viewModel: BookshelfViewModel private lateinit var viewModel: BookshelfViewModel
private lateinit var adapter: GroupAdapter private lateinit var adapter: GroupAdapter
private var callBack: CallBack? = null private var callBack: CallBack? = null
@ -74,6 +76,9 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
callBack = activity as? CallBack callBack = activity as? CallBack
arguments?.getInt("requestCode")?.let {
requestCode = it
}
initData() initData()
} }
@ -157,7 +162,7 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
tv_edit.onClick { editGroup(item) } tv_edit.onClick { editGroup(item) }
tv_del.onClick { viewModel.delGroup(item) } tv_del.onClick { viewModel.delGroup(item) }
this.onClick { this.onClick {
callBack?.upGroup(item) callBack?.upGroup(requestCode, item)
dismiss() dismiss()
} }
} }
@ -181,6 +186,6 @@ class GroupSelectDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
} }
interface CallBack { interface CallBack {
fun upGroup(group: BookGroup) fun upGroup(requestCode: Int, group: BookGroup)
} }
} }

@ -306,7 +306,7 @@ class BookInfoActivity :
return viewModel.durChapterIndex return viewModel.durChapterIndex
} }
override fun upGroup(group: BookGroup) { override fun upGroup(requestCode: Int, group: BookGroup) {
viewModel.groupData.postValue(group) viewModel.groupData.postValue(group)
viewModel.bookData.value?.group = group.groupId viewModel.bookData.value?.group = group.groupId
if (viewModel.inBookshelf) { if (viewModel.inBookshelf) {

Loading…
Cancel
Save