@@ -119,7 +119,7 @@ public class AndroidNotification {
119
119
.put (Priority .HIGH , "PRIORITY_HIGH" )
120
120
.put (Priority .MAX , "PRIORITY_MAX" )
121
121
.build ();
122
-
122
+
123
123
private AndroidNotification (Builder builder ) {
124
124
this .title = builder .title ;
125
125
this .body = builder .body ;
@@ -150,7 +150,7 @@ private AndroidNotification(Builder builder) {
150
150
this .titleLocArgs = null ;
151
151
}
152
152
this .channelId = builder .channelId ;
153
- this .image = builder .image ;
153
+ this .image = builder .image ;
154
154
this .ticker = builder .ticker ;
155
155
this .sticky = builder .sticky ;
156
156
this .eventTime = builder .eventTime ;
@@ -174,6 +174,10 @@ private AndroidNotification(Builder builder) {
174
174
} else {
175
175
this .visibility = null ;
176
176
}
177
+ if (builder .notificationCount != null ) {
178
+ checkArgument (builder .notificationCount >= 0 ,
179
+ "notificationCount if specified must be zero or positive valued" );
180
+ }
177
181
this .notificationCount = builder .notificationCount ;
178
182
}
179
183
@@ -220,6 +224,7 @@ public static class Builder {
220
224
private List <String > titleLocArgs = new ArrayList <>();
221
225
private String channelId ;
222
226
private String image ;
227
+ private Integer notificationCount ;
223
228
private String ticker ;
224
229
private Boolean sticky ;
225
230
private String eventTime ;
@@ -231,7 +236,6 @@ public static class Builder {
231
236
private LightSettings lightSettings ;
232
237
private Boolean defaultLightSettings ;
233
238
private Visibility visibility ;
234
- private Integer notificationCount ;
235
239
236
240
private Builder () {}
237
241
@@ -580,13 +584,15 @@ public Builder setVisibility(Visibility visibility) {
580
584
581
585
/**
582
586
* Sets the number of items this notification represents. May be displayed as a badge
583
- * count for launchers that support badging. For example, this might be useful if you're
584
- * using just one notification to represent multiple new messages but you want the count
585
- * here to represent the number of total new messages. If zero or unspecified, systems
586
- * that support badging use the default, which is to increment a number displayed on
587
+ * count for launchers that support badging.
588
+ * If not invoked then notification count is left unchanged.
589
+ * For example, this might be useful if you're using just one notification to represent
590
+ * multiple new messages but you want the count here to represent the number of total
591
+ * new messages. If zero or unspecified, systems that support badging use the default,
592
+ * which is to increment a number displayed on
587
593
* the long-press menu each time a new notification arrives.
588
594
*
589
- * @param notificationCount The notification count
595
+ * @param notificationCount Zero or positive value. Zero indicates leave unchanged.
590
596
* @return This builder.
591
597
*/
592
598
public Builder setNotificationCount (int notificationCount ) {
0 commit comments