@@ -83,10 +83,12 @@ class NotificationHelper(val context: Context) {
8383 // a Target is like a listener for image loading events
8484 val target = object : Target {
8585 override fun onBitmapLoaded (bitmap : Bitmap , from : Picasso .LoadedFrom ) {
86- summaryBuilder.setLargeIcon(bitmap) // set only if there is actually one
86+ // set channel icon only if there is actually one (for Android versions < 7.0)
87+ summaryBuilder.setLargeIcon(bitmap)
8788
88- // Show individual stream notifications
89- showStreamNotifications(newStreams, data.listInfo.serviceId)
89+ // Show individual stream notifications, set channel icon only if there is actually
90+ // one
91+ showStreamNotifications(newStreams, data.listInfo.serviceId, bitmap)
9092 // Show summary notification
9193 manager.notify(data.pseudoId, summaryBuilder.build())
9294
@@ -95,7 +97,7 @@ class NotificationHelper(val context: Context) {
9597
9698 override fun onBitmapFailed (e : Exception , errorDrawable : Drawable ) {
9799 // Show individual stream notifications
98- showStreamNotifications(newStreams, data.listInfo.serviceId)
100+ showStreamNotifications(newStreams, data.listInfo.serviceId, null )
99101 // Show summary notification
100102 manager.notify(data.pseudoId, summaryBuilder.build())
101103 iconLoadingTargets.remove(this ) // allow it to be garbage-collected
@@ -113,20 +115,28 @@ class NotificationHelper(val context: Context) {
113115 PicassoHelper .loadNotificationIcon(data.avatarUrl).into(target)
114116 }
115117
116- private fun showStreamNotifications (newStreams : List <StreamInfoItem >, serviceId : Int ) {
117- newStreams.asSequence()
118- .map { it to createStreamNotification(it, serviceId) }
119- .forEach { (stream, notification) ->
120- manager.notify(stream.url.hashCode(), notification)
121- }
118+ private fun showStreamNotifications (
119+ newStreams : List <StreamInfoItem >,
120+ serviceId : Int ,
121+ channelIcon : Bitmap ?
122+ ) {
123+ for (stream in newStreams) {
124+ val notification = createStreamNotification(stream, serviceId, channelIcon)
125+ manager.notify(stream.url.hashCode(), notification)
126+ }
122127 }
123128
124- private fun createStreamNotification (item : StreamInfoItem , serviceId : Int ): Notification {
129+ private fun createStreamNotification (
130+ item : StreamInfoItem ,
131+ serviceId : Int ,
132+ channelIcon : Bitmap ?
133+ ): Notification {
125134 return NotificationCompat .Builder (
126135 context,
127136 context.getString(R .string.streams_notification_channel_id)
128137 )
129138 .setSmallIcon(R .drawable.ic_newpipe_triangle_white)
139+ .setLargeIcon(channelIcon)
130140 .setContentTitle(item.name)
131141 .setContentText(item.uploaderName)
132142 .setGroup(item.uploaderUrl)
0 commit comments