Remove isFirstWindow/isLastWindow from Timeline.

These methods are only used in one place, and offer duplicate
functionality to checking getNext(Previous)WindowIndex == C.INDEX_UNSET.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=165910258
This commit is contained in:
tonihei 2017-08-21 03:49:38 -07:00 committed by Oliver Woodman
parent cec0c52c8d
commit cb45a47da1
2 changed files with 4 additions and 27 deletions

View File

@ -593,30 +593,6 @@ public abstract class Timeline {
} }
} }
/**
* Returns whether the given window is the last window of the timeline depending on the
* {@code repeatMode}.
*
* @param windowIndex A window index.
* @param repeatMode A repeat mode.
* @return Whether the window of the given index is the last window of the timeline.
*/
public final boolean isLastWindow(int windowIndex, @Player.RepeatMode int repeatMode) {
return getNextWindowIndex(windowIndex, repeatMode) == C.INDEX_UNSET;
}
/**
* Returns whether the given window is the first window of the timeline depending on the
* {@code repeatMode}.
*
* @param windowIndex A window index.
* @param repeatMode A repeat mode.
* @return Whether the window of the given index is the first window of the timeline.
*/
public final boolean isFirstWindow(int windowIndex, @Player.RepeatMode int repeatMode) {
return getPreviousWindowIndex(windowIndex, repeatMode) == C.INDEX_UNSET;
}
/** /**
* Populates a {@link Window} with data for the window at the specified index. Does not populate * Populates a {@link Window} with data for the window at the specified index. Does not populate
* {@link Window#id}. * {@link Window#id}.

View File

@ -674,9 +674,10 @@ public class PlaybackControlView extends FrameLayout {
int windowIndex = player.getCurrentWindowIndex(); int windowIndex = player.getCurrentWindowIndex();
timeline.getWindow(windowIndex, window); timeline.getWindow(windowIndex, window);
isSeekable = window.isSeekable; isSeekable = window.isSeekable;
enablePrevious = !timeline.isFirstWindow(windowIndex, player.getRepeatMode()) enablePrevious = isSeekable || !window.isDynamic
|| isSeekable || !window.isDynamic; || timeline.getPreviousWindowIndex(windowIndex, player.getRepeatMode()) != C.INDEX_UNSET;
enableNext = !timeline.isLastWindow(windowIndex, player.getRepeatMode()) || window.isDynamic; enableNext = window.isDynamic
|| timeline.getNextWindowIndex(windowIndex, player.getRepeatMode()) != C.INDEX_UNSET;
if (player.isPlayingAd()) { if (player.isPlayingAd()) {
// Always hide player controls during ads. // Always hide player controls during ads.
hide(); hide();