Merge "Prevent crash when removing duplicates" into oc-dev

am: 7a148b9e09

Change-Id: I9ea047489b44bc538033343a6350a5abb8afef63
This commit is contained in:
Matthew Fritze
2017-06-01 21:24:36 +00:00
committed by android-build-merger
2 changed files with 44 additions and 3 deletions

View File

@@ -323,18 +323,18 @@ public class DatabaseResultLoader extends AsyncLoader<List<? extends SearchResul
for (int j = i - 1; j >= 0; j--) {
primaryResult = results.get(j);
if (areDuplicateResults(primaryResult, secondaryResult)) {
if (primaryResult.viewType != ResultPayload.PayloadType.INTENT) {
// Case where both payloads are inline
results.remove(i);
break;
} else if (secondaryResult.viewType != ResultPayload.PayloadType.INTENT) {
// Case where only second result is inline
// Case where only second result is inline.
results.remove(j);
i--; // shift the top index to reflect the lower element being removed
} else {
// Case where both payloads are intent
// Case where both payloads are intent.
results.remove(i);
break;
}
}
}