mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Display on navbar the number of friendship requests received by the user.
This commit is contained in:
parent
2cb7bf7eb2
commit
e9fff846f0
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -52,6 +52,7 @@ public class NotificationsHelper {
|
|||||||
//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);
|
||||||
|
|
||||||
//Try to perform the request and parse results
|
//Try to perform the request and parse results
|
||||||
try {
|
try {
|
||||||
@ -63,6 +64,8 @@ public class NotificationsHelper {
|
|||||||
NotificationsCount res = new NotificationsCount();
|
NotificationsCount res = new NotificationsCount();
|
||||||
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"));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -12,6 +12,7 @@ public class NotificationsCount {
|
|||||||
//Private fields
|
//Private fields
|
||||||
private int notificationsCount;
|
private int notificationsCount;
|
||||||
private int conversationsCount;
|
private int conversationsCount;
|
||||||
|
private int friendsRequestsCount;
|
||||||
|
|
||||||
|
|
||||||
//Set and get notifications count
|
//Set and get notifications count
|
||||||
@ -32,4 +33,13 @@ public class NotificationsCount {
|
|||||||
public int getConversationsCount() {
|
public int getConversationsCount() {
|
||||||
return conversationsCount;
|
return conversationsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Getter and setter for friends requests
|
||||||
|
public int getFriendsRequestsCount() {
|
||||||
|
return friendsRequestsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFriendsRequestsCount(int friendsRequestsCount) {
|
||||||
|
this.friendsRequestsCount = friendsRequestsCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,8 @@ public class NotificationsService extends IntentService {
|
|||||||
* Notification extras
|
* Notification extras
|
||||||
*/
|
*/
|
||||||
public static final String BROADCAST_EXTRA_NUMBER_NOTIFICATIONS = "NumberNotifications";
|
public static final String BROADCAST_EXTRA_NUMBER_NOTIFICATIONS = "NumberNotifications";
|
||||||
public static final String BROADCAST_EXTRACT_UNREAD_CONVERSATIONS = "UnreadConversations";
|
public static final String BROADCAST_EXTRA_UNREAD_CONVERSATIONS = "UnreadConversations";
|
||||||
|
public static final String BROADCAST_EXTRA_NUMBER_FRIENDSHIP_REQUESTS = "NumberFriendsRequests";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification channel ID
|
* Notification channel ID
|
||||||
@ -154,7 +155,8 @@ public class NotificationsService extends IntentService {
|
|||||||
//Create an intent and push nut data
|
//Create an intent and push nut data
|
||||||
Intent pushIntent = new Intent(BROADCAST_ACTION)
|
Intent pushIntent = new Intent(BROADCAST_ACTION)
|
||||||
.putExtra(BROADCAST_EXTRA_NUMBER_NOTIFICATIONS, count.getNotificationsCount())
|
.putExtra(BROADCAST_EXTRA_NUMBER_NOTIFICATIONS, count.getNotificationsCount())
|
||||||
.putExtra(BROADCAST_EXTRACT_UNREAD_CONVERSATIONS, count.getConversationsCount());
|
.putExtra(BROADCAST_EXTRA_UNREAD_CONVERSATIONS, count.getConversationsCount())
|
||||||
|
.putExtra(BROADCAST_EXTRA_NUMBER_FRIENDSHIP_REQUESTS, count.getFriendsRequestsCount());
|
||||||
|
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(pushIntent);
|
LocalBroadcastManager.getInstance(this).sendBroadcast(pushIntent);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,9 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
count.setNotificationsCount(intent.getExtras().getInt(
|
count.setNotificationsCount(intent.getExtras().getInt(
|
||||||
NotificationsService.BROADCAST_EXTRA_NUMBER_NOTIFICATIONS));
|
NotificationsService.BROADCAST_EXTRA_NUMBER_NOTIFICATIONS));
|
||||||
count.setConversationsCount(intent.getExtras().getInt(
|
count.setConversationsCount(intent.getExtras().getInt(
|
||||||
NotificationsService.BROADCAST_EXTRACT_UNREAD_CONVERSATIONS));
|
NotificationsService.BROADCAST_EXTRA_UNREAD_CONVERSATIONS));
|
||||||
|
count.setFriendsRequestsCount(intent.getExtras().getInt(
|
||||||
|
NotificationsService.BROADCAST_EXTRA_NUMBER_FRIENDSHIP_REQUESTS));
|
||||||
updateNumberNotifications(count);
|
updateNumberNotifications(count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,6 +347,9 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
mNavBar.getItemIdentifierView(R.id.action_conversations).setNumberNews(
|
mNavBar.getItemIdentifierView(R.id.action_conversations).setNumberNews(
|
||||||
count.getConversationsCount());
|
count.getConversationsCount());
|
||||||
|
|
||||||
|
mNavBar.getItemIdentifierView(R.id.action_friendslist).setNumberNews(
|
||||||
|
count.getFriendsRequestsCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user