Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f19ab4aa
authored
Mar 24, 2021
by
kimvde
Committed by
Ian Baker
Mar 24, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add possibility to iterate over Commands
PiperOrigin-RevId: 364836973
parent
94a4ed79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/common/src/main/java/com/google/android/exoplayer2/util/ExoFlags.java
library/common/src/test/java/com/google/android/exoplayer2/util/ExoFlagsTest.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
f19ab4aa
...
...
@@ -690,6 +690,7 @@ public interface Player {
*
* @param index The index. Must be between 0 (inclusive) and {@link #size()} (exclusive).
* @return The {@link EventFlags event} at the given index.
* @throws IndexOutOfBoundsException If index is outside the allowed range.
*/
@EventFlags
public
int
get
(
int
index
)
{
...
...
@@ -787,6 +788,23 @@ public interface Player {
return
flags
.
contains
(
command
);
}
/** Returns the number of commands in this set. */
public
int
size
()
{
return
flags
.
size
();
}
/**
* Returns the {@link Command} at the given index.
*
* @param index The index. Must be between 0 (inclusive) and {@link #size()} (exclusive).
* @return The {@link Command} at the given index.
* @throws IndexOutOfBoundsException If index is outside the allowed range.
*/
@Command
public
int
get
(
int
index
)
{
return
flags
.
get
(
index
);
}
@Override
public
boolean
equals
(
@Nullable
Object
obj
)
{
if
(
this
==
obj
)
{
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/ExoFlags.java
View file @
f19ab4aa
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
util
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkIndex
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkState
;
import
android.util.SparseBooleanArray
;
...
...
@@ -152,10 +153,10 @@ public final class ExoFlags {
*
* @param index The index. Must be between 0 (inclusive) and {@link #size()} (exclusive).
* @return The flag at the given index.
* @throws I
llegalArgument
Exception If index is outside the allowed range.
* @throws I
ndexOutOfBounds
Exception If index is outside the allowed range.
*/
public
int
get
(
int
index
)
{
Assertions
.
checkArgument
(
index
>=
0
&&
index
<
size
());
checkIndex
(
index
,
/* start= */
0
,
/* limit= */
size
());
return
flags
.
keyAt
(
index
);
}
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/ExoFlagsTest.java
View file @
f19ab4aa
...
...
@@ -122,17 +122,17 @@ public final class ExoFlagsTest {
}
@Test
public
void
get_withNegativeIndex_throwsI
llegalArgument
Exception
()
{
public
void
get_withNegativeIndex_throwsI
ndexOutOfBounds
Exception
()
{
ExoFlags
flags
=
new
ExoFlags
.
Builder
().
build
();
assertThrows
(
I
llegalArgument
Exception
.
class
,
()
->
flags
.
get
(
/* index= */
-
1
));
assertThrows
(
I
ndexOutOfBounds
Exception
.
class
,
()
->
flags
.
get
(
/* index= */
-
1
));
}
@Test
public
void
get_withIndexExceedingSize_throwsI
llegalArgument
Exception
()
{
public
void
get_withIndexExceedingSize_throwsI
ndexOutOfBounds
Exception
()
{
ExoFlags
flags
=
new
ExoFlags
.
Builder
().
add
(
/* flag= */
0
).
add
(
/* flag= */
123
).
build
();
assertThrows
(
I
llegalArgument
Exception
.
class
,
()
->
flags
.
get
(
/* index= */
2
));
assertThrows
(
I
ndexOutOfBounds
Exception
.
class
,
()
->
flags
.
get
(
/* index= */
2
));
}
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment