Merge "ShadeListBuilder clarity refactors" into tm-qpr-dev
This commit is contained in:
@@ -90,6 +90,18 @@ data class ListAttachState private constructor(
|
|||||||
stableIndex = -1
|
stableIndex = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erases bookkeeping traces stored on an entry when it is removed from the notif list.
|
||||||
|
* This can happen if the entry is removed from a group that was broken up or if the entry was
|
||||||
|
* filtered out during any of the filtering steps.
|
||||||
|
*/
|
||||||
|
fun detach() {
|
||||||
|
parent = null
|
||||||
|
section = null
|
||||||
|
promoter = null
|
||||||
|
// stableIndex = -1 // TODO(b/241229236): Clear this once we fix the stability fragility
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun create(): ListAttachState {
|
fun create(): ListAttachState {
|
||||||
|
|||||||
@@ -958,9 +958,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
|
|||||||
* filtered out during any of the filtering steps.
|
* filtered out during any of the filtering steps.
|
||||||
*/
|
*/
|
||||||
private void annulAddition(ListEntry entry) {
|
private void annulAddition(ListEntry entry) {
|
||||||
entry.setParent(null);
|
entry.getAttachState().detach();
|
||||||
entry.getAttachState().setSection(null);
|
|
||||||
entry.getAttachState().setPromoter(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assignSections() {
|
private void assignSections() {
|
||||||
@@ -1198,9 +1196,9 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
|
|||||||
o2.getSectionIndex());
|
o2.getSectionIndex());
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
|
|
||||||
int index1 = canReorder(o1) ? -1 : o1.getPreviousAttachState().getStableIndex();
|
cmp = Integer.compare(
|
||||||
int index2 = canReorder(o2) ? -1 : o2.getPreviousAttachState().getStableIndex();
|
getStableOrderIndex(o1),
|
||||||
cmp = Integer.compare(index1, index2);
|
getStableOrderIndex(o2));
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
|
|
||||||
NotifComparator sectionComparator = getSectionComparator(o1, o2);
|
NotifComparator sectionComparator = getSectionComparator(o1, o2);
|
||||||
@@ -1214,31 +1212,32 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
|
|||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
final NotificationEntry rep1 = o1.getRepresentativeEntry();
|
cmp = Integer.compare(
|
||||||
final NotificationEntry rep2 = o2.getRepresentativeEntry();
|
o1.getRepresentativeEntry().getRanking().getRank(),
|
||||||
cmp = rep1.getRanking().getRank() - rep2.getRanking().getRank();
|
o2.getRepresentativeEntry().getRanking().getRank());
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
|
|
||||||
cmp = Long.compare(
|
cmp = -1 * Long.compare(
|
||||||
rep2.getSbn().getNotification().when,
|
o1.getRepresentativeEntry().getSbn().getNotification().when,
|
||||||
rep1.getSbn().getNotification().when);
|
o2.getRepresentativeEntry().getSbn().getNotification().when);
|
||||||
return cmp;
|
return cmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private final Comparator<NotificationEntry> mGroupChildrenComparator = (o1, o2) -> {
|
private final Comparator<NotificationEntry> mGroupChildrenComparator = (o1, o2) -> {
|
||||||
int index1 = canReorder(o1) ? -1 : o1.getPreviousAttachState().getStableIndex();
|
int cmp = Integer.compare(
|
||||||
int index2 = canReorder(o2) ? -1 : o2.getPreviousAttachState().getStableIndex();
|
getStableOrderIndex(o1),
|
||||||
int cmp = Integer.compare(index1, index2);
|
getStableOrderIndex(o2));
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
|
|
||||||
cmp = o1.getRepresentativeEntry().getRanking().getRank()
|
cmp = Integer.compare(
|
||||||
- o2.getRepresentativeEntry().getRanking().getRank();
|
o1.getRepresentativeEntry().getRanking().getRank(),
|
||||||
|
o2.getRepresentativeEntry().getRanking().getRank());
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
|
|
||||||
cmp = Long.compare(
|
cmp = -1 * Long.compare(
|
||||||
o2.getRepresentativeEntry().getSbn().getNotification().when,
|
o1.getRepresentativeEntry().getSbn().getNotification().when,
|
||||||
o1.getRepresentativeEntry().getSbn().getNotification().when);
|
o2.getRepresentativeEntry().getSbn().getNotification().when);
|
||||||
return cmp;
|
return cmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1248,8 +1247,16 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
|
|||||||
*/
|
*/
|
||||||
private boolean mForceReorderable = false;
|
private boolean mForceReorderable = false;
|
||||||
|
|
||||||
private boolean canReorder(ListEntry entry) {
|
private int getStableOrderIndex(ListEntry entry) {
|
||||||
return mForceReorderable || getStabilityManager().isEntryReorderingAllowed(entry);
|
if (mForceReorderable) {
|
||||||
|
// this is used to determine if the list is correctly sorted
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (getStabilityManager().isEntryReorderingAllowed(entry)) {
|
||||||
|
// let the stability manager constrain or allow reordering
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return entry.getPreviousAttachState().getStableIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean applyFilters(NotificationEntry entry, long now, List<NotifFilter> filters) {
|
private boolean applyFilters(NotificationEntry entry, long now, List<NotifFilter> filters) {
|
||||||
|
|||||||
Reference in New Issue
Block a user