Skip to content

Commit 719a637

Browse files
committed
TextView content is reset to itself to force it to correctly resize using cached image
1 parent c8b1eaa commit 719a637

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/WPImageGetter.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,18 @@ public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate)
9292
return;
9393
}
9494

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

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

105-
// image is from cache? don't need to modify view height
106-
if (isImmediate) {
107-
AppLog.d(T.UTILS, "WPImageGetter isImmediate");
108-
return;
103+
// force textView to resize correctly if image isn't cached
104+
if (!isImmediate) {
105+
view.setText(view.getText());
109106
}
110-
111-
// invalidate the textView so the image redraws
112-
view.invalidate();
113-
114-
int newHeight = remote.getBounds().height();
115-
view.setHeight(view.getHeight() + newHeight - oldHeight);
116107
}
117108
});
118109

0 commit comments

Comments
 (0)