Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timob-11762: imageView should update images correctly #3689

Merged
merged 2 commits into from
Jan 11, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,10 @@ public void handleStop()
fireStop();
}

private void setImageSource(Object object)
private void setImageSource(Object object, boolean sameSource)
{
if (imageViewProxy.inTableView()) {
ArrayList<TiDrawableReference> currentSources = imageViewProxy.getImageSources();
if (currentSources != null) {
imageSources = currentSources;
return;
}
if (imageViewProxy.inTableView() && sameSource && imageSources != null) {
return;
}

imageSources = new ArrayList<TiDrawableReference>();
Expand Down Expand Up @@ -960,7 +956,7 @@ public void processProperties(KrollDict d)
}

if (d.containsKey(TiC.PROPERTY_IMAGES)) {
setImageSource(d.get(TiC.PROPERTY_IMAGES));
setImageSource(d.get(TiC.PROPERTY_IMAGES), false);
setImages();
}
if (d.containsKey(TiC.PROPERTY_CAN_SCALE)) {
Expand Down Expand Up @@ -1039,12 +1035,16 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else if (key.equals(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)) {
view.setEnableZoomControls(TiConvert.toBoolean(newValue));
} else if (key.equals(TiC.PROPERTY_IMAGE)) {
setImageSource(newValue);
if (oldValue.equals(newValue)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use "==" here instead of .equals(), because we are trying to check if two object reference variables refer to the exact same instance of an object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. equals() is more appropriate here, because we only care whether the value of the two objects are the same not the object itself.

setImageSource(newValue, true);
} else {
setImageSource(newValue, false);
}
firedLoad = false;
setImage(true);
} else if (key.equals(TiC.PROPERTY_IMAGES)) {
if (newValue instanceof Object[]) {
setImageSource(newValue);
setImageSource(newValue, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check if (oldValue==newValue) and then do the same thing as above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed.

setImages();
}
} else {
Expand Down