Prevent some crashes

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-08-09 18:05:23 +02:00
parent e4af75a62b
commit 45e2bd505d

View file

@ -2082,21 +2082,29 @@ public class CallController extends BaseController {
case ESTABLISHED: case ESTABLISHED:
handler.postDelayed(() -> setCallState(CallStatus.CALLING_TIMEOUT), 45000); handler.postDelayed(() -> setCallState(CallStatus.CALLING_TIMEOUT), 45000);
handler.post(() -> { handler.post(() -> {
connectingTextView.setText(R.string.nc_calling); if (connectingView != null) {
if (connectingTextView.getVisibility() != View.VISIBLE) { connectingTextView.setText(R.string.nc_calling);
connectingView.setVisibility(View.VISIBLE); if (connectingTextView.getVisibility() != View.VISIBLE) {
connectingView.setVisibility(View.VISIBLE);
}
} }
if (progressBar.getVisibility() != View.VISIBLE) { if (progressBar != null) {
progressBar.setVisibility(View.VISIBLE); if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE);
}
} }
if (conversationView.getVisibility() != View.INVISIBLE) { if (conversationView != null) {
conversationView.setVisibility(View.INVISIBLE); if (conversationView.getVisibility() != View.INVISIBLE) {
conversationView.setVisibility(View.INVISIBLE);
}
} }
if (errorImageView.getVisibility() != View.GONE) { if (errorImageView != null) {
errorImageView.setVisibility(View.GONE); if (errorImageView.getVisibility() != View.GONE) {
errorImageView.setVisibility(View.GONE);
}
} }
}); });
break; break;
@ -2108,43 +2116,61 @@ public class CallController extends BaseController {
animateCallControls(false, 5000); animateCallControls(false, 5000);
} }
if (connectingView.getVisibility() != View.INVISIBLE) { if (connectingView != null) {
connectingView.setVisibility(View.INVISIBLE); if (connectingView.getVisibility() != View.INVISIBLE) {
connectingView.setVisibility(View.INVISIBLE);
}
} }
if (progressBar.getVisibility() != View.GONE) { if (progressBar != null) {
progressBar.setVisibility(View.GONE); if (progressBar.getVisibility() != View.GONE) {
progressBar.setVisibility(View.GONE);
}
} }
if (conversationView.getVisibility() != View.VISIBLE) { if (conversationView != null) {
conversationView.setVisibility(View.VISIBLE); if (conversationView.getVisibility() != View.VISIBLE) {
conversationView.setVisibility(View.VISIBLE);
}
} }
if (errorImageView.getVisibility() != View.GONE) { if (errorImageView != null) {
errorImageView.setVisibility(View.GONE); if (errorImageView.getVisibility() != View.GONE) {
errorImageView.setVisibility(View.GONE);
}
} }
}); });
break; break;
case OFFLINE: case OFFLINE:
handler.post(() -> { handler.post(() -> {
stopCallingSound(); stopCallingSound();
connectingTextView.setText(R.string.nc_offline);
if (connectingView.getVisibility() != View.VISIBLE) { if (connectingTextView != null) {
connectingView.setVisibility(View.VISIBLE); connectingTextView.setText(R.string.nc_offline);
if (connectingView.getVisibility() != View.VISIBLE) {
connectingView.setVisibility(View.VISIBLE);
}
} }
if (conversationView.getVisibility() != View.INVISIBLE) {
conversationView.setVisibility(View.INVISIBLE); if (conversationView != null) {
if (conversationView.getVisibility() != View.INVISIBLE) {
conversationView.setVisibility(View.INVISIBLE);
}
} }
if (progressBar.getVisibility() != View.GONE) { if (progressBar != null) {
progressBar.setVisibility(View.GONE); if (progressBar.getVisibility() != View.GONE) {
progressBar.setVisibility(View.GONE);
}
} }
errorImageView.setImageResource(R.drawable.ic_signal_wifi_off_white_24dp); if (errorImageView != null) {
if (errorImageView.getVisibility() != View.VISIBLE) { errorImageView.setImageResource(R.drawable.ic_signal_wifi_off_white_24dp);
errorImageView.setVisibility(View.VISIBLE); if (errorImageView.getVisibility() != View.VISIBLE) {
errorImageView.setVisibility(View.VISIBLE);
}
} }
}); });
break; break;