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
@Parcelize | |
data class Example(val id: String, val name: String) : Parcelable |
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
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleEventObserver | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.lifecycleScope | |
import kotlinx.coroutines.InternalCoroutinesApi | |
import kotlinx.coroutines.Job | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.collect | |
import kotlinx.coroutines.launch |
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
AlertDialog.Builder(context) | |
.setPositiveButton(R.string.ok) { dialog, id -> | |
// User clicked OK button | |
} | |
.setNegativeButton(R.string.cancel) { dialog, id -> | |
// User cancelled the dialog | |
} | |
.create() | |
.show() |
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 CustomAlertDialog : DialogFragment() { | |
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
AlertDialog.Builder(requireContext()) | |
.setMessage(getString(R.string.order_confirmation)) | |
.setPositiveButton(getString(R.string.ok)) { _,_ -> } | |
.create() | |
} | |
} |
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 ... | |
} | |
} |
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") | |
} |