double check that activity is not null in updateSend button

This commit is contained in:
Daniel Gultsch 2019-05-22 17:30:04 +02:00
parent a909e1a7cf
commit 132f81df23
1 changed files with 2 additions and 2 deletions

View File

@ -2254,7 +2254,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
public void updateSendButton() { public void updateSendButton() {
boolean hasAttachments = mediaPreviewAdapter != null && mediaPreviewAdapter.hasAttachments(); boolean hasAttachments = mediaPreviewAdapter != null && mediaPreviewAdapter.hasAttachments();
boolean useSendButtonToIndicateStatus = PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("send_button_status", getResources().getBoolean(R.bool.send_button_status)); boolean useSendButtonToIndicateStatus = activity != null && PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("send_button_status", getResources().getBoolean(R.bool.send_button_status));
final Conversation c = this.conversation; final Conversation c = this.conversation;
final Presence.Status status; final Presence.Status status;
final String text = this.binding.textinput == null ? "" : this.binding.textinput.getText().toString(); final String text = this.binding.textinput == null ? "" : this.binding.textinput.getText().toString();
@ -2265,7 +2265,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
action = SendButtonTool.getAction(getActivity(), c, text); action = SendButtonTool.getAction(getActivity(), c, text);
} }
if (useSendButtonToIndicateStatus && c.getAccount().getStatus() == Account.State.ONLINE) { if (useSendButtonToIndicateStatus && c.getAccount().getStatus() == Account.State.ONLINE) {
if (activity.xmppConnectionService != null && activity.xmppConnectionService.getMessageArchiveService().isCatchingUp(c)) { if (activity != null && activity.xmppConnectionService != null && activity.xmppConnectionService.getMessageArchiveService().isCatchingUp(c)) {
status = Presence.Status.OFFLINE; status = Presence.Status.OFFLINE;
} else if (c.getMode() == Conversation.MODE_SINGLE) { } else if (c.getMode() == Conversation.MODE_SINGLE) {
status = c.getContact().getShownStatus(); status = c.getContact().getShownStatus();