Refactor intent creation

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-04-30 14:01:36 +02:00
parent b721e68a1a
commit 719c81d4a6
2 changed files with 19 additions and 9 deletions

View File

@ -441,17 +441,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
return true;
case R.id.conversation_video_call:
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());
Intent callIntent = new Intent(getActivity(), CallActivity.class);
callIntent.putExtras(bundle);
startActivity(callIntent);
startActivity(getIntentForCall(false));
return true;
case R.id.conversation_voice_call:
startActivity(getIntentForCall(true));
return true;
default:
@ -459,6 +452,22 @@ 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 (isVoiceOnlyCall) {
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
}
Intent callIntent = new Intent(getActivity(), CallActivity.class);
callIntent.putExtras(bundle);
return callIntent;
}
@Override
public void onSelectionChanged(int count) {
//globalMenu.findItem(R.id.action_delete).setVisible(count > 0);

View File

@ -47,4 +47,5 @@ public class BundleKeys {
public static final String KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS";
public static final String KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME";
public static final String KEY_ROOM_PASSWORD = "KEY_ROOM_PASSWORD";
public static final String KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY";
}