ShortcutHelper: trim after skipping missing cards

This commit is contained in:
FC Stegerman
2023-07-11 19:18:41 +02:00
parent 95055f1ce6
commit eca9d1c74c

View File

@@ -70,15 +70,8 @@ class ShortcutHelper {
ShortcutInfoCompat found = list.remove(foundIndex.intValue());
list.addFirst(found);
} else {
// The item is new to the list. First, we need to trim the list
// until it is able to accept a new item, then the item is
// inserted.
while (list.size() >= MAX_SHORTCUTS) {
list.pollLast();
}
// The item is new to the list. We add it and trim the list later.
ShortcutInfoCompat shortcut = createShortcutBuilder(context, card).build();
list.addFirst(shortcut);
}
@@ -99,6 +92,11 @@ class ShortcutHelper {
finalList.addLast(updatedShortcut);
rank++;
// trim the list
if (rank >= MAX_SHORTCUTS) {
break;
}
}
}