Commit bcec5970 by olly Committed by Oliver Woodman

No-op cleanup for playback controls

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132859943
parent 8190089b
...@@ -44,9 +44,9 @@ public class PlaybackControlView extends FrameLayout { ...@@ -44,9 +44,9 @@ public class PlaybackControlView extends FrameLayout {
*/ */
public interface VisibilityListener { public interface VisibilityListener {
/** /**
* Called after the visibility changed. * Called when the visibility changes.
* *
* @param visibility The visibility value of the UI control after having changed. * @param visibility The new visibility. Either {@link View#VISIBLE} or {@link View#GONE}.
*/ */
void onVisibilityChange(int visibility); void onVisibilityChange(int visibility);
} }
...@@ -54,9 +54,8 @@ public class PlaybackControlView extends FrameLayout { ...@@ -54,9 +54,8 @@ public class PlaybackControlView extends FrameLayout {
public static final int DEFAULT_FAST_FORWARD_MS = 15000; public static final int DEFAULT_FAST_FORWARD_MS = 15000;
public static final int DEFAULT_REWIND_MS = 5000; public static final int DEFAULT_REWIND_MS = 5000;
public static final int DEFAULT_SHOW_DURATION_MS = 5000; public static final int DEFAULT_SHOW_DURATION_MS = 5000;
private static final long MAX_POSITION_FOR_SEEK_TO_PREVIOUS = 3000;
private ExoPlayer player; private static final long MAX_POSITION_FOR_SEEK_TO_PREVIOUS = 3000;
private final ComponentListener componentListener; private final ComponentListener componentListener;
private final View previousButton; private final View previousButton;
...@@ -67,16 +66,18 @@ public class PlaybackControlView extends FrameLayout { ...@@ -67,16 +66,18 @@ public class PlaybackControlView extends FrameLayout {
private final SeekBar progressBar; private final SeekBar progressBar;
private final View fastForwardButton; private final View fastForwardButton;
private final View rewindButton; private final View rewindButton;
private VisibilityListener visibilityListener;
private final StringBuilder formatBuilder; private final StringBuilder formatBuilder;
private final Formatter formatter; private final Formatter formatter;
private final Timeline.Window currentWindow;
private ExoPlayer player;
private VisibilityListener visibilityListener;
private final Timeline.Window currentWindow = new Timeline.Window();
private boolean dragging; private boolean dragging;
private boolean isProgressUpdating; private boolean isProgressUpdating;
private int rewindMs = DEFAULT_REWIND_MS; private int rewindMs = DEFAULT_REWIND_MS;
private int fastForwardMs = DEFAULT_FAST_FORWARD_MS; private int fastForwardMs = DEFAULT_FAST_FORWARD_MS;
private int showDuration = DEFAULT_SHOW_DURATION_MS; private int showDurationMs = DEFAULT_SHOW_DURATION_MS;
private final Runnable updateProgressAction = new Runnable() { private final Runnable updateProgressAction = new Runnable() {
@Override @Override
...@@ -104,6 +105,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -104,6 +105,7 @@ public class PlaybackControlView extends FrameLayout {
public PlaybackControlView(Context context, AttributeSet attrs) { public PlaybackControlView(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
currentWindow = new Timeline.Window();
formatBuilder = new StringBuilder(); formatBuilder = new StringBuilder();
formatter = new Formatter(formatBuilder, Locale.getDefault()); formatter = new Formatter(formatBuilder, Locale.getDefault());
componentListener = new ComponentListener(); componentListener = new ComponentListener();
...@@ -147,7 +149,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -147,7 +149,7 @@ public class PlaybackControlView extends FrameLayout {
/** /**
* Set the {@link VisibilityListener}. * Sets the {@link VisibilityListener}.
* *
* @param listener The listener to be notified about visibility changes. * @param listener The listener to be notified about visibility changes.
*/ */
...@@ -156,47 +158,47 @@ public class PlaybackControlView extends FrameLayout { ...@@ -156,47 +158,47 @@ public class PlaybackControlView extends FrameLayout {
} }
/** /**
* Set the duration to rewind in milliseconds. * Sets the rewind increment in milliseconds.
* *
* @param rewindMs Duration to rewind in milliseconds. * @param rewindMs The rewind increment in milliseconds.
*/ */
public void setRewindMs(int rewindMs) { public void setRewindIncrementMs(int rewindMs) {
this.rewindMs = rewindMs; this.rewindMs = rewindMs;
} }
/** /**
* Set the duration to fast forward in milliseconds. * Sets the fast forward increment in milliseconds.
* *
* @param fastForwardMs Duration to fast forward in milliseconds. * @param fastForwardMs The fast forward increment in milliseconds.
*/ */
public void setFastForwardMs(int fastForwardMs) { public void setFastForwardIncrementMs(int fastForwardMs) {
this.fastForwardMs = fastForwardMs; this.fastForwardMs = fastForwardMs;
} }
/** /**
* Set the duration to show the playback control in milliseconds. * Sets the duration to show the playback control in milliseconds.
* *
* @param showDuration Duration in milliseconds. * @param showDurationMs The duration in milliseconds.
*/ */
public void setShowDuration(int showDuration) { public void setShowDurationMs(int showDurationMs) {
this.showDuration = showDuration; this.showDurationMs = showDurationMs;
} }
/** /**
* Show the controller for the duration set by {@link #setShowDuration(int)} or * Shows the controller for the duration last passed to {@link #setShowDurationMs(int)}, or for
* for {@link #DEFAULT_SHOW_DURATION_MS} in milliseconds if not yet set. * {@link #DEFAULT_SHOW_DURATION_MS} if {@link #setShowDurationMs(int)} has not been called.
*/ */
public void show() { public void show() {
show(showDuration); show(showDurationMs);
} }
/** /**
* Show the controller for the given {@code duration} in milliseconds. If {@code duration} is 0 * Shows the controller for the {@code durationMs}. If {@code durationMs} is 0 the controller is
* the controller is shown until {@code hide()} is called. * shown until {@link #hide()} is called.
* *
* @param duration number of milliseconds the controller is shown. * @param durationMs The duration in milliseconds.
*/ */
public void show(int duration) { public void show(int durationMs) {
setVisibility(VISIBLE); setVisibility(VISIBLE);
if (visibilityListener != null) { if (visibilityListener != null) {
visibilityListener.onVisibilityChange(getVisibility()); visibilityListener.onVisibilityChange(getVisibility());
...@@ -204,14 +206,14 @@ public class PlaybackControlView extends FrameLayout { ...@@ -204,14 +206,14 @@ public class PlaybackControlView extends FrameLayout {
isProgressUpdating = true; isProgressUpdating = true;
post(updateProgressAction); post(updateProgressAction);
removeCallbacks(hideAction); removeCallbacks(hideAction);
showDuration = duration; showDurationMs = durationMs;
if (duration > 0) { if (durationMs > 0) {
postDelayed(hideAction, duration); postDelayed(hideAction, durationMs);
} }
} }
/** /**
* Hide the controller. * Hides the controller.
*/ */
public void hide() { public void hide() {
setVisibility(GONE); setVisibility(GONE);
...@@ -223,9 +225,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -223,9 +225,7 @@ public class PlaybackControlView extends FrameLayout {
} }
/** /**
* Returns {@code true} if the controller is currently visible or {@code false} otherwise. * Returns whether the controller is currently visible.
*
* @return {@code true} if shown or {@code false}.
*/ */
public boolean isVisible() { public boolean isVisible() {
return getVisibility() == VISIBLE; return getVisibility() == VISIBLE;
...@@ -233,8 +233,8 @@ public class PlaybackControlView extends FrameLayout { ...@@ -233,8 +233,8 @@ public class PlaybackControlView extends FrameLayout {
private void hideDeferred() { private void hideDeferred() {
removeCallbacks(hideAction); removeCallbacks(hideAction);
if (showDuration != 0) { if (showDurationMs != 0) {
postDelayed(hideAction, showDuration); postDelayed(hideAction, showDurationMs);
} }
} }
...@@ -395,6 +395,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -395,6 +395,7 @@ public class PlaybackControlView extends FrameLayout {
private final class ComponentListener implements ExoPlayer.EventListener, private final class ComponentListener implements ExoPlayer.EventListener,
SeekBar.OnSeekBarChangeListener, OnClickListener { SeekBar.OnSeekBarChangeListener, OnClickListener {
@Override @Override
public void onStartTrackingTouch(SeekBar seekBar) { public void onStartTrackingTouch(SeekBar seekBar) {
removeCallbacks(hideAction); removeCallbacks(hideAction);
...@@ -432,13 +433,19 @@ public class PlaybackControlView extends FrameLayout { ...@@ -432,13 +433,19 @@ public class PlaybackControlView extends FrameLayout {
} }
@Override @Override
public void onTimelineChanged(Timeline timeline, Object manifest) { /* do nothing. */ } public void onTimelineChanged(Timeline timeline, Object manifest) {
// Do nothing.
}
@Override @Override
public void onLoadingChanged(boolean isLoading) { /* do nothing */ } public void onLoadingChanged(boolean isLoading) {
// Do nothing.
}
@Override @Override
public void onPlayerError(ExoPlaybackException error) { /* do nothing */ } public void onPlayerError(ExoPlaybackException error) {
// Do nothing.
}
@Override @Override
public void onClick(View view) { public void onClick(View view) {
......
...@@ -160,30 +160,30 @@ public final class SimpleExoPlayerView extends FrameLayout { ...@@ -160,30 +160,30 @@ public final class SimpleExoPlayerView extends FrameLayout {
} }
/** /**
* Set the number of milliseconds to rewind for each step. * Sets the rewind increment in milliseconds.
* *
* @param rewindMs Rewind step in milliseconds. * @param rewindMs The rewind increment in milliseconds.
*/ */
public void setRewindMs(int rewindMs) { public void setRewindIncrementMs(int rewindMs) {
controller.setRewindMs(rewindMs); controller.setRewindIncrementMs(rewindMs);
} }
/** /**
* Set the number of milliseconds to fast forward for each step. * Sets the fast forward increment in milliseconds.
* *
* @param fastForwardMs Fast forward step in milliseconds. * @param fastForwardMs The fast forward increment in milliseconds.
*/ */
public void setFastForwardMs(int fastForwardMs) { public void setFastForwardIncrementMs(int fastForwardMs) {
controller.setFastForwardMs(fastForwardMs); controller.setFastForwardIncrementMs(fastForwardMs);
} }
/** /**
* Set the duration to show the playback control in milliseconds. * Sets the duration to show the playback control in milliseconds.
* *
* @param showDuration Duration in milliseconds. * @param showDurationMs The duration in milliseconds.
*/ */
public void setControlShowDuration(int showDuration) { public void setControlShowDurationMs(int showDurationMs) {
controller.setShowDuration(showDuration); controller.setShowDurationMs(showDurationMs);
} }
/** /**
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#CC000000"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="#CC000000"
android:orientation="vertical" android:orientation="vertical"
android:layoutDirection="ltr"> android:layoutDirection="ltr">
...@@ -29,22 +29,24 @@ ...@@ -29,22 +29,24 @@
android:orientation="horizontal"> android:orientation="horizontal">
<ImageButton android:id="@+id/prev" <ImageButton android:id="@+id/prev"
style="@style/MediaButton.Previous"
android:contentDescription="@string/prev_description" android:contentDescription="@string/prev_description"
android:visibility="gone"/> style="@style/MediaButton.Previous"/>
<ImageButton android:id="@+id/rew" <ImageButton android:id="@+id/rew"
style="@style/MediaButton.Rew" android:contentDescription="@string/rew_description"
android:contentDescription="@string/rew_description"/> style="@style/MediaButton.Rew"/>
<ImageButton android:id="@+id/pause" <ImageButton android:id="@+id/pause"
style="@style/MediaButton.Pause" android:contentDescription="@string/pause_description"
android:contentDescription="@string/pause_description"/> style="@style/MediaButton.Pause"/>
<ImageButton android:id="@+id/ffwd" <ImageButton android:id="@+id/ffwd"
style="@style/MediaButton.Ffwd" android:contentDescription="@string/ffw_description"
android:contentDescription="@string/ffw_description"/> style="@style/MediaButton.Ffwd"/>
<ImageButton android:id="@+id/next" <ImageButton android:id="@+id/next"
style="@style/MediaButton.Next"
android:contentDescription="@string/prev_description" android:contentDescription="@string/prev_description"
android:visibility="gone"/> style="@style/MediaButton.Next"/>
</LinearLayout> </LinearLayout>
...@@ -54,30 +56,30 @@ ...@@ -54,30 +56,30 @@
android:orientation="horizontal"> android:orientation="horizontal">
<TextView android:id="@+id/time_current" <TextView android:id="@+id/time_current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingStart="4dp" android:paddingStart="4dp"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="4dp" android:paddingEnd="4dp"
android:textColor="#FFBEBEBE"/> android:textColor="#FFBEBEBE"/>
<SeekBar android:id="@+id/mediacontroller_progress" <SeekBar android:id="@+id/mediacontroller_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="32dp"/> android:layout_height="32dp"
style="?android:attr/progressBarStyleHorizontal"/>
<TextView android:id="@+id/time" <TextView android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="14sp" android:textSize="14sp"
android:textStyle="bold" android:textStyle="bold"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingEnd="4dp" android:paddingEnd="4dp"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="4dp" android:paddingStart="4dp"
android:textColor="#FFBEBEBE"/> android:textColor="#FFBEBEBE"/>
......
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