Skip to content

Commit

Permalink
fix: NPE in ChatActivity ActionBarMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Feb 15, 2024
1 parent 1acd794 commit d299726
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16958,10 +16958,16 @@ private void addToSelectedMessages(MessageObject messageObject, boolean outside,
ActionBarMenuItem selectItem = actionBar.createActionMode().getItem(nkactionbarbtn_selectBetween);
ActionBarMenuItem combineMessageItem = actionBar.createActionMode().getItem(combine_message);

ActionBarMenuSubItem saveToDownloadsItem = actionModeOtherItem.getSubItem(save_to);
ActionBarMenuSubItem saveMessageItem = actionModeOtherItem.getSubItem(nkbtn_savemessage);
ActionBarMenuSubItem forwardNoQuoteItem = actionModeOtherItem.getSubItem(nkbtn_forward_noquote);
ActionBarMenuSubItem starItem = actionModeOtherItem.getSubItem(star);
ActionBarMenuSubItem saveToDownloadsItem = null;
ActionBarMenuSubItem saveMessageItem = null;
ActionBarMenuSubItem forwardNoQuoteItem = null;
ActionBarMenuSubItem starItem = null;
if (actionModeOtherItem != null) {
saveToDownloadsItem = actionModeOtherItem.getSubItem(save_to);
saveMessageItem = actionModeOtherItem.getSubItem(nkbtn_savemessage);
forwardNoQuoteItem = actionModeOtherItem.getSubItem(nkbtn_forward_noquote);
starItem = actionModeOtherItem.getSubItem(star);
}

boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || hasSelectedNoforwardsMessage();
boolean canForward = chatMode != MODE_SCHEDULED && cantForwardMessagesCount == 0 && !noforwards;
Expand Down Expand Up @@ -17249,7 +17255,9 @@ public void onAnimationCancel(Animator animation) {

if (translateItem != null)
translateItem.setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() > 0);
actionModeOtherItem.setSubItemVisibility(nkbtn_sharemessage, selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() > 0);
if (actionModeOtherItem != null) {
actionModeOtherItem.setSubItemVisibility(nkbtn_sharemessage, selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() > 0);
}

boolean allowPin = false;
if (currentChat != null) {
Expand All @@ -17267,7 +17275,9 @@ public void onAnimationCancel(Animator animation) {
}
}
}
actionModeOtherItem.setSubItemVisibility(nkbtn_unpin, allowPin);
if (actionModeOtherItem != null) {
actionModeOtherItem.setSubItemVisibility(nkbtn_unpin, allowPin);
}
}
}
updateSelectedMessageReactions();
Expand Down

0 comments on commit d299726

Please sign in to comment.