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
d388ab25
authored
May 06, 2021
by
jinpark
Committed by
bachinger
May 06, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make Player.Commands Bundleable
PiperOrigin-RevId: 372266634
parent
5595c487
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
1 deletions
library/common/src/main/java/com/google/android/exoplayer2/Player.java
library/common/src/main/java/com/google/android/exoplayer2/Player.java
View file @
d388ab25
...
@@ -41,6 +41,7 @@ import com.google.common.base.Objects;
...
@@ -41,6 +41,7 @@ import com.google.common.base.Objects;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -567,7 +568,7 @@ public interface Player {
...
@@ -567,7 +568,7 @@ public interface Player {
*
*
* <p>Instances are immutable.
* <p>Instances are immutable.
*/
*/
final
class
Commands
{
final
class
Commands
implements
Bundleable
{
/** A builder for {@link Commands} instances. */
/** A builder for {@link Commands} instances. */
public
static
final
class
Builder
{
public
static
final
class
Builder
{
...
@@ -685,6 +686,46 @@ public interface Player {
...
@@ -685,6 +686,46 @@ public interface Player {
public
int
hashCode
()
{
public
int
hashCode
()
{
return
flags
.
hashCode
();
return
flags
.
hashCode
();
}
}
// Bundleable implementation.
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
FIELD_COMMANDS
})
private
@interface
FieldNumber
{}
private
static
final
int
FIELD_COMMANDS
=
0
;
@Override
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
ArrayList
<
Integer
>
commandsBundle
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
flags
.
size
();
i
++)
{
commandsBundle
.
add
(
flags
.
get
(
i
));
}
bundle
.
putIntegerArrayList
(
keyForField
(
FIELD_COMMANDS
),
commandsBundle
);
return
bundle
;
}
/** Object that can restore {@link Commands} from a {@link Bundle}. */
public
static
final
Creator
<
Commands
>
CREATOR
=
Commands:
:
fromBundle
;
private
static
Commands
fromBundle
(
Bundle
bundle
)
{
@Nullable
ArrayList
<
Integer
>
commands
=
bundle
.
getIntegerArrayList
(
keyForField
(
FIELD_COMMANDS
));
if
(
commands
==
null
)
{
return
Commands
.
EMPTY
;
}
Builder
builder
=
new
Builder
();
for
(
int
i
=
0
;
i
<
commands
.
size
();
i
++)
{
builder
.
add
(
commands
.
get
(
i
));
}
return
builder
.
build
();
}
private
static
String
keyForField
(
@FieldNumber
int
field
)
{
return
Integer
.
toString
(
field
,
Character
.
MAX_RADIX
);
}
}
}
/**
/**
...
...
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