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;
* <li>Corresponding method: {@link #setShowShuffleButton(boolean)}
* <li>Default: false
* </ul>
* <li><b>{@code disable_animation}</b> - Whether animation is applied when hide and show
* controls.
* <li><b>{@code animation_enabled}</b> - Whether an animation is used to show and hide the
* playback controls.
* <ul>
* <li>Corresponding method: None
* <li>Default: false
* <li>Corresponding method: {@link #setAnimationEnabled(boolean)}
* <li>Default: true
* </ul>
* <li><b>{@code time_bar_min_update_interval}</b> - Specifies the minimum interval between time
* bar position updates.
......@@ -471,8 +471,7 @@ public class StyledPlayerControlView extends FrameLayout {
showNextButton = true;
showShuffleButton = false;
showSubtitleButton = false;
boolean disableAnimation = false;
boolean animationEnabled = true;
boolean showVrButton = false;
if (playbackAttrs != null) {
......@@ -512,15 +511,15 @@ public class StyledPlayerControlView extends FrameLayout {
a.getInt(
R.styleable.StyledPlayerControlView_time_bar_min_update_interval,
timeBarMinUpdateIntervalMs));
disableAnimation =
a.getBoolean(R.styleable.StyledPlayerControlView_disable_animation, disableAnimation);
animationEnabled =
a.getBoolean(R.styleable.StyledPlayerControlView_animation_enabled, animationEnabled);
} finally {
a.recycle();
}
}
controlViewLayoutManager = new StyledPlayerControlViewLayoutManager();
controlViewLayoutManager.setDisableAnimation(disableAnimation);
controlViewLayoutManager.setAnimationEnabled(animationEnabled);
visibilityListeners = new CopyOnWriteArrayList<>();
period = new Timeline.Period();
window = new Timeline.Window();
......@@ -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.
*
* <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;
private int uxState = UX_STATE_ALL_VISIBLE;
private boolean isMinimalMode;
private boolean needToShowBars;
private boolean disableAnimation = false;
private boolean animationEnabled = true;
@Nullable private StyledPlayerControlView styledPlayerControlView;
......@@ -93,7 +93,7 @@ import java.util.ArrayList;
return;
}
removeHideCallbacks();
if (isAnimationDisabled()) {
if (!animationEnabled) {
postDelayedRunnable(hideController, 0);
} else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) {
postDelayedRunnable(hideProgressBar, 0);
......@@ -102,8 +102,12 @@ import java.util.ArrayList;
}
}
void setDisableAnimation(boolean disableAnimation) {
this.disableAnimation = disableAnimation;
void setAnimationEnabled(boolean animationEnabled) {
this.animationEnabled = animationEnabled;
}
boolean isAnimationEnabled() {
return animationEnabled;
}
void resetHideCallbacks() {
......@@ -114,7 +118,7 @@ import java.util.ArrayList;
int showTimeoutMs =
styledPlayerControlView != null ? styledPlayerControlView.getShowTimeoutMs() : 0;
if (showTimeoutMs > 0) {
if (isAnimationDisabled()) {
if (!animationEnabled) {
postDelayedRunnable(hideController, showTimeoutMs);
} else if (uxState == UX_STATE_ONLY_PROGRESS_VISIBLE) {
postDelayedRunnable(hideProgressBar, ANIMATION_INTERVAL_MS);
......@@ -428,15 +432,11 @@ import java.util.ArrayList;
}
}
private boolean isAnimationDisabled() {
return disableAnimation;
}
private final Runnable showAllBars =
new Runnable() {
@Override
public void run() {
if (isAnimationDisabled()) {
if (!animationEnabled) {
setUxState(UX_STATE_ALL_VISIBLE);
resetHideCallbacks();
return;
......
......@@ -70,7 +70,7 @@
<attr name="show_vr_button" format="boolean"/>
<attr name="time_bar_min_update_interval" format="integer"/>
<attr name="controller_layout_id" format="reference"/>
<attr name="disable_animation" format="boolean"/>
<attr name="animation_enabled" format="boolean"/>
<!-- DefaultTimeBar attributes -->
<attr name="bar_height" format="dimension"/>
......@@ -151,7 +151,7 @@
<attr name="show_vr_button"/>
<attr name="time_bar_min_update_interval"/>
<attr name="controller_layout_id"/>
<attr name="disable_animation"/>
<attr name="animation_enabled"/>
<!-- DefaultTimeBar attributes -->
<attr name="bar_height"/>
<attr name="touch_target_height"/>
......@@ -214,7 +214,7 @@
<attr name="show_vr_button"/>
<attr name="time_bar_min_update_interval"/>
<attr name="controller_layout_id"/>
<attr name="disable_animation"/>
<attr name="animation_enabled"/>
<!-- DefaultTimeBar attributes -->
<attr name="bar_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