Makes controls initially hidden

Also, there was a bug that controls are always shown at the beginning
even when controlview's hide() is called.

PiperOrigin-RevId: 323300617
This commit is contained in:
insun 2020-07-27 06:23:44 +01:00 committed by Oliver Woodman
parent 9743e47f1f
commit f99023e887
2 changed files with 12 additions and 3 deletions

View File

@ -54,9 +54,10 @@ import java.util.ArrayList;
private final OnLayoutChangeListener onLayoutChangeListener;
private int uxState = UX_STATE_ALL_VISIBLE;
private boolean initiallyHidden;
private boolean isMinimalMode;
private boolean needToShowBars;
private boolean animationEnabled = true;
private boolean animationEnabled;
@Nullable private StyledPlayerControlView styledPlayerControlView;
@ -86,9 +87,11 @@ import java.util.ArrayList;
hideMainBarsRunnable = this::hideMainBars;
hideControllerRunnable = this::hideController;
onLayoutChangeListener = this::onLayoutChange;
animationEnabled = true;
}
public void show() {
initiallyHidden = false;
if (this.styledPlayerControlView == null) {
return;
}
@ -102,6 +105,7 @@ import java.util.ArrayList;
}
public void hide() {
initiallyHidden = true;
if (styledPlayerControlView == null
|| uxState == UX_STATE_ANIMATING_HIDE
|| uxState == UX_STATE_NONE_VISIBLE) {
@ -156,6 +160,8 @@ import java.util.ArrayList;
public void onViewAttached(StyledPlayerControlView v) {
styledPlayerControlView = v;
v.setVisibility(initiallyHidden ? View.GONE : View.VISIBLE);
v.addOnLayoutChangeListener(onLayoutChangeListener);
// Relating to Title Bar View

View File

@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2.ui;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
@ -1320,9 +1322,10 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
}
int playbackState = player.getPlaybackState();
return controllerAutoShow
&& !player.getCurrentTimeline().isEmpty()
&& (playbackState == Player.STATE_IDLE
|| playbackState == Player.STATE_ENDED
|| !player.getPlayWhenReady());
|| !checkNotNull(player).getPlayWhenReady());
}
private void showController(boolean showIndefinitely) {
@ -1613,7 +1616,7 @@ public class StyledPlayerView extends FrameLayout implements AdsLoader.AdViewPro
// Suppress the update if transitioning to an unprepared period within the same window. This
// is necessary to avoid closing the shutter when such a transition occurs. See:
// https://github.com/google/ExoPlayer/issues/5507.
Player player = Assertions.checkNotNull(StyledPlayerView.this.player);
Player player = checkNotNull(StyledPlayerView.this.player);
Timeline timeline = player.getCurrentTimeline();
if (timeline.isEmpty()) {
lastPeriodUidWithTracks = null;