diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java index 973c50d311c3b..6bb5e8f2625aa 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java @@ -22,6 +22,7 @@ import android.view.View; import com.android.internal.statusbar.StatusBarNotification; +import java.util.Comparator; import java.util.ArrayList; /** @@ -43,30 +44,35 @@ public class NotificationData { } } private final ArrayList mEntries = new ArrayList(); + private final Comparator mEntryCmp = new Comparator() { + public int compare(Entry a, Entry b) { + return (int)(a.notification.notification.when - b.notification.notification.when); + } + }; public int size() { return mEntries.size(); } - public Entry getEntryAt(int index) { - return mEntries.get(index); - } - - public int findEntry(IBinder key) { - final int N = mEntries.size(); - for (int i=0; i 0) { + break; + } + } + mEntries.add(i, entry); + return i; } public int add(IBinder key, StatusBarNotification notification, View row, View content, @@ -82,36 +88,19 @@ public class NotificationData { } public Entry remove(IBinder key) { - final int N = mEntries.size(); - for (int i=0; i when) { - return i; - } - } - return N; + return e; } /** * Return whether there are any visible items (i.e. items without an error). */ public boolean hasVisibleItems() { - final int N = mEntries.size(); - for (int i=0; i " + notification + ") // TODO"); - NotificationData oldList = mHaps; - - int oldIndex = oldList.findEntry(key); - if (oldIndex < 0) { + + final NotificationData.Entry oldEntry = mHaps.findByKey(key); + if (oldEntry == null) { Slog.w(TAG, "updateNotification for unknown key: " + key); return; } - final NotificationData.Entry oldEntry = oldList.getEntryAt(oldIndex); final StatusBarNotification oldNotification = oldEntry.notification; final RemoteViews oldContentView = oldNotification.notification.contentView;