From cf31615891d50320fc8441b049bc87d5e147d29b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 14 Oct 2022 17:14:24 +0800 Subject: [PATCH] try fix NPE in ChatMessageCell --- .../java/org/telegram/ui/Cells/ChatMessageCell.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index ffab414f0..af04221d7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -12225,7 +12225,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (hasPsaHint) { int x; if (currentPosition == null || (currentPosition.flags & MessageObject.POSITION_FLAG_RIGHT) != 0) { - x = currentBackgroundDrawable.getBounds().right; + x = getCurrentBackgroundRight(); } else { x = 0; int dWidth = getGroupPhotosWidth(); @@ -15123,7 +15123,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate drawable.setAlpha(255); } if (docTitleOffsetX < 0 || docTitleOffsetX == 0 && docTitleLayout.getLineLeft(0) == 0) { - pollHintX = currentBackgroundDrawable.getBounds().right - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 17 : 11); + pollHintX = getCurrentBackgroundRight() - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 17 : 11); } else { pollHintX = getCurrentBackgroundLeft() + AndroidUtilities.dp(11); } @@ -15185,7 +15185,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } delegate.needReloadPolls(); } - int tx = currentBackgroundDrawable.getBounds().right - closeTimeWidth - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 40 : 34); + int tx = getCurrentBackgroundRight() - closeTimeWidth - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 40 : 34); if (time <= 5000) { Theme.chat_timePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outPollWrongAnswer : Theme.key_chat_inPollWrongAnswer)); } @@ -16724,6 +16724,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate return left; } + public int getCurrentBackgroundRight() { + return currentBackgroundDrawable == null ? 0 : currentBackgroundDrawable.getBounds().right; + } + public TransitionParams getTransitionParams() { return transitionParams; } @@ -16975,7 +16979,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate lastForwardedNamesOffset = namesOffset; lastForwardNameWidth = forwardedNameWidth; lastBackgroundLeft = getCurrentBackgroundLeft(); - lastBackgroundRight = currentBackgroundDrawable.getBounds().right; + lastBackgroundRight = getCurrentBackgroundRight(); reactionsLayoutInBubble.recordDrawingState(); if (replyNameLayout != null) {