FileDocCategorySizeDatePackage
NotificationViewList.javaAPI DocAndroid 1.5 API6604Wed May 06 22:42:00 BST 2009com.android.server.status

NotificationViewList

public class NotificationViewList extends Object

Fields Summary
private ArrayList
mOngoing
private ArrayList
mLatest
Constructors Summary
NotificationViewList()


     
    
Methods Summary
voidadd(StatusBarNotification notification)

        ArrayList<StatusBarNotification> list = notification.data.ongoingEvent ? mOngoing : mLatest;
        long when = notification.data.when;
        final int N = list.size();
        int index = N;
        for (int i=0; i<N; i++) {
            StatusBarNotification that = list.get(i);
            if (that.data.when > when) {
                index = i;
                break;
            }
        }
        list.add(index, notification);

        if (StatusBarService.SPEW) {
            String s = "";
            for (int i=0; i<mOngoing.size(); i++) {
                StatusBarNotification that = mOngoing.get(i);
                if (that.key == notification.key) {
                    s += "[";
                }
                s += that.data.when;
                if (that.key == notification.key) {
                    s += "]";
                }
                s += " ";
            }
            Log.d(StatusBarService.TAG, "NotificationViewList ongoing index=" + index + ": " + s);

            s = "";
            for (int i=0; i<mLatest.size(); i++) {
                StatusBarNotification that = mLatest.get(i);
                if (that.key == notification.key) {
                    s += "[";
                }
                s += that.data.when;
                if (that.key == notification.key) {
                    s += "]";
                }
                s += " ";
            }
            Log.d(StatusBarService.TAG, "NotificationViewList latest  index=" + index + ": " + s);
        }
    
voidclearViews()

        int N = mOngoing.size();
        for (int i=0; i<N; i++) {
            mOngoing.get(i).view = null;
        }
        N = mLatest.size();
        for (int i=0; i<N; i++) {
            mLatest.get(i).view = null;
        }
    
StatusBarNotificationget(android.view.View view)

        int N = mOngoing.size();
        for (int i=0; i<N; i++) {
            StatusBarNotification notification = mOngoing.get(i);
            View v = notification.view;
            if (v == view) {
                return notification;
            }
        }
        N = mLatest.size();
        for (int i=0; i<N; i++) {
            StatusBarNotification notification = mLatest.get(i);
            View v = notification.view;
            if (v == view) {
                return notification;
            }
        }
        return null;
    
StatusBarNotificationget(android.os.IBinder key)

        int index;
        index = indexForKey(mOngoing, key);
        if (index >= 0) {
            return mOngoing.get(index);
        }
        index = indexForKey(mLatest, key);
        if (index >= 0) {
            return mLatest.get(index);
        }
        return null;
    
intgetExpandedIndex(StatusBarNotification notification)

        ArrayList<StatusBarNotification> list = notification.data.ongoingEvent ? mOngoing : mLatest;
        return list.size() - indexForKey(list, notification.key) - 1;
    
intgetIconIndex(NotificationData n)

        final int ongoingSize = mOngoing.size();
        final int latestSize = mLatest.size();
        if (n.ongoingEvent) {
            int index = indexInList(mOngoing, n);
            if (index >= 0) {
                return latestSize + index + 1;
            } else {
                return -1;
            }
        } else {
            return indexInList(mLatest, n) + 1;
        }
    
StatusBarNotificationgetLatest(int index)

        return mLatest.get(index);
    
StatusBarNotificationgetOngoing(int index)

        return mOngoing.get(index);
    
booleanhasClearableItems()

        int N = mLatest.size();
        for (int i=0; i<N; i++) {
            if (mLatest.get(i).data.clearable) {
                return true;
            }
        }
        return false;
    
private static final intindexForKey(java.util.ArrayList list, android.os.IBinder key)

        final int N = list.size();
        for (int i=0; i<N; i++) {
            if (list.get(i).key == key) {
                return i;
            }
        }
        return -1;
    
private static final intindexInList(java.util.ArrayList list, NotificationData n)

        final int N = list.size();
        for (int i=0; i<N; i++) {
            StatusBarNotification that = list.get(i);
            if (that.data == n) {
                return i;
            }
        }
        return -1;
    
intlatestCount()

        return mLatest.size();
    
private final booleanmatchPackage(StatusBarNotification snb, java.lang.String packageName)

        if (snb.data.contentIntent != null) {
            if (snb.data.contentIntent.getTargetPackage().equals(packageName)) {
                return true;
            }
        } else if (snb.data.pkg != null && snb.data.pkg.equals(packageName)) {
            return true;
        }
        return false;
    
java.util.ArrayListnotificationsForPackage(java.lang.String packageName)

        ArrayList<StatusBarNotification> list = new ArrayList<StatusBarNotification>();
        int N = mOngoing.size();
        for (int i=0; i<N; i++) {
            if (matchPackage(mOngoing.get(i), packageName)) {
                list.add(mOngoing.get(i));
            }
        }
        N = mLatest.size();
        for (int i=0; i<N; i++) {
            if (matchPackage(mLatest.get(i), packageName)) {
                list.add(mLatest.get(i));
            }
        }
        return list;
    
intongoingCount()

        return mOngoing.size();
    
voidremove(StatusBarNotification notification)

        NotificationData n = notification.data;
        int index;
        index = indexInList(mOngoing, n);
        if (index >= 0) {
            mOngoing.remove(index);
            return;
        }
        index = indexInList(mLatest, n);
        if (index >= 0) {
            mLatest.remove(index);
            return;
        }
    
intsize()

        return mOngoing.size() + mLatest.size();
    
voidupdate(StatusBarNotification notification)

        remove(notification);
        add(notification);