[go: nahoru, domu]

Skip to content

Commit

Permalink
TextView content is reset to itself to force it to correctly resize u…
Browse files Browse the repository at this point in the history
…sing cached image
  • Loading branch information
nbradbury committed Aug 26, 2014
1 parent 9da1cdc commit e38d62a
Showing 1 changed file with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,18 @@ public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate)
return;
}

final int oldHeight = remote.getBounds().height();
int maxWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (mMaxSize > 0 && (maxWidth > mMaxSize || maxWidth == 0)) {
maxWidth = mMaxSize;
AppLog.d(T.UTILS, "WPImageGetter setting maxWidth = mMaxSize");
}

Drawable drawable = new BitmapDrawable(view.getContext().getResources(), response.getBitmap());
remote.setRemoteDrawable(drawable, maxWidth);

// image is from cache? don't need to modify view height
if (isImmediate) {
AppLog.d(T.UTILS, "WPImageGetter isImmediate");
return;
// force textView to resize correctly if image isn't cached
if (!isImmediate) {
view.setText(view.getText());
}

// invalidate the textView so the image redraws
view.invalidate();

int newHeight = remote.getBounds().height();
view.setHeight(view.getHeight() + newHeight - oldHeight);
}
});

Expand Down

0 comments on commit e38d62a

Please sign in to comment.