Skip to content

Instantly share code, notes, and snippets.

View vad-zuev's full-sized avatar

Vadim Zuev vad-zuev

View GitHub Profile
@vad-zuev
vad-zuev / AlertDialog.kt
Last active August 6, 2018 11:51
Shows an AlertDialog that doesn't break an active immersive mode. Credits go to Beaver6813 for the original idea (https://stackoverflow.com/questions/22794049/how-do-i-maintain-the-immersive-mode-in-dialogs/23207365)
/**
* Creates and shows an [AlertDialog] while maintaining the immersive mode.
* @param activity the `Activity` which will host the dialog
* @param title dialog's title
* @param message dialog's message
* @param cancelable whether the dialog should be cancelable
* @param yesButton the text for the positive button (no positive button will be added if `null` is passed)
* @param noButton the text for the negative button (no negative button will be added if `null` is passed)
* @param yesCallback callback to invoke when the user presses the positive button
* @param noCallback callback to invoke when the user presses the negative button