Bug 921776 - Forced notifications to keep the same timestamp to preserve the order they are displayed in; fixed current notification mechanism in notification handler to update correctly the current foreground notification; r=wesj
This commit is contained in:
@@ -33,6 +33,7 @@ public class NotificationHandler {
|
||||
* one download is in progress.
|
||||
*/
|
||||
private Notification mForegroundNotification;
|
||||
private int mForegroundNotificationId;
|
||||
|
||||
public NotificationHandler(Context context) {
|
||||
mContext = context;
|
||||
@@ -168,23 +169,26 @@ public class NotificationHandler {
|
||||
}
|
||||
|
||||
protected void setForegroundNotification(int id, Notification notification) {
|
||||
mForegroundNotificationId = id;
|
||||
mForegroundNotification = notification;
|
||||
}
|
||||
|
||||
private void updateForegroundNotification(int id, Notification oldNotification) {
|
||||
if (mForegroundNotification == oldNotification) {
|
||||
private void updateForegroundNotification(int oldId, Notification oldNotification) {
|
||||
if (mForegroundNotificationId == oldId) {
|
||||
// If we're removing the notification associated with the
|
||||
// foreground, we need to pick another active notification to act
|
||||
// as the foreground notification.
|
||||
Notification foregroundNotification = null;
|
||||
for (final Notification notification : mNotifications.values()) {
|
||||
int foregroundId = 0;
|
||||
for (final Integer id : mNotifications.keySet()) {
|
||||
final Notification notification = mNotifications.get(id);
|
||||
if (isOngoing(notification)) {
|
||||
foregroundNotification = notification;
|
||||
foregroundId = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setForegroundNotification(id, foregroundNotification);
|
||||
setForegroundNotification(foregroundId, foregroundNotification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user