Commit 22802506 by insun Committed by Oliver Woodman

Minor changes regarding animation_enabled in StyledPlayerControlView.

- Removed unnecessary private method
- Revised document for animation_enabled attribute
- Added setAnimationEnabled/isAnimationEnabled in StyledPlayerControlView

PiperOrigin-RevId: 319054648
parent a3977b94
...@@ -127,11 +127,11 @@ import java.util.concurrent.CopyOnWriteArrayList; ...@@ -127,11 +127,11 @@ import java.util.concurrent.CopyOnWriteArrayList;
* <li>Corresponding method: {@link #setShowShuffleButton(boolean)} * <li>Corresponding method: {@link #setShowShuffleButton(boolean)}
* <li>Default: false * <li>Default: false
* </ul> * </ul>
* <li><b>{@code disable_animation}</b> - Whether animation is applied when hide and show * <li><b>{@code animation_enabled}</b> - Whether an animation is used to show and hide the
* controls. * playback controls.
* <ul> * <ul>
* <li>Corresponding method: None * <li>Corresponding method: {@link #setAnimationEnabled(boolean)}
* <li>Default: false * <li>Default: true
* </ul> * </ul>
* <li><b>{@code time_bar_min_update_interval}</b> - Specifies the minimum interval between time * <li><b>{@code time_bar_min_update_interval}</b> - Specifies the minimum interval between time
* bar position updates. * bar position updates.
...@@ -471,8 +471,7 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -471,8 +471,7 @@ public class StyledPlayerControlView extends FrameLayout {
showNextButton = true; showNextButton = true;
showShuffleButton = false; showShuffleButton = false;
showSubtitleButton = false; showSubtitleButton = false;
boolean disableAnimation = false; boolean animationEnabled = true;
boolean showVrButton = false; boolean showVrButton = false;
if (playbackAttrs != null) { if (playbackAttrs != null) {
...@@ -512,15 +511,15 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -512,15 +511,15 @@ public class StyledPlayerControlView extends FrameLayout {
a.getInt( a.getInt(
R.styleable.StyledPlayerControlView_time_bar_min_update_interval, R.styleable.StyledPlayerControlView_time_bar_min_update_interval,
timeBarMinUpdateIntervalMs)); timeBarMinUpdateIntervalMs));
disableAnimation = animationEnabled =
a.getBoolean(R.styleable.StyledPlayerControlView_disable_animation, disableAnimation); a.getBoolean(R.styleable.StyledPlayerControlView_animation_enabled, animationEnabled);
} finally { } finally {
a.recycle(); a.recycle();
} }
} }
controlViewLayoutManager = new StyledPlayerControlViewLayoutManager(); controlViewLayoutManager = new StyledPlayerControlViewLayoutManager();
controlViewLayoutManager.setDisableAnimation(disableAnimation); controlViewLayoutManager.setAnimationEnabled(animationEnabled);
visibilityListeners = new CopyOnWriteArrayList<>(); visibilityListeners = new CopyOnWriteArrayList<>();
period = new Timeline.Period(); period = new Timeline.Period();
window = new Timeline.Window(); window = new Timeline.Window();
...@@ -1032,6 +1031,20 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -1032,6 +1031,20 @@ public class StyledPlayerControlView extends FrameLayout {
} }
/** /**
* Sets whether an animation is used to show and hide the playback controls.
*
* @param animationEnabled Whether an animation is applied to show and hide playback controls.
*/
public void setAnimationEnabled(boolean animationEnabled) {
controlViewLayoutManager.setAnimationEnabled(animationEnabled);
}
/** Returns whether an animation is used to show and hide the playback controls. */
public boolean isAnimationEnabled() {
return controlViewLayoutManager.isAnimationEnabled();
}
/**
* Sets the minimum interval between time bar position updates. * Sets the minimum interval between time bar position updates.
* *
* <p>Note that smaller intervals, e.g. 33ms, will result in a smooth movement but will use more * <p>Note that smaller intervals, e.g. 33ms, will result in a smooth movement but will use more
......
...@@ -50,7 +50,7 @@ import java.util.ArrayList; ...@@ -50,7 +50,7 @@ import java.util.ArrayList;
private int uxState = UX_STATE_ALL_VISIBLE; private int uxState = UX_STATE_ALL_VISIBLE;
private boolean isMinimalMode; private boolean isMinimalMode;
private boolean needToShowBars; private boolean needToShowBars;
private boolean disableAnimation = false; private boolean animationEnabled = true;
@Nullable private StyledPlayerControlView styledPlayerControlView; @Nullable private StyledPlayerControlView styledPlayerControlView;
...@@ -93,7 +93,7 @@ import java.util.ArrayList; ...@@ -93,7 +93,7 @@ import java.util.ArrayList;
return; return;
} }
removeHideCallbacks(); removeHideCallbacks();
if (isAnimationDisabled()) { if (!animationEnabled) {
postDelayedRunnable(hideController, 0); postDelayedRunnable(hideController, 0);
} else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) { } else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) {
postDelayedRunnable(hideProgressBar, 0); postDelayedRunnable(hideProgressBar, 0);
...@@ -102,8 +102,12 @@ import java.util.ArrayList; ...@@ -102,8 +102,12 @@ import java.util.ArrayList;
} }
} }
void setDisableAnimation(boolean disableAnimation) { void setAnimationEnabled(boolean animationEnabled) {
this.disableAnimation = disableAnimation; this.animationEnabled = animationEnabled;
}
boolean isAnimationEnabled() {
return animationEnabled;
} }
void resetHideCallbacks() { void resetHideCallbacks() {
...@@ -114,7 +118,7 @@ import java.util.ArrayList; ...@@ -114,7 +118,7 @@ import java.util.ArrayList;
int showTimeoutMs = int showTimeoutMs =
styledPlayerControlView != null ? styledPlayerControlView.getShowTimeoutMs() : 0; styledPlayerControlView != null ? styledPlayerControlView.getShowTimeoutMs() : 0;
if (showTimeoutMs > 0) { if (showTimeoutMs > 0) {
if (isAnimationDisabled()) { if (!animationEnabled) {
postDelayedRunnable(hideController, showTimeoutMs); postDelayedRunnable(hideController, showTimeoutMs);
} else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) { } else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) {
postDelayedRunnable(hideProgressBar, ANIMATION_INTERVAL_MS); postDelayedRunnable(hideProgressBar, ANIMATION_INTERVAL_MS);
...@@ -428,15 +432,11 @@ import java.util.ArrayList; ...@@ -428,15 +432,11 @@ import java.util.ArrayList;
} }
} }
private boolean isAnimationDisabled() {
return disableAnimation;
}
private final Runnable showAllBars = private final Runnable showAllBars =
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
if (isAnimationDisabled()) { if (!animationEnabled) {
setUxState(UX_STATE_ALL_VISIBLE); setUxState(UX_STATE_ALL_VISIBLE);
resetHideCallbacks(); resetHideCallbacks();
return; return;
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<attr name="show_vr_button" format="boolean"/> <attr name="show_vr_button" format="boolean"/>
<attr name="time_bar_min_update_interval" format="integer"/> <attr name="time_bar_min_update_interval" format="integer"/>
<attr name="controller_layout_id" format="reference"/> <attr name="controller_layout_id" format="reference"/>
<attr name="disable_animation" format="boolean"/> <attr name="animation_enabled" format="boolean"/>
<!-- DefaultTimeBar attributes --> <!-- DefaultTimeBar attributes -->
<attr name="bar_height" format="dimension"/> <attr name="bar_height" format="dimension"/>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<attr name="show_vr_button"/> <attr name="show_vr_button"/>
<attr name="time_bar_min_update_interval"/> <attr name="time_bar_min_update_interval"/>
<attr name="controller_layout_id"/> <attr name="controller_layout_id"/>
<attr name="disable_animation"/> <attr name="animation_enabled"/>
<!-- DefaultTimeBar attributes --> <!-- DefaultTimeBar attributes -->
<attr name="bar_height"/> <attr name="bar_height"/>
<attr name="touch_target_height"/> <attr name="touch_target_height"/>
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
<attr name="show_vr_button"/> <attr name="show_vr_button"/>
<attr name="time_bar_min_update_interval"/> <attr name="time_bar_min_update_interval"/>
<attr name="controller_layout_id"/> <attr name="controller_layout_id"/>
<attr name="disable_animation"/> <attr name="animation_enabled"/>
<!-- DefaultTimeBar attributes --> <!-- DefaultTimeBar attributes -->
<attr name="bar_height"/> <attr name="bar_height"/>
<attr name="touch_target_height"/> <attr name="touch_target_height"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment