Slide 27
Slide 27 text
@Louis_CAD
What if there Noti
f
ications were Kotlin-
f
irst?
Current API
@CheckResult fun bigText(
context: Context,
channelId: String,
title: String,
multiLineText: String,
openAction: Intent
): Notification = NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_my_fancy_monochrome_icon)
.setContentTitle(title)
.setContentText(multiLineText)
.setStyle(
NotificationCompat.BigTextStyle()
.setBigContentTitle(title)
.bigText(multiLineText)
)
.setContentIntent(
PendingIntent.getActivity(
context,
0,
//
requestCode
openAction,
PendingIntent.FLAG_IMMUTABLE
)
)
.build()
Only needs the applicationContext : could be omitted
1
1
1
1
2 Limited type safety : can lead to mistakes
2
2
3
3
Duplication
3
4
4
Could be default values
4
5
Could be an extension function
5
Builder… build… 👷 🔨 …ceremony
6
set, set, set, set, set, set, set…
7
6
6
8
Doesn't look like it, but small icon is actually required!
8