title: How do I create a new fragment that opens a full screen video view from the previous fragment when maximized?
body: <p>I am working on an app where I am supposed to open a video view in landscape mode ,when the video is clicked in portrait mode. I plan to add a fragment to do that, but i want to preserve the states of everything in the previous view so the call is not interrupted. is there a way to do this?
  Here's my fragment code:</p>
  
  <pre><code>public class SecureRoomCallFragment extends BaseCallFragment {
  @BindView(R.id.callStatusContainer)
  ViewGroup callStatusContainer;
  @BindView(R.id.callNameText)
  TextView callNameText;
  @BindView(R.id.callParticipantCountText)
  TextView callParticipantCountText;
  @BindView(R.id.callDurationText)
  TextView callDurationText;
  @BindView(R.id.activeSpeakerContainer)
  ViewGroup activeSpeakerContainer;
  @BindView(R.id.activeSpeakerVideo)
  ViewGroup activeSpeakerVideo;
  @BindView(R.id.activeSpeakerImage)
  ImageView activeSpeakerImage;
  @BindView(R.id.activeSpeakerName)
  TextView activeSpeakerName;
  @BindView(R.id.callProgressContainer)
  ViewGroup callProgressContainer;
  @BindView(R.id.callProgressName)
  TextView callProgressName;
  @BindView(R.id.callProgressText)
  TextView callProgressText;
  @BindView(R.id.groupCallerList)
  RecyclerView groupCallerList;
  @BindView(R.id.callButtonContainerUnavailable)
  ViewGroup callButtonContainerUnavailable;
  @BindView(R.id.callButtonCancel)
  Button cancelButton;
  @BindView(R.id.callButtonRetry)
  Button retryButton;
  @BindView(R.id.full_screen_image)
  ImageView fullScreenImage;
  
  private GroupCallAdapter callerAdapter;
  private int totalNumberOfUsers = -1;
  private static final int MAX_NUM_USERS_ALLOW_IN_CALL = 10;
  private boolean isFullScreen = true;
  private boolean isScreenShareEnabled = false;
  private String screenshareuserID;
  private String participantuserID;
  public SecureRoomCallFragment(final int totalNumberOfUsers) {
  this.totalNumberOfUsers = (totalNumberOfUsers &lt; MAX_NUM_USERS_ALLOW_IN_CALL) ? totalNumberOfUsers : MAX_NUM_USERS_ALLOW_IN_CALL;
  }
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  final View layout = inflater.inflate(R.layout.fragment_call_room, container, false);
  ButterKnife.bind(this, layout);
  
  
  resetUI();
  callProgressName.setText(callHelper.getConvo().getName());
  callNameText.setText(callHelper.getConvo().getName());
  return layout;
  }
  
  
  @Override
  protected void onCallConnected() {
  if (!callHelper.getConvo().isPrivateChat()) {
  callProgressText.setText(getString(R.string.call_status_connected));
  callProgressContainer.setVisibility(View.INVISIBLE);
  groupCallerList.setVisibility(View.VISIBLE);
  callStatusContainer.setVisibility(View.VISIBLE);
  
  }
  }
  
  @Override
  protected void onCallCompleted() {
  DialogInterface.OnClickListener positiveClickListener = new DialogInterface.OnClickListener() {
  @Override
  public void onClick(DialogInterface dialog, int which) {
  callProgressText.setText(getString(R.string.call_status_completed));
  callProgressContainer.setVisibility(View.VISIBLE);
  groupCallerList.setVisibility(View.INVISIBLE);
  getActivity().finish();
  }
  };
  showAlert(getString(R.string.dialog_title_meeting_end), getString(R.string.dialog_message_meeting_end), getString(android.R.string.ok), positiveClickListener, true /* isModal */);
  }
  
  @Override
  protected void onUserJoined(@NonNull Participant participant, final int participantSize) {
  if (participant == null) {
  
  
  return;
  }
  
  
  participantuserID = participant.userId;
  
  if (callProgressContainer.getVisibility() == View.VISIBLE) {
  callProgressText.setText(getString(R.string.call_status_connected));
  callProgressContainer.setVisibility(View.INVISIBLE);
  groupCallerList.setVisibility(View.VISIBLE);
  callStatusContainer.setVisibility(View.VISIBLE);
  }
  
  final boolean isActiveParticipant = callHelper.isActiveParticipant(participant);
  
  if (isActiveParticipant) {
  final Caller activeCaller = callHelper.getActiveCaller();
  if (activeCaller != null) {
  final Participant activeParticipant = activeCaller.getParticipant();
  
  activeSpeakerVideo.removeAllViews();
  activeSpeakerVideo.addView(activeParticipant.videoPlayer.videoView, videoLayoutParams);
  
  activeSpeakerName.setText(activeCaller.getName());
  
  
  activeSpeakerName.setVisibility(View.VISIBLE);
  if (activeCaller.getImage() != null) {
  activeSpeakerImage.setImageBitmap(activeCaller.getImage());
  } else {
  activeSpeakerImage.setImageResource(R.drawable.call_default_profile);
  }
  activeSpeakerImage.setVisibility(View.INVISIBLE);
  activeSpeakerImage.setVisibility(View.VISIBLE);
  
  showActiveSpeakerVideo(!activeCaller.isVideoPaused());
  showControlButtons(true);
  }
  }
  
  callerAdapter.notifyDataSetChanged();
  callParticipantCountText.setText("( " +participantSize+" / "+totalNumberOfUsers+" )");
  
  super.onUserJoined(participant, participantSize);
  }
  
  @Override
  protected void onUserLeft(@NonNull Participant participant, final int participantSize) {
  if (participant == null) {
  return;
  }
  
  
  
  final boolean isActiveParticipant = callHelper.isActiveParticipant(participant);
  
  
  if (isActiveParticipant) {
  final Caller activeCaller = callHelper.getActiveCaller();
  if (activeCaller != null) {
  swapVideoView(activeCaller);
  } else {
  showActiveSpeakerVideo(false);
  activeSpeakerName.setVisibility(View.GONE);
  }
  } else {
  callerAdapter.notifyDataSetChanged();
  }
  callParticipantCountText.setText("( " +participantSize+" / "+totalNumberOfUsers+" )");
  }
  
  @Override
  protected void onUserVideoPaused(@NonNull Participant participant, boolean isVideoPaused) {
  if (participant == null) {
  return;
  }
  
  final boolean isActiveParticipant = callHelper.isActiveParticipant(participant);
  
  if (isActiveParticipant) {
  showActiveSpeakerVideo(!isVideoPaused);
  } else {
  callerAdapter.notifyDataSetChanged();
  }
  }
  
  @Override
  protected void onDurationTick(long duration, @NonNull String formattedString) {
  
  callDurationText.setText(formattedString);
  }
  
  @Override
  protected void onAVDEvent(@NonNull String avdUserID) {
  final Caller activeCaller = callHelper.getActiveCaller();
  
  if (activeCaller != null) {
  swapVideoView(activeCaller);
  
  }
  }
  
  @Override
  protected void onScreenShare(boolean inScreenShare, @NonNull String userID, @NonNull int width, @NonNull int height) {
  isScreenShareEnabled = inScreenShare;
  screenshareuserID = userID;
  
  if (inScreenShare) {
  fullscreenvideodisplay(userID, width, height);
  
  } else {
  regularvideodisplay(userID);
  
  }
  }
  
  private void toggleFullScreen() {
  if (isFullScreen) {
  regularvideodisplay(null);
  } else {
  fullscreenvideodisplay(null, -1, -1);
  }
  isFullScreen = !isFullScreen;
  }
  
  public void fullscreenvideodisplay(@NonNull String userID, @NonNull int width, @NonNull int height) {
  DisplayMetrics metrics = new DisplayMetrics();
  getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
  ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) activeSpeakerContainer.getLayoutParams();
  if(width &lt;= 0 || height &lt;=0) {
  width = metrics.widthPixels;
  height = metrics.heightPixels;
  }
  params.leftMargin = 0;
  params.topMargin = 300;
  activeSpeakerVideo.setEnabled(true);
  activeSpeakerContainer.setRotation(90);
  float scale ;
  if(height &gt; width ) {
  scale = (height * 1.0f) / (width * 1.0f);
  }else{
  scale = (width * 1.0f) / (height * 1.0f);
  }
  activeSpeakerContainer.setScaleX(scale);
  groupCallerList.setVisibility(View.INVISIBLE);
  
  }
  
  public void regularvideodisplay(@NonNull String userID) {
  DisplayMetrics metrics = new DisplayMetrics();
  getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
  ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) activeSpeakerContainer.getLayoutParams();
  
  params.width =  metrics.widthPixels;
  params.height = metrics.heightPixels;
  params.leftMargin = 0;
  params.topMargin = 0;
  activeSpeakerVideo.setEnabled(false);
  activeSpeakerContainer.setRotation(0);
  activeSpeakerContainer.setVisibility(View.VISIBLE);
  groupCallerList.setVisibility(View.VISIBLE);
  activeSpeakerContainer.setScaleX(1);
  activeSpeakerContainer.setScaleY(1);
  }
  
  @Override
  protected void refresh() {
  // Refresh activeCaller's avatar
  final Caller activeCaller = callHelper.getActiveCaller();
  if (activeCaller != null) {
  setActiveSpeakerAvator(activeCaller);
  }
  
  // Refresh other callers' avatars
  callerAdapter.notifyDataSetChanged();
  }
  
  private void setActiveSpeakerAvator(@NonNull final Caller activeCaller) {
  
  if (activeCaller.getImage() != null) {
  
  activeSpeakerImage.setImageBitmap(activeCaller.getImage());
  } else {
  
  activeSpeakerImage.setImageResource(R.drawable.call_default_profile);
  }
  }
  
  private void swapVideoView(@NonNull final Caller activeCaller) {
  
  if ((activeCaller == null) || (activeCaller.getParticipant() == null)) {
  return;
  }
  
  final Participant activeParticipant = activeCaller.getParticipant();
  
  if (activeSpeakerVideo.getChildCount() != 0) {
  
  activeSpeakerVideo.removeAllViews();
  }
  
  final VideoView videoView;
  if (activeParticipant.isMe) {
  
  videoView = activeParticipant.videoStreamer.videoView;
  } else {
  
  videoView = activeParticipant.videoPlayer.videoView;
  
  
  }
  if (videoView.getParent() != null) {
  Timber.tag(NPLCallFSM.NPLDebugTAG);
  
  ViewGroup parent = (ViewGroup) videoView.getParent();
  parent.removeView(videoView);
  }
  
  activeSpeakerVideo.addView(videoView, videoLayoutParams);
  activeSpeakerName.setText(activeCaller.getName());
  activeSpeakerName.setVisibility(View.VISIBLE);
  
  setActiveSpeakerAvator(activeCaller);
  
  activeSpeakerImage.setVisibility(View.INVISIBLE);
  activeSpeakerImage.setVisibility(View.VISIBLE);
  
  showActiveSpeakerVideo(!activeCaller.isVideoPaused());
  callerAdapter.notifyDataSetChanged();
  }
  
  @Override
  public void resetUI() {
  groupCallerList.setVisibility(View.INVISIBLE);
  callProgressText.setText(getString(R.string.call_status_connecting));
  callProgressContainer.setVisibility(View.VISIBLE);
  callButtonContainer.setVisibility(View.VISIBLE);
  callStatusContainer.setVisibility(View.GONE);
  callButtonContainerUnavailable.setVisibility(View.GONE);
  
  activeSpeakerName.setText(getString(R.string.empty_string));
  activeSpeakerName.setVisibility(View.GONE);
  activeSpeakerImage.setImageResource(R.drawable.call_default_profile);
  activeSpeakerImage.setVisibility(View.VISIBLE);
  activeSpeakerVideo.removeAllViews();
  activeSpeakerVideo.setVisibility(View.INVISIBLE);
  
  LinearLayoutManager manager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
  callerAdapter = new GroupCallAdapter(callHelper.getCallers());
  groupCallerList.setLayoutManager(manager);
  groupCallerList.setAdapter(callerAdapter);
  showControlButtons(false);
  onDurationTick(0, "00:00:00");
  }
  
  private void showActiveSpeakerVideo(boolean showVideo) {
  if (showVideo) {
  activeSpeakerImage.setVisibility(View.INVISIBLE);
  activeSpeakerVideo.setVisibility(View.VISIBLE);
  
  if(isScreenShareEnabled &amp;&amp; screenshareuserID.equals(participantuserID)) {
  fullScreenImage.setVisibility(View.VISIBLE);
  fullScreenImage.setOnClickListener(new View.OnClickListener() {
  
  @Override
  public void onClick(View v) {
  // do something when the button is clicked
  
  toggleFullScreen();
  }
  });
  }
  } else {
  activeSpeakerImage.setVisibility(View.VISIBLE);
  activeSpeakerVideo.setVisibility(View.INVISIBLE);
  
  fullScreenImage.setVisibility(View.GONE);
  regularvideodisplay(null);
  }
  }
  
  @Override
  protected void onCallUnavailable() {
  if (callHelper.getConvo().isPrivateChat()) {
  showActiveSpeakerVideo(false);
  //            callHelper.getSelfCaller().setVideoPaused(true);
  callStatusContainer.setVisibility(View.GONE);
  callProgressContainer.setVisibility(View.VISIBLE);
  callProgressText.setText(getString(R.string.call_status_unavailable));
  callButtonContainer.setVisibility(View.INVISIBLE);
  callButtonContainerUnavailable.setVisibility(View.VISIBLE);
  callerAdapter.notifyDataSetChanged();
  }
  }
  
  @OnClick(R.id.callButtonCancel)
  public void onCallButtonCancelPressed() {
  callHelper.onCancelButtonPressed(cancelButton);
  }
  
  @OnClick(R.id.callButtonRetry)
  public void onCallButtonRetryPressed() {
  callHelper.onRetryButtonPressed(retryButton);
  }
  
  }
  </code></pre>
  
  <p>Here's my layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  
  &lt;RelativeLayout
  android:id="@+id/activeSpeakerContainer"
  android:layout_width="0dp"
  android:layout_height="0dp"
  app:layout_constraintBottom_toTopOf="@+id/groupCallerList"
  app:layout_constraintDimensionRatio="1:1"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toTopOf="parent"&gt;
  
  &lt;ZoomLayout
  android:id="@+id/activeSpeakerVideo"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/black" /&gt;
  
  &lt;ImageView
  android:id="@+id/activeSpeakerImage"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="48dp"
  android:src="@drawable/call_default_profile" /&gt;
  
  &lt;ImageView
  android:id="@+id/beta_calling_watermark"
  android:layout_width="130dp"
  android:layout_height="28dp"
  android:layout_alignParentBottom="true"
  android:layout_alignParentLeft="true"
  android:layout_marginBottom="36dp"
  android:layout_marginLeft="16dp"
  android:src="@drawable/ic_beta_calling_watermark_blue" /&gt;
  
  &lt;ImageView
  android:id="@+id/full_screen_image"
  android:layout_width="28dp"
  android:layout_height="28dp"
  android:layout_alignParentTop="true"
  android:layout_marginTop="36dp"
  android:layout_alignParentLeft="true"
  android:layout_alignParentStart="true"
  android:layout_marginLeft="16dp"
  android:layout_marginStart="16dp"
  android:visibility="gone"
  android:src="@drawable/fullscreen_icon" /&gt;
  
  &lt;TextView
  android:id="@+id/activeSpeakerName"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:background="#AA555555"
  android:ellipsize="end"
  android:gravity="center_horizontal|bottom"
  android:lines="1"
  android:textSize="16sp"
  tools:text="" /&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
  android:id="@+id/callStatusContainer"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:background="#AA555555"
  android:padding="8dp"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toTopOf="parent"&gt;
  
  &lt;TextView
  android:id="@+id/callNameText"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:layout_alignParentStart="true"
  android:layout_alignParentTop="true"
  android:ellipsize="end"
  android:lines="1"
  android:textSize="14sp"
  tools:text="" /&gt;
  
  &lt;TextView
  android:id="@+id/callParticipantCountText"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentTop="true"
  android:layout_toEndOf="@+id/callNameText"
  android:layout_toRightOf="@+id/callNameText"
  android:ellipsize="end"
  android:lines="1"
  android:paddingLeft="18dp"
  android:paddingRight="18dp"
  android:textSize="14sp" /&gt;
  
  &lt;TextView
  android:id="@+id/callDurationText"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentTop="true"
  android:layout_marginLeft="8dp"
  android:layout_marginStart="8dp"
  android:layout_toEndOf="@id/callParticipantCountText"
  android:layout_toLeftOf="@+id/callButtonVideoRotate"
  android:layout_toRightOf="@id/callParticipantCountText"
  android:layout_toStartOf="@id/callButtonVideoRotate"
  android:lines="1"
  android:textSize="14sp"
  tools:text="03:16" /&gt;
  
  &lt;ImageButton
  android:id="@+id/callButtonVideoRotate"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignBottom="@+id/callDurationText"
  android:layout_alignParentEnd="true"
  android:layout_alignParentRight="true"
  android:layout_alignParentTop="true"
  android:background="@android:color/transparent"
  android:src="@drawable/ic_video_cam_switch" /&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;android.support.v7.widget.RecyclerView
  android:id="@+id/groupCallerList"
  android:layout_width="0dp"
  android:layout_height="0dp"
  android:visibility="invisible"
  app:layout_constraintBottom_toTopOf="@+id/callButtonContainer"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toBottomOf="@+id/activeSpeakerContainer"&gt;
  
  &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;RelativeLayout
  android:id="@+id/callProgressContainer"
  android:layout_width="0dp"
  android:layout_height="0dp"
  app:layout_constraintBottom_toBottomOf="@+id/groupCallerList"
  app:layout_constraintLeft_toLeftOf="@+id/groupCallerList"
  app:layout_constraintRight_toRightOf="@+id/groupCallerList"
  app:layout_constraintTop_toTopOf="@+id/groupCallerList"&gt;
  
  &lt;TextView
  android:id="@+id/callProgressName"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  android:layout_marginTop="8dp"
  android:gravity="center_horizontal"
  android:textSize="20sp"
  tools:text="Caller Name" /&gt;
  
  &lt;TextView
  android:id="@+id/callProgressText"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_below="@+id/callProgressName"
  android:layout_centerHorizontal="true"
  android:layout_marginTop="8dp"
  android:gravity="center_horizontal"
  android:text="@string/call_status_connecting"
  android:textSize="16sp" /&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;include
  android:id="@+id/callButtonContainer"
  layout="@layout/layout_call_button_bar_1_row"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toBottomOf="@+id/groupCallerList" /&gt;
  
  
  &lt;android.support.constraint.ConstraintLayout
  android:id="@+id/callButtonContainerUnavailable"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:visibility="gone"
  app:layout_constraintBottom_toBottomOf="@+id/callButtonContainer"
  app:layout_constraintLeft_toLeftOf="@+id/callButtonContainer"
  app:layout_constraintRight_toRightOf="@+id/callButtonContainer"
  app:layout_constraintTop_toTopOf="@+id/callButtonContainer"
  tools:visibility="visible"&gt;
  
  &lt;Button
  android:id="@+id/callButtonCancel"
  style="@style/CallButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:drawableTop="@drawable/btn_call_end"
  android:text="@string/dialog_button_cancel"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintLeft_toLeftOf="parent"
  app:layout_constraintRight_toLeftOf="@+id/callButtonRetry"
  app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;Button
  android:id="@+id/callButtonRetry"
  style="@style/CallButton"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:drawableTop="@drawable/btn_call_retry"
  android:text="@string/button_try_again"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintLeft_toRightOf="@+id/callButtonCancel"
  app:layout_constraintRight_toRightOf="parent"
  app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>Here's the adapter:</p>
  
  <pre><code>public class GroupCallAdapter extends RecyclerView.Adapter&lt;GroupCallAdapter.CallerViewHolder&gt; {
  
  private CopyOnWriteArrayList&lt;Caller&gt; callers;
  
  public GroupCallAdapter(@NonNull final CopyOnWriteArrayList&lt;Caller&gt; callers) {
  this.callers = callers;
  }
  
  @Override
  public CallerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  final View layout = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_caller, parent, false);
  final CallerViewHolder viewHolder = new CallerViewHolder(layout);
  return viewHolder;
  }
  
  @Override
  public void onBindViewHolder(CallerViewHolder holder, int position) {
  final Caller caller = callers.get(position);
  final Participant participant = caller.getParticipant();
  
  if (caller.getName() != null) {
  holder.callerName.setText(caller.getName());
  }
  
  if (caller.getImage() != null) {
  holder.callerImage.setImageBitmap(caller.getImage());
  } else {
  holder.callerImage.setImageResource(R.drawable.call_default_profile);
  }
  holder.callerImage.setVisibility(View.INVISIBLE);
  holder.callerImage.setVisibility(View.VISIBLE);
  
  final VideoView videoView;
  if (participant.isMe) {
  videoView = participant.videoStreamer.videoView;
  
  } else {
  videoView = participant.videoPlayer.videoView;
  
  }
  if (holder.callerVideo.getChildCount() != 0) {
  holder.callerVideo.removeAllViews();
  }
  if (videoView.getParent() != null) {
  ViewGroup parent = (ViewGroup) videoView.getParent();
  parent.removeView(videoView);
  }
  holder.callerVideo.addView(videoView, CallerViewHolder.videoLayoutParams);
  
  if (caller.isVideoPaused()) {
  holder.callerVideo.setVisibility(View.INVISIBLE);
  holder.callerImage.setVisibility(View.VISIBLE);
  } else {
  holder.callerVideo.setVisibility(View.VISIBLE);
  holder.callerImage.setVisibility(View.INVISIBLE);
  
  
  
  }
  }
  
  @Override
  public int getItemCount() {
  return callers.size();
  }
  
  public static final class CallerViewHolder extends RecyclerView.ViewHolder {
  
  @BindView(R.id.callerVideo)
  public ViewGroup callerVideo;
  @BindView(R.id.callerImage)
  public ImageView callerImage;
  @BindView(R.id.callerName)
  public TextView callerName;
  
  protected static PinchandZoomLayout.LayoutParams videoLayoutParams = new PinchandZoomLayout.LayoutParams(
  ViewGroup.LayoutParams.MATCH_PARENT,
  ViewGroup.LayoutParams.MATCH_PARENT
  
  );
  
  public CallerViewHolder(View itemView) {
  super(itemView);
  ButterKnife.bind(this, itemView);
  
  }
  
  }
  }
  </code></pre>
  
  <p>here's another layout for calls:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
  &lt;RelativeLayout
  android:id="@+id/callerContainer"
  android:layout_width="0dp"
  android:layout_height="0dp"
  app:layout_constraintDimensionRatio="1:1"
  app:layout_constraintTop_toTopOf="parent"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintLeft_toLeftOf="parent"&gt;
  
  &lt;ZoomLayout
  android:id="@+id/callerVideo"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/black" /&gt;
  
  &lt;ImageView
  android:id="@+id/callerImage"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:padding="16dp"
  android:src="@drawable/call_default_profile" /&gt;
  
  &lt;TextView
  android:id="@+id/callerName"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="#AA555555"
  android:gravity="center_horizontal|bottom"
  android:textSize="12sp"
  android:lines="1"
  android:ellipsize="end"
  tools:text=""
  android:layout_alignParentBottom="true" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>