From b98b18b14bed15124bae3f1eb0db581037c0817a Mon Sep 17 00:00:00 2001 From: Pierfrancesco Soffritti Date: Fri, 2 Sep 2016 13:36:51 +0200 Subject: [PATCH] adjustments --- .../youtubeplayer/PlayerControlsWrapper.java | 11 ++++++++++- .../youtubeplayer/YouTubePlayerView.java | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/PlayerControlsWrapper.java b/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/PlayerControlsWrapper.java index f8004d39..c248e2d6 100644 --- a/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/PlayerControlsWrapper.java +++ b/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/PlayerControlsWrapper.java @@ -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; @@ -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) @@ -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() { diff --git a/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/YouTubePlayerView.java b/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/YouTubePlayerView.java index 9814938f..96c85153 100644 --- a/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/YouTubePlayerView.java +++ b/YouTubePlayer/src/main/java/com/pierfrancescosoffritti/youtubeplayer/YouTubePlayerView.java @@ -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; } @@ -204,7 +211,10 @@ public void release() { } youTubePlayer.destroy(); - getContext().unregisterReceiver(networkReceiver); + try { + getContext().unregisterReceiver(networkReceiver); + } catch (Exception ignore) { + } } /**