make ongoing call check null safe. fixes #3951
This commit is contained in:
parent
39229c34f6
commit
b4db2e5284
|
@ -182,7 +182,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
private Toast messageLoaderToast;
|
||||
private ConversationsActivity activity;
|
||||
private boolean reInitRequiredOnStart = true;
|
||||
private OnClickListener clickToMuc = new OnClickListener() {
|
||||
private final OnClickListener clickToMuc = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -192,14 +192,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
startActivity(intent);
|
||||
}
|
||||
};
|
||||
private OnClickListener leaveMuc = new OnClickListener() {
|
||||
private final OnClickListener leaveMuc = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activity.xmppConnectionService.archiveConversation(conversation);
|
||||
}
|
||||
};
|
||||
private OnClickListener joinMuc = new OnClickListener() {
|
||||
private final OnClickListener joinMuc = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -207,7 +207,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
};
|
||||
|
||||
private OnClickListener acceptJoin = new OnClickListener() {
|
||||
private final OnClickListener acceptJoin = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
conversation.setAttribute("accept_non_anonymous", true);
|
||||
|
@ -216,7 +216,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
};
|
||||
|
||||
private OnClickListener enterPassword = new OnClickListener() {
|
||||
private final OnClickListener enterPassword = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -231,7 +231,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
});
|
||||
}
|
||||
};
|
||||
private OnScrollListener mOnScrollListener = new OnScrollListener() {
|
||||
private final OnScrollListener mOnScrollListener = new OnScrollListener() {
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
@ -310,7 +310,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
};
|
||||
private EditMessage.OnCommitContentListener mEditorContentListener = new EditMessage.OnCommitContentListener() {
|
||||
private final EditMessage.OnCommitContentListener mEditorContentListener = new EditMessage.OnCommitContentListener() {
|
||||
@Override
|
||||
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts, String[] contentMimeTypes) {
|
||||
// try to get permission to read the image, if applicable
|
||||
|
@ -333,7 +333,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
};
|
||||
private Message selectedMessage;
|
||||
private OnClickListener mEnableAccountListener = new OnClickListener() {
|
||||
private final OnClickListener mEnableAccountListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Account account = conversation == null ? null : conversation.getAccount();
|
||||
|
@ -343,7 +343,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
};
|
||||
private OnClickListener mUnblockClickListener = new OnClickListener() {
|
||||
private final OnClickListener mUnblockClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
v.post(() -> v.setVisibility(View.INVISIBLE));
|
||||
|
@ -354,8 +354,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
};
|
||||
private OnClickListener mBlockClickListener = this::showBlockSubmenu;
|
||||
private OnClickListener mAddBackClickListener = new OnClickListener() {
|
||||
private final OnClickListener mBlockClickListener = this::showBlockSubmenu;
|
||||
private final OnClickListener mAddBackClickListener = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -366,8 +366,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
}
|
||||
};
|
||||
private View.OnLongClickListener mLongPressBlockListener = this::showBlockSubmenu;
|
||||
private OnClickListener mAllowPresenceSubscription = new OnClickListener() {
|
||||
private final View.OnLongClickListener mLongPressBlockListener = this::showBlockSubmenu;
|
||||
private final OnClickListener mAllowPresenceSubscription = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Contact contact = conversation == null ? null : conversation.getContact();
|
||||
|
@ -400,8 +400,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
updateSnackBar(conversation);
|
||||
}
|
||||
};
|
||||
private AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false);
|
||||
private OnEditorActionListener mEditorActionListener = (v, actionId, event) -> {
|
||||
private final AtomicBoolean mSendingPgpMessage = new AtomicBoolean(false);
|
||||
private final OnEditorActionListener mEditorActionListener = (v, actionId, event) -> {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEND) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null && imm.isFullscreenMode()) {
|
||||
|
@ -413,7 +413,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
return false;
|
||||
}
|
||||
};
|
||||
private OnClickListener mScrollButtonListener = new OnClickListener() {
|
||||
private final OnClickListener mScrollButtonListener = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -421,7 +421,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
setSelection(binding.messagesView.getCount() - 1, true);
|
||||
}
|
||||
};
|
||||
private OnClickListener mSendButtonListener = new OnClickListener() {
|
||||
private final OnClickListener mSendButtonListener = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -517,7 +517,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
|
||||
private static Conversation getConversation(Activity activity, @IdRes int res) {
|
||||
final Fragment fragment = activity.getFragmentManager().findFragmentById(res);
|
||||
if (fragment != null && fragment instanceof ConversationFragment) {
|
||||
if (fragment instanceof ConversationFragment) {
|
||||
return ((ConversationFragment) fragment).getConversation();
|
||||
} else {
|
||||
return null;
|
||||
|
@ -527,11 +527,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
public static ConversationFragment get(Activity activity) {
|
||||
FragmentManager fragmentManager = activity.getFragmentManager();
|
||||
Fragment fragment = fragmentManager.findFragmentById(R.id.main_fragment);
|
||||
if (fragment != null && fragment instanceof ConversationFragment) {
|
||||
if (fragment instanceof ConversationFragment) {
|
||||
return (ConversationFragment) fragment;
|
||||
} else {
|
||||
fragment = fragmentManager.findFragmentById(R.id.secondary_fragment);
|
||||
return fragment != null && fragment instanceof ConversationFragment ? (ConversationFragment) fragment : null;
|
||||
return fragment instanceof ConversationFragment ? (ConversationFragment) fragment : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,7 +986,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
menuCall.setVisible(false);
|
||||
menuOngoingCall.setVisible(false);
|
||||
} else {
|
||||
final Optional<OngoingRtpSession> ongoingRtpSession = activity.xmppConnectionService.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
||||
final XmppConnectionService service = activity.xmppConnectionService;
|
||||
final Optional<OngoingRtpSession> ongoingRtpSession = service == null ? Optional.absent() : service.getJingleConnectionManager().getOngoingRtpConnection(conversation.getContact());
|
||||
if (ongoingRtpSession.isPresent()) {
|
||||
menuOngoingCall.setVisible(true);
|
||||
menuCall.setVisible(false);
|
||||
|
@ -998,7 +999,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
menuContactDetails.setVisible(!this.conversation.withSelf());
|
||||
menuMucDetails.setVisible(false);
|
||||
final XmppConnectionService service = activity.xmppConnectionService;
|
||||
menuInviteContact.setVisible(service != null && service.findConferenceServer(conversation.getAccount()) != null);
|
||||
}
|
||||
if (conversation.isMuted()) {
|
||||
|
|
Loading…
Reference in New Issue