Prevent crash if call intent is null

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-05-16 08:16:20 +02:00
parent ec7aecef46
commit 6c5860ac97

View File

@ -91,6 +91,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.inject.Inject;
@ -566,10 +567,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
return true;
case R.id.conversation_video_call:
startActivity(getIntentForCall(false));
startActivity(Objects.requireNonNull(getIntentForCall(false)));
return true;
case R.id.conversation_voice_call:
startActivity(getIntentForCall(true));
startActivity(Objects.requireNonNull(getIntentForCall(true)));
return true;
default:
@ -578,19 +579,23 @@ public class ChatController extends BaseController implements MessagesListAdapte
}
private Intent getIntentForCall(boolean isVoiceOnlyCall) {
Bundle bundle = new Bundle();
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
if (currentCall != null && !TextUtils.isEmpty(currentCall.getSessionId())) {
Bundle bundle = new Bundle();
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
if (isVoiceOnlyCall) {
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
if (isVoiceOnlyCall) {
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
}
Intent callIntent = new Intent(getActivity(), CallActivity.class);
callIntent.putExtras(bundle);
return callIntent;
} else {
return null;
}
Intent callIntent = new Intent(getActivity(), CallActivity.class);
callIntent.putExtras(bundle);
return callIntent;
}