FileDocCategorySizeDatePackage
NotificationComparator.javaAPI DocAndroid 5.1 API1970Thu Mar 12 22:22:42 GMT 2015com.android.server.notification

NotificationComparator

public class NotificationComparator extends Object implements Comparator
Sorts notifications individually into attention-relelvant order.

Fields Summary
Constructors Summary
Methods Summary
public intcompare(NotificationRecord left, NotificationRecord right)

        final int leftPackagePriority = left.getPackagePriority();
        final int rightPackagePriority = right.getPackagePriority();
        if (leftPackagePriority != rightPackagePriority) {
            // by priority, high to low
            return -1 * Integer.compare(leftPackagePriority, rightPackagePriority);
        }

        final int leftScore = left.sbn.getScore();
        final int rightScore = right.sbn.getScore();
        if (leftScore != rightScore) {
            // by priority, high to low
            return -1 * Integer.compare(leftScore, rightScore);
        }

        final float leftPeople = left.getContactAffinity();
        final float rightPeople = right.getContactAffinity();
        if (leftPeople != rightPeople) {
            // by contact proximity, close to far
            return -1 * Float.compare(leftPeople, rightPeople);
        }

        // then break ties by time, most recent first
        return -1 * Long.compare(left.getRankingTimeMs(), right.getRankingTimeMs());