|
|
@ -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) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |