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