Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
PierfrancescoSoffritti committed Sep 2, 2016
1 parent a08c39b commit b98b18b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class PlayerControlsWrapper implements View.OnClickListener, YouTubePlayerFullSc

@NonNull private final SeekBar seekBar;

private View.OnClickListener onFullScreenButtonListener;

// view state
private boolean isPlaying = false;
private boolean isVisible = true;
Expand Down Expand Up @@ -63,6 +65,10 @@ protected PlayerControlsWrapper(@NonNull YouTubePlayerView youTubePlayerView, @N
fullScreenButton.setOnClickListener(this);
}

public void setOnFullScreenButtonListener(View.OnClickListener onFullScreenButtonListener) {
this.onFullScreenButtonListener = onFullScreenButtonListener;
}

@Override
public void onClick(View view) {
if(view == panel)
Expand All @@ -74,7 +80,10 @@ else if(view == fullScreenButton)
}

private void onFullScreenPressed() {
youTubePlayerView.toggleFullScreen();
if(onFullScreenButtonListener == null)
youTubePlayerView.toggleFullScreen();
else
onFullScreenButtonListener.onClick(fullScreenButton);
}

private void onPlayButtonPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ private void adjustControlsSize() {
playerControls.setLayoutParams(params);
}

/**
* Set a custom behaviour to the full screen button.
*/
public void onFullScreenButtonListener(OnClickListener listener) {
playerControlsWrapper.setOnFullScreenButtonListener(listener);
}

public boolean isFullScreen() {
return isFullScreen;
}
Expand Down Expand Up @@ -204,7 +211,10 @@ public void release() {
}

youTubePlayer.destroy();
getContext().unregisterReceiver(networkReceiver);
try {
getContext().unregisterReceiver(networkReceiver);
} catch (Exception ignore) {
}
}

/**
Expand Down

0 comments on commit b98b18b

Please sign in to comment.