mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-10-31 09:34:47 +00:00 
			
		
		
		
	Get number of pending calls only if call system is available
This commit is contained in:
		| @@ -44,15 +44,18 @@ public class NotificationsHelper { | ||||
|     /** | ||||
|      * Get the notifications count | ||||
|      * | ||||
|      * @param include_calls Specify whether pending calls should be included or not in the count | ||||
|      * @return Notifications count / NULL in case of failure | ||||
|      */ | ||||
|     @Nullable | ||||
|     public NotificationsCount pullCount(){ | ||||
|     public NotificationsCount pullCount(boolean include_calls){ | ||||
|  | ||||
|         //Perform an API request | ||||
|         APIRequest params = new APIRequest(mContext, | ||||
|                 "notifications/count_all_news"); | ||||
|         params.addBoolean("friends_request", true); | ||||
|  | ||||
|         if(include_calls) | ||||
|             params.addBoolean("include_calls", true); | ||||
|  | ||||
|         //Try to perform the request and parse results | ||||
| @@ -66,6 +69,8 @@ public class NotificationsHelper { | ||||
|             res.setNotificationsCount(object.getInt("notifications")); | ||||
|             res.setConversationsCount(object.getInt("conversations")); | ||||
|             res.setFriendsRequestsCount(object.getInt("friends_request")); | ||||
|  | ||||
|             if(include_calls) | ||||
|                 res.setPendingCalls(object.getInt("calls")); | ||||
|  | ||||
|             return res; | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import android.util.Log; | ||||
|  | ||||
| import org.communiquons.android.comunic.client.R; | ||||
| import org.communiquons.android.comunic.client.data.helpers.AccountHelper; | ||||
| import org.communiquons.android.comunic.client.data.helpers.CallsHelper; | ||||
| import org.communiquons.android.comunic.client.data.models.NotificationsCount; | ||||
| import org.communiquons.android.comunic.client.data.helpers.NotificationsHelper; | ||||
| import org.communiquons.android.comunic.client.data.utils.PreferencesUtils; | ||||
| @@ -119,7 +120,7 @@ public class NotificationsService extends IntentService { | ||||
|             } | ||||
|  | ||||
|             //Pull the number of notifications | ||||
|             NotificationsCount count = mNotifHelper.pullCount(); | ||||
|             NotificationsCount count = mNotifHelper.pullCount(CallsHelper.IsCallSystemAvailable()); | ||||
|  | ||||
|             //Check for error | ||||
|             if(count == null){ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user