Created
May 22, 2018 16:29
-
-
Save alexstyl/ed682669cddeba9462580f90f9be4926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
.setActions(viewModel) | |
.loadLargeImage(viewModel.contact.imagePath) | |
.setSmallIcon(R.drawable.ic_stat_memento) | |
.setColor(colors.getDailyReminderColor()) | |
.setGroup(NotificationConstants.DAILY_REMINDER_GROUP_ID) | |
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) | |
.setAutoCancel(true) | |
.addPerson(CONTENT_LOOKUP_URI.buildUpon().appendPath(viewModel.contact.contactID.toString()).build().toString()) | |
.build() | |
notificationManager.notify(viewModel.notificationId, notification) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment