Skip to content

Instantly share code, notes, and snippets.

@fardavide
Created May 3, 2019 14:06
Show Gist options
  • Save fardavide/4c08d6c8d54d2e26f2f5d8cc5bf0fcd6 to your computer and use it in GitHub Desktop.
Save fardavide/4c08d6c8d54d2e26f2f5d8cc5bf0fcd6 to your computer and use it in GitHub Desktop.
class NotificationBuilder(
context: Context
) : ResourcedBuilder by context() {
var contentText: CharSequence? by optional { contentTextRes }
@StringRes var contentTextRes: Int? = null
var title: CharSequence by required { titleRes }
@get:StringRes var titleRes: Int? = null
@get:DrawableRes var smallIconRes: Int by required()
internal fun build(): Notification {
return builder
.setContentTitle( title )
.apply { contentText?.let { setContentText( it ) } }
...
.build()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment