Skip to content

Instantly share code, notes, and snippets.

@alexstyl
Last active June 12, 2018 11:01
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 alexstyl/872f05d3a97361939a1629fded65f68f to your computer and use it in GitHub Desktop.
Save alexstyl/872f05d3a97361939a1629fded65f68f to your computer and use it in GitHub Desktop.
private fun notifyContacts(viewModels: List<ContactEventNotificationViewModel>) {
viewModels.forEach { viewModel ->
val requestCode = NotificationConstants.CHANNEL_ID_CONTACTS.hashCode() + viewModel.hashCode()
val startIntent = PersonActivity.buildIntentFor(context, viewModel.contact)
val pendingIntent = PendingIntent.getActivity(
context,
requestCode,
startIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
val notification =
NotificationCompat.Builder(context, NotificationConstants.CHANNEL_ID_CONTACTS)
.setContentTitle(viewModel.title)
.setContentText(viewModel.label)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_stat_memento)
.setColor(colors.getDailyReminderColor())
.setGroup(NotificationConstants.DAILY_REMINDER_GROUP_ID)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY)
.setAutoCancel(true)
.addActionsFrom(viewModel)
.loadLargeImage(viewModel.contact.imagePath)
.build()
notificationManager.notify(viewModel.notificationId, notification)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment