Fix crash when getLayout() is null.

This commit is contained in:
Lucio Maciel 2021-08-13 18:39:06 -03:00 committed by GitHub
parent a5790edb2b
commit d4cabce876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -153,7 +153,7 @@ public class EmojiTextView extends AppCompatTextView {
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
CharSequence text = getText();
if (!measureLastLine || text == null || text.length() == 0) {
if (getLayout() == null || !measureLastLine || text == null || text.length() == 0) {
lastLineWidth = -1;
} else {
Layout layout = getLayout();
@ -175,7 +175,7 @@ public class EmojiTextView extends AppCompatTextView {
}
public boolean isSingleLine() {
return getLayout().getLineCount() == 1;
return getLayout() != null && getLayout().getLineCount() == 1;
}
public void setOverflowText(@Nullable CharSequence overflowText) {

View file

@ -387,7 +387,12 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
}
if (!updatingFooter && !isCaptionlessMms(messageRecord) && !isViewOnceMessage(messageRecord) && isFooterVisible(messageRecord, nextMessageRecord, groupThread)) {
if (!updatingFooter &&
!isCaptionlessMms(messageRecord) &&
!isViewOnceMessage(messageRecord) &&
isFooterVisible(messageRecord, nextMessageRecord, groupThread) &&
bodyText.getLastLineWidth() > 0)
{
int footerWidth = footer.getMeasuredWidth();
int availableWidth = getAvailableMessageBubbleWidth(bodyText);
if (bodyText.isSingleLine()) {