Skip to content

Instantly share code, notes, and snippets.

@ditn
Created April 26, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ditn/c9eb85f4d5e3664323a6f80b17420dbc to your computer and use it in GitHub Desktop.
Save ditn/c9eb85f4d5e3664323a6f80b17420dbc to your computer and use it in GitHub Desktop.
Idiomatic ternary function in Kotlin
val builder = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(icon)
// Excluded for brevity
.apply {
if (AndroidUtils.is19orHigher()) {
setVibrate(longArrayOf(100))
} else {
setVibrate(longArrayOf())
}
}
.setContentText(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment