Fix notifications issue.

This commit is contained in:
Pierre 2018-04-11 08:30:15 +02:00
parent cd88567faf
commit 5798df62bf

View File

@ -30,6 +30,16 @@ public class NotificationsService extends IntentService {
*/
private static final String TAG = "NotificationsService";
/**
* Notification channel ID
*/
private final String CHANNEL_ID = "MainNotifChannel";
/**
* Main notification ID
*/
private final static int MAIN_NOTIFICATION_ID = 0;
/**
* Keep run status
*/
@ -40,15 +50,12 @@ public class NotificationsService extends IntentService {
*/
private NotificationsHelper mNotifHelper;
/**
* Notification channel ID
*/
private final String CHANNEL_ID = "MainNotifChannel";
/**
* Main notification ID
* Last notification count
*/
private final static int MAIN_NOTIFICATION_ID = 0;
private NotificationsCount mLastCount;
/**
* Public constructor
@ -105,6 +112,16 @@ public class NotificationsService extends IntentService {
if(count.getNotificationsCount() > 0 || count.getConversationsCount() > 0){
//Check notification count
if(mLastCount != null){
//Check if it is required to push a new notification
if(mLastCount.getNotificationsCount() != count.getNotificationsCount()
|| mLastCount.getConversationsCount() != count.getConversationsCount())
showNotification(count);
}
else
//Show notification
showNotification(count);
}
@ -116,6 +133,9 @@ public class NotificationsService extends IntentService {
}
//Save last notifications count
mLastCount = count;
}
Log.v(TAG, "Stop service");