Fixed a bug where the positioning on the lockscreen was wrong

Because of a circular dependancy of calculating the notification
heights and setting them to GONE, the views could be laid out in a
wrong fashion. Another issue was that ambient notifications would
still be taken into account as well as removed notifications.

This also lead to a bug where the removal of notifications could
lead to unnecessary add animations when swiping them away.

Change-Id: If9ad81237a520b14dc6851df3af52406d192a7a7
Fixes: 28441832
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 7e2fa2d..5256e4f6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -418,11 +418,18 @@
             if (!(child instanceof ExpandableNotificationRow)) {
                 continue;
             }
+            ExpandableNotificationRow row = (ExpandableNotificationRow) child;
             boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(
-                    ((ExpandableNotificationRow) child).getStatusBarNotification());
+                    row.getStatusBarNotification());
             if (suppressedSummary) {
                 continue;
             }
+            if (!mStatusBar.shouldShowOnKeyguard(row.getStatusBarNotification())) {
+                continue;
+            }
+            if (row.isRemoved()) {
+                continue;
+            }
             availableSpace -= child.getMinHeight() + notificationPadding;
             if (availableSpace >= 0 && count < maximum) {
                 count++;