Merge "Move sticky cards to the bottom" into rvc-dev
This commit is contained in:
@@ -169,16 +169,23 @@ public class ContextualCardManager implements ContextualCardLoader.CardContentLo
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
List<ContextualCard> sortCards(List<ContextualCard> cards) {
|
List<ContextualCard> sortCards(List<ContextualCard> cards) {
|
||||||
//take mContextualCards as the source and do the ranking based on the rule.
|
// take mContextualCards as the source and do the ranking based on the rule.
|
||||||
return cards.stream()
|
final List<ContextualCard> result = cards.stream()
|
||||||
.sorted((c1, c2) -> Double.compare(c2.getRankingScore(), c1.getRankingScore()))
|
.sorted((c1, c2) -> Double.compare(c2.getRankingScore(), c1.getRankingScore()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
final List<ContextualCard> stickyCards = result.stream()
|
||||||
|
.filter(c -> c.getCategory() == STICKY_VALUE)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// make sticky cards be at the tail end.
|
||||||
|
result.removeAll(stickyCards);
|
||||||
|
result.addAll(stickyCards);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContextualCardUpdated(Map<Integer, List<ContextualCard>> updateList) {
|
public void onContextualCardUpdated(Map<Integer, List<ContextualCard>> updateList) {
|
||||||
final Set<Integer> cardTypes = updateList.keySet();
|
final Set<Integer> cardTypes = updateList.keySet();
|
||||||
//Remove the existing data that matches the certain cardType before inserting new data.
|
// Remove the existing data that matches the certain cardType before inserting new data.
|
||||||
List<ContextualCard> cardsToKeep;
|
List<ContextualCard> cardsToKeep;
|
||||||
|
|
||||||
// We are not sure how many card types will be in the database, so when the list coming
|
// We are not sure how many card types will be in the database, so when the list coming
|
||||||
|
Reference in New Issue
Block a user