Skip to content

Commit

Permalink
UI fix: when casting, hide ViewGroup containing video player
Browse files Browse the repository at this point in the history
For some reason, only hiding the video player wasn't sufficient.
This minor tweak completely removes the black box above the playlist.
  • Loading branch information
warren-bank committed May 18, 2019
1 parent 52fb5ae commit c33d6f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.app.Dialog;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.google.android.exoplayer2.ui.PlaybackControlView;
import com.google.android.exoplayer2.ui.PlayerView;
Expand All @@ -19,7 +18,7 @@ final class FullScreenManager {
private PlayerView localPlayerView;
private Dialog mFullScreenDialog;
private ImageView mFullScreenIcon;
private FrameLayout mFullScreenButton;
private ViewGroup mFullScreenButton;

// static factory

Expand Down Expand Up @@ -82,25 +81,26 @@ public void onBackPressed() {
}

private void openFullscreenDialog() {
((ViewGroup) localPlayerView.getParent()).removeView(localPlayerView);
((ViewGroup) localPlayerView.getParent()).removeView(localPlayerView); // FrameLayout
mFullScreenDialog.addContentView(localPlayerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(videoActivity, R.drawable.ic_fullscreen_close));
isFullScreen = true;
mFullScreenDialog.show();
}

private void closeFullscreenDialog() {
((ViewGroup) localPlayerView.getParent()).removeView(localPlayerView);
((FrameLayout) videoActivity.findViewById(R.id.main_media_frame)).addView(localPlayerView);
((ViewGroup) localPlayerView.getParent()).removeView(localPlayerView); // Dialog
((ViewGroup) videoActivity.findViewById(R.id.main_media_frame)).addView(localPlayerView); // FrameLayout
isFullScreen = false;
mFullScreenDialog.dismiss();
mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(videoActivity, R.drawable.ic_fullscreen_open));
}

private void initFullscreenButton() {
PlaybackControlView controlView = localPlayerView.findViewById(R.id.exo_controller);
mFullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
mFullScreenButton = controlView.findViewById(R.id.exo_fullscreen_button);
PlaybackControlView controlView;
controlView = (PlaybackControlView) localPlayerView.findViewById(R.id.exo_controller);
mFullScreenIcon = (ImageView) controlView.findViewById(R.id.exo_fullscreen_icon);
mFullScreenButton = (ViewGroup) controlView.findViewById(R.id.exo_fullscreen_button); // FrameLayout
mFullScreenButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.annotation.Nullable;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory;
Expand Down Expand Up @@ -452,11 +453,11 @@ private void setCurrentPlayer(Player currentPlayer) {
// View management.
if (currentPlayer == exoPlayer) {
fullScreenManager.enable();
localPlayerView.setVisibility(View.VISIBLE);
((ViewGroup) localPlayerView.getParent()).setVisibility(View.VISIBLE); // FrameLayout
castControlView.hide();
} else /* currentPlayer == castPlayer */ {
fullScreenManager.disable();
localPlayerView.setVisibility(View.GONE);
((ViewGroup) localPlayerView.getParent()).setVisibility(View.GONE); // FrameLayout
castControlView.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.video_activity);

Toolbar toolbar = findViewById(R.id.toolbar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("");
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
Expand All @@ -76,12 +76,12 @@ public void onClick(View v) {
}
});

localPlayerView = findViewById(R.id.local_player_view);
localPlayerView = (PlayerView) findViewById(R.id.local_player_view);
localPlayerView.requestFocus();

castControlView = findViewById(R.id.cast_control_view);
castControlView = (PlayerControlView) findViewById(R.id.cast_control_view);

mediaQueueList = findViewById(R.id.sample_list);
mediaQueueList = (RecyclerView) findViewById(R.id.sample_list);
ItemTouchHelper helper = new ItemTouchHelper(new RecyclerViewCallback());
helper.attachToRecyclerView(mediaQueueList);
mediaQueueList.setLayoutManager(new LinearLayoutManager(this));
Expand Down
4 changes: 2 additions & 2 deletions constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = 004070016
releaseVersion = '004.07.00-16API'
releaseVersionCode = 004070116
releaseVersion = '004.07.01-16API'
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
Expand Down

0 comments on commit c33d6f6

Please sign in to comment.