MessagingImageMessage: Don't crash if measured after recycle

We're hoping to gut the recycling code in the messaging notification
code entirely (it's a lot of complexity for apparently little or no
performance gain), but in the meantime, mitigate a System UI crash.

Bug: 231025249
Test: none, I found no unit tests to start with
Change-Id: I3bcc14d102a87ed96ce37241d25eccf44ba2acb0
This commit is contained in:
Julia Tuttle
2022-05-24 13:07:29 -04:00
parent 2274df1efb
commit 2e12d55283

View File

@@ -226,6 +226,13 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mDrawable == null) {
Log.e(TAG, "onMeasure() after recycle()!");
setMeasuredDimension(0, 0);
return;
}
if (mIsIsolated) {
// When isolated we have a fixed size, let's use that sizing.
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec),