Add DiffCallback to handle Contextual Cards update.

Use DiffCallback in ContextualCardsAdapter to only update items that
are changed instead of touching those unchanged ones.

Also fix a bug where ConditionContexualCardCard#onStart is incorrectly
skipped.

Fixes: 112245748
Bug: 118165942
Test: robotests
Change-Id: I7989d621764fe40a3fceb8c9f40baced840818ba
This commit is contained in:
Emily Chuang
2018-10-16 18:49:29 +08:00
committed by Fan Zhang
parent 0a546d1916
commit 18a99faaf1
6 changed files with 80 additions and 17 deletions

View File

@@ -115,10 +115,6 @@ public class ContextualCardManager implements CardContentLoader.CardContentLoade
@Override
public void onContextualCardUpdated(Map<Integer, List<ContextualCard>> updateList) {
//TODO(b/112245748): Should implement a DiffCallback.
//Keep the old list for comparison.
final List<ContextualCard> prevCards = mContextualCards;
final Set<Integer> cardTypes = updateList.keySet();
//Remove the existing data that matches the certain cardType before inserting new data.
final List<ContextualCard> cardsToKeep = mContextualCards