Commit 50761482 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Fix answer in suggest async image loading in Android.

When images are loaded async, it was updating the existing
list of property models.  The property model for the list
was doing an equality check for the list.  Two separate list
instances with the same contents (in this case, the exact
same objects), then the equality check will pass.

To overcome this, we allow skipping the equality checks
for object properties.

BUG=898522

Change-Id: I60483d3365217b5da5d0a2cf052ac888bac1a522
Reviewed-on: https://chromium-review.googlesource.com/c/1345510Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609884}
parent ddb795b3
......@@ -55,7 +55,22 @@ public class PropertyModel extends PropertyObservable<PropertyKey> {
* @param <T> The type of the Object being tracked by the key.
*/
public final static class WritableObjectPropertyKey<T>
extends ReadableObjectPropertyKey<T> implements PropertyKey {}
extends ReadableObjectPropertyKey<T> implements PropertyKey {
private final boolean mSkipEquality;
/** Default constructor for a writable object property. */
public WritableObjectPropertyKey() {
this(false);
}
/**
* Constructs a new writable object property.
* @param skipEquality Whether the equality check should be bypassed for this key.
*/
public WritableObjectPropertyKey(boolean skipEquality) {
mSkipEquality = skipEquality;
}
}
private final Map<PropertyKey, ValueContainer> mData;
......@@ -177,7 +192,7 @@ public class PropertyModel extends PropertyObservable<PropertyKey> {
if (container == null) {
container = new ObjectContainer<T>();
mData.put(key, container);
} else if (ObjectsCompat.equals(container.value, value)) {
} else if (!key.mSkipEquality && ObjectsCompat.equals(container.value, value)) {
return;
}
......
......@@ -25,7 +25,7 @@ public class SuggestionListProperties {
/** The list of models controlling the state of the suggestion items. */
public static final WritableObjectPropertyKey<List<PropertyModel>> SUGGESTION_MODELS =
new WritableObjectPropertyKey<>();
new WritableObjectPropertyKey<>(true);
/** Whether the suggestion list should have a dark background. */
public static final WritableBooleanPropertyKey USE_DARK_BACKGROUND =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment