Created
November 5, 2022 21:10
-
-
Save k0siara/e7eb0c4dca0088596202e5a9cdfd587f to your computer and use it in GitHub Desktop.
BetterMyFragment.kt
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 | |
} | |
DialogResult.Cancel -> { | |
// Code D | |
} | |
} | |
// Code B | |
} | |
} | |
private suspend fun showDialogAndAwaitResult(): DialogResult { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment