public boolean imageUpdate(Image img,
int flags,
int x,
int y,
int newWidth,
int newHeight) {
if (image == null || image != img || getParent() == null) {
return false;
}
// Bail out if there was an error:
if ((flags & (ABORT|ERROR)) != 0) {
repaint(0);
synchronized(ImageView.this) {
if (image == img) {
// Be sure image hasn't changed since we don't
// initialy synchronize
image = null;
if ((state & WIDTH_FLAG) != WIDTH_FLAG) {
width = DEFAULT_WIDTH;
}
if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) {
height = DEFAULT_HEIGHT;
}
}
if ((state & LOADING_FLAG) == LOADING_FLAG) {
// No need to resize or repaint, still in the process
// of loading.
return false;
}
}
updateAltTextView();
safePreferenceChanged();
return false;
}
// Resize image if necessary:
short changed = 0;
if ((flags & ImageObserver.HEIGHT) != 0 && !getElement().
getAttributes().isDefined(HTML.Attribute.HEIGHT)) {
changed |= 1;
}
if ((flags & ImageObserver.WIDTH) != 0 && !getElement().
getAttributes().isDefined(HTML.Attribute.WIDTH)) {
changed |= 2;
}
synchronized(ImageView.this) {
if (image != img) {
return false;
}
if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) {
width = newWidth;
}
if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) {
height = newHeight;
}
if ((state & LOADING_FLAG) == LOADING_FLAG) {
// No need to resize or repaint, still in the process of
// loading.
return true;
}
}
if (changed != 0) {
// May need to resize myself, asynchronously:
safePreferenceChanged();
return true;
}
// Repaint when done or when new pixels arrive:
if ((flags & (FRAMEBITS|ALLBITS)) != 0) {
repaint(0);
}
else if ((flags & SOMEBITS) != 0 && sIsInc) {
repaint(sIncRate);
}
return ((flags & ALLBITS) == 0);
}
|