This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoticeDialogFragment : DialogFragment() { | |
internal lateinit var listener: NoticeDialogListener | |
interface NoticeDialogListener { | |
fun onDialogPositiveClick(dialog: DialogFragment) | |
fun onDialogNegativeClick(dialog: DialogFragment) | |
} | |
override fun onAttach(context: Context) { | |
super.onAttach(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFragment : Fragment(R.layout.my_layout) { | |
fun onSomeAction() { | |
coroutineScope.launch { | |
// Code A | |
when (val dialogResult = showDialogAndAwaitResult()) { | |
DialogResult.Ok -> { | |
// Code C | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyFragment : Fragment(R.layout.my_layout) { | |
fun onSomeAction() { | |
// Code A | |
showDialog( | |
onOkClicked = { ... }, | |
onCancelClicked = { ... } | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeFragment : Fragment(R.layout.home_fragment) { | |
private val binding by viewBinding<HomeFragmentBinding>() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
binding.button.setOnClickListener { | |
findNavController().navigate(HomeFragmentDirections.toMyDialog()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun confirmStartGame() { | |
val fm = supportFragmentManager | |
if (fm.isStateSaved) return | |
val newFragment = StartGameDialogFragment() | |
newFragment.show(newFragment, "game") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun confirmStartGame() { | |
val newFragment = StartGameDialogFragment() | |
newFragment.show(supportFragmentManager, "game") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomDialog : DialogFragment(R.layout.custom_dialog) { | |
private val binding by viewBinding<CustomDialogBinding>() | |
private val viewModel by viewModels<CustomDialogViewModel>() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
// Setup UI and other stuff ... | |
} | |
} |