Skip to content

Instantly share code, notes, and snippets.

@alparslandev
Last active September 24, 2019 05:57
Show Gist options
  • Save alparslandev/eb148a5b847bec635dd855b04fd5d90f to your computer and use it in GitHub Desktop.
Save alparslandev/eb148a5b847bec635dd855b04fd5d90f to your computer and use it in GitHub Desktop.
show
private fun showAlertAndOperate(@StringRes stringId: Int, leave: Leave, func: () -> Unit) {
leaveDetailsDialogFragment.dismiss() // Close Leave Details Dialog Fragment
val text = getString(stringId, leave.User.getNameSurname(), LeaveDate.getDayAndTimeByFormat(leave.CreatedAt, LeaveDate.prettyFormatLongDateTime), leave.Reason.Name)
showAlertDialog(text, DialogInterface.OnClickListener {_, which ->
if (which == DialogInterface.BUTTON_POSITIVE) {
func()
/* func() is sent as parameter.
When dialog shows up and user tap OK button, func() is fired here */
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment