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,22 +2082,30 @@ 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(() -> {
if (connectingView != null) {
connectingTextView.setText(R.string.nc_calling); connectingTextView.setText(R.string.nc_calling);
if (connectingTextView.getVisibility() != View.VISIBLE) { if (connectingTextView.getVisibility() != View.VISIBLE) {
connectingView.setVisibility(View.VISIBLE); connectingView.setVisibility(View.VISIBLE);
} }
}
if (progressBar != null) {
if (progressBar.getVisibility() != View.VISIBLE) { if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
} }
}
if (conversationView != null) {
if (conversationView.getVisibility() != View.INVISIBLE) { if (conversationView.getVisibility() != View.INVISIBLE) {
conversationView.setVisibility(View.INVISIBLE); conversationView.setVisibility(View.INVISIBLE);
} }
}
if (errorImageView != null) {
if (errorImageView.getVisibility() != View.GONE) { if (errorImageView.getVisibility() != View.GONE) {
errorImageView.setVisibility(View.GONE); errorImageView.setVisibility(View.GONE);
} }
}
}); });
break; break;
case IN_CONVERSATION: case IN_CONVERSATION:
@ -2108,44 +2116,62 @@ public class CallController extends BaseController {
animateCallControls(false, 5000); animateCallControls(false, 5000);
} }
if (connectingView != null) {
if (connectingView.getVisibility() != View.INVISIBLE) { if (connectingView.getVisibility() != View.INVISIBLE) {
connectingView.setVisibility(View.INVISIBLE); connectingView.setVisibility(View.INVISIBLE);
} }
}
if (progressBar != null) {
if (progressBar.getVisibility() != View.GONE) { if (progressBar.getVisibility() != View.GONE) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
} }
}
if (conversationView != null) {
if (conversationView.getVisibility() != View.VISIBLE) { if (conversationView.getVisibility() != View.VISIBLE) {
conversationView.setVisibility(View.VISIBLE); conversationView.setVisibility(View.VISIBLE);
} }
}
if (errorImageView != null) {
if (errorImageView.getVisibility() != View.GONE) { if (errorImageView.getVisibility() != View.GONE) {
errorImageView.setVisibility(View.GONE); errorImageView.setVisibility(View.GONE);
} }
}
}); });
break; break;
case OFFLINE: case OFFLINE:
handler.post(() -> { handler.post(() -> {
stopCallingSound(); stopCallingSound();
if (connectingTextView != null) {
connectingTextView.setText(R.string.nc_offline); connectingTextView.setText(R.string.nc_offline);
if (connectingView.getVisibility() != View.VISIBLE) { if (connectingView.getVisibility() != View.VISIBLE) {
connectingView.setVisibility(View.VISIBLE); connectingView.setVisibility(View.VISIBLE);
} }
}
if (conversationView != null) {
if (conversationView.getVisibility() != View.INVISIBLE) { if (conversationView.getVisibility() != View.INVISIBLE) {
conversationView.setVisibility(View.INVISIBLE); conversationView.setVisibility(View.INVISIBLE);
} }
}
if (progressBar != null) {
if (progressBar.getVisibility() != View.GONE) { if (progressBar.getVisibility() != View.GONE) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
} }
}
if (errorImageView != null) {
errorImageView.setImageResource(R.drawable.ic_signal_wifi_off_white_24dp); errorImageView.setImageResource(R.drawable.ic_signal_wifi_off_white_24dp);
if (errorImageView.getVisibility() != View.VISIBLE) { if (errorImageView.getVisibility() != View.VISIBLE) {
errorImageView.setVisibility(View.VISIBLE); errorImageView.setVisibility(View.VISIBLE);
} }
}
}); });
break; break;
case LEAVING: case LEAVING: