@@ -55,15 +55,15 @@ public class FCMService extends FirebaseMessagingService implements PushConstant
55
55
private static HashMap <Integer , ArrayList <String >> messageMap = new HashMap <Integer , ArrayList <String >>();
56
56
57
57
public void setNotification (int notId , String message ) {
58
- ArrayList <String > messageList = messageMap .get (notId );
59
- if (messageList == null ) {
60
- messageList = new ArrayList <String >();
61
- messageMap .put (notId , messageList );
62
- }
63
58
64
59
if (message .isEmpty ()) {
65
- messageList . clear ( );
60
+ messageMap . remove ( notId );
66
61
} else {
62
+ ArrayList <String > messageList = messageMap .get (notId );
63
+ if (messageList == null ) {
64
+ messageList = new ArrayList <String >();
65
+ messageMap .put (notId , messageList );
66
+ }
67
67
messageList .add (message );
68
68
}
69
69
}
@@ -659,13 +659,35 @@ private void setNotificationOngoing(Bundle extras, NotificationCompat.Builder mB
659
659
660
660
private void setNotificationMessage (int notId , Bundle extras , NotificationCompat .Builder mBuilder ) {
661
661
String message = extras .getString (MESSAGE );
662
+ String lines = extras .getString (LINES );
662
663
String style = extras .getString (STYLE , STYLE_TEXT );
663
664
if (STYLE_INBOX .equals (style )) {
664
665
setNotification (notId , message );
665
666
666
667
mBuilder .setContentText (fromHtml (message ));
667
668
668
- ArrayList <String > messageList = messageMap .get (notId );
669
+ ArrayList <String > messageList = new ArrayList <String >();
670
+ if (lines != null ) {
671
+ setNotification (notId , "" );
672
+ try {
673
+ JSONArray linesList = new JSONArray (lines );
674
+ if (linesList .length () != 0 ) {
675
+ for (int i = 0 ; i < linesList .length (); i ++) {
676
+ messageList .add (linesList .optString (i ));
677
+ setNotification (notId , linesList .optString (i ));
678
+ }
679
+ }
680
+ } catch (JSONException e ) {
681
+ // nope
682
+ }
683
+ } else {
684
+ ArrayList <String > cachedMessages = messageMap .get (notId );
685
+ messageList .add (message );
686
+ for (int i = 0 ; i < cachedMessages .size (); i ++) {
687
+ messageList .addAll (cachedMessages );
688
+ }
689
+ }
690
+
669
691
Integer sizeList = messageList .size ();
670
692
if (sizeList > 1 ) {
671
693
String sizeListMessage = sizeList .toString ();
@@ -677,7 +699,7 @@ private void setNotificationMessage(int notId, Bundle extras, NotificationCompat
677
699
NotificationCompat .InboxStyle notificationInbox = new NotificationCompat .InboxStyle ()
678
700
.setBigContentTitle (fromHtml (extras .getString (TITLE ))).setSummaryText (fromHtml (stacking ));
679
701
680
- for (int i = messageList .size () - 1 ; i >= 0 ; i -- ) {
702
+ for (int i = 0 ; i < messageList .size (); i ++ ) {
681
703
notificationInbox .addLine (fromHtml (messageList .get (i )));
682
704
}
683
705
0 commit comments