feat(playlist): stick to list.subList API
This commit is contained in:
parent
2c801ca267
commit
cc7f011ecb
@ -312,16 +312,11 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
|||||||
* is thrown.
|
* is thrown.
|
||||||
*
|
*
|
||||||
* @param fromIndex The initial range index, pointing to the first media source that will be
|
* @param fromIndex The initial range index, pointing to the first media source that will be
|
||||||
* removed. This index must be in the range of 0 <= index < {@link #getSize()}.
|
* removed. This index must be in the range of 0 <= index <= {@link #getSize()}.
|
||||||
* @param toIndex The final range index, pointing to the first media source that will be left
|
* @param toIndex The final range index, pointing to the first media source that will be left
|
||||||
* untouched. The last media source to be removed is at index {@code toIndex} - 1.
|
* untouched. This index must be in the range of 0 <= index <= {@link #getSize()}.
|
||||||
* This index must be in the range of 0 <= index < {@link #getSize()}.
|
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} <
|
||||||
*
|
* 0, {@code toIndex} > {@link #getSize()}, {@code fromIndex} > {@code toIndex}
|
||||||
* @throws IndexOutOfBoundsException when either index is out of playlist bounds, i.e. {@code
|
|
||||||
* fromIndex} < 0 or >= {@link #getSize()}, {@code toIndex} < 0 or > {@link
|
|
||||||
* #getSize()}
|
|
||||||
* @throws IndexOutOfBoundsException when range is malformed, i.e. {@code fromIndex} >
|
|
||||||
* {@code toIndex}
|
|
||||||
*/
|
*/
|
||||||
public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex) {
|
public final synchronized void removeMediaSourceRange(int fromIndex, int toIndex) {
|
||||||
removeMediaSourceRange(fromIndex, toIndex, null);
|
removeMediaSourceRange(fromIndex, toIndex, null);
|
||||||
@ -335,37 +330,23 @@ public class ConcatenatingMediaSource extends CompositeMediaSource<MediaSourceHo
|
|||||||
* is thrown.
|
* is thrown.
|
||||||
*
|
*
|
||||||
* @param fromIndex The initial range index, pointing to the first media source that will be
|
* @param fromIndex The initial range index, pointing to the first media source that will be
|
||||||
* removed. This index must be in the range of 0 <= index < {@link #getSize()}.
|
* removed. This index must be in the range of 0 <= index <= {@link #getSize()}.
|
||||||
* @param toIndex The final range index, pointing to the first media source that will be left
|
* @param toIndex The final range index, pointing to the first media source that will be left
|
||||||
* untouched. The last media source to be removed is at index {@code toIndex} - 1.
|
* untouched. This index must be in the range of 0 <= index <= {@link #getSize()}.
|
||||||
* This index must be in the range of 0 <= index < {@link #getSize()}.
|
|
||||||
*
|
|
||||||
* @throws IndexOutOfBoundsException when either index is out of playlist bounds, i.e. {@code
|
|
||||||
* fromIndex} < 0 or >= {@link #getSize()}, {@code toIndex} < 0 or > {@link
|
|
||||||
* #getSize()}
|
|
||||||
* @throws IndexOutOfBoundsException when range is malformed, i.e. {@code fromIndex} >
|
|
||||||
* {@code toIndex}
|
|
||||||
* @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
|
* @param actionOnCompletion A {@link Runnable} which is executed immediately after the media
|
||||||
* source range has been removed from the playlist.
|
* source range has been removed from the playlist.
|
||||||
|
* @throws IndexOutOfBoundsException When the range is malformed, i.e. {@code fromIndex} <
|
||||||
|
* 0, {@code toIndex} > {@link #getSize()}, {@code fromIndex} > {@code toIndex}
|
||||||
*/
|
*/
|
||||||
public final synchronized void removeMediaSourceRange(
|
public final synchronized void removeMediaSourceRange(
|
||||||
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) {
|
int fromIndex, int toIndex, @Nullable Runnable actionOnCompletion) {
|
||||||
if (fromIndex < 0 || fromIndex >= mediaSourcesPublic.size()) {
|
Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
|
||||||
throw new IndexOutOfBoundsException(String.format("Cannot remove source range: initial index (%d) out of bounds", fromIndex));
|
|
||||||
}
|
|
||||||
if (toIndex < 0 || toIndex > mediaSourcesPublic.size()) {
|
|
||||||
throw new IndexOutOfBoundsException(String.format("Cannot remove source range: final index (%d) out of bounds", toIndex));
|
|
||||||
}
|
|
||||||
if (fromIndex > toIndex) {
|
|
||||||
throw new IndexOutOfBoundsException(String.format("Cannot remove source range: range malformed (%d, %d)", fromIndex, toIndex));
|
|
||||||
}
|
|
||||||
if (fromIndex == toIndex) {
|
if (fromIndex == toIndex) {
|
||||||
if (actionOnCompletion != null) {
|
if (actionOnCompletion != null) {
|
||||||
actionOnCompletion.run();
|
actionOnCompletion.run();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mediaSourcesPublic.subList(fromIndex, toIndex).clear();
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player
|
player
|
||||||
.createMessage(this)
|
.createMessage(this)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user