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
e96fde5f
authored
May 07, 2021
by
aquilescanta
Committed by
Andrew Lewis
May 10, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add an IntDef for PlaybackException's Bundle key fields
PiperOrigin-RevId: 372548259
parent
2914e574
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java
library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java
View file @
e96fde5f
...
...
@@ -204,8 +204,25 @@ public class PlaybackException extends Exception implements Bundleable {
// Bundleable implementation.
/**
* Identifiers for fields in a {@link Bundle} which represents a playback exception. Subclasses
* may use {@link #FIELD_CUSTOM_ID_BASE} to generate more keys using {@link #keyForField(int)}.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
(
open
=
true
,
value
=
{
FIELD_INT_ERROR_CODE
,
FIELD_LONG_TIMESTAMP_MS
,
FIELD_STRING_MESSAGE
,
FIELD_STRING_CAUSE_CLASS_NAME
,
FIELD_STRING_CAUSE_MESSAGE
,
})
protected
@interface
FieldNumber
{}
private
static
final
int
FIELD_INT_ERROR_CODE
=
0
;
private
static
final
int
FIELD_LONG_TIME
_
STAMP_MS
=
1
;
private
static
final
int
FIELD_LONG_TIMESTAMP_MS
=
1
;
private
static
final
int
FIELD_STRING_MESSAGE
=
2
;
private
static
final
int
FIELD_STRING_CAUSE_CLASS_NAME
=
3
;
private
static
final
int
FIELD_STRING_CAUSE_MESSAGE
=
4
;
...
...
@@ -227,7 +244,7 @@ public class PlaybackException extends Exception implements Bundleable {
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putInt
(
keyForField
(
FIELD_INT_ERROR_CODE
),
errorCode
);
bundle
.
putLong
(
keyForField
(
FIELD_LONG_TIME
_
STAMP_MS
),
timestampMs
);
bundle
.
putLong
(
keyForField
(
FIELD_LONG_TIMESTAMP_MS
),
timestampMs
);
bundle
.
putString
(
keyForField
(
FIELD_STRING_MESSAGE
),
getMessage
());
@Nullable
Throwable
cause
=
getCause
();
if
(
cause
!=
null
)
{
...
...
@@ -250,7 +267,7 @@ public class PlaybackException extends Exception implements Bundleable {
keyForField
(
FIELD_INT_ERROR_CODE
),
/* defaultValue= */
ERROR_CODE_UNSPECIFIED
);
long
timestampMs
=
bundle
.
getLong
(
keyForField
(
FIELD_LONG_TIME
_
STAMP_MS
),
keyForField
(
FIELD_LONG_TIMESTAMP_MS
),
/* defaultValue= */
SystemClock
.
elapsedRealtime
());
@Nullable
String
message
=
bundle
.
getString
(
keyForField
(
FIELD_STRING_MESSAGE
));
@Nullable
String
causeClassName
=
bundle
.
getString
(
keyForField
(
FIELD_STRING_CAUSE_CLASS_NAME
));
...
...
@@ -279,10 +296,10 @@ public class PlaybackException extends Exception implements Bundleable {
}
/**
* Converts the given {@
code field} to a string which can be used as a field key when implementing
* {@link #toBundle()} and {@link Bundleable.Creator}.
* Converts the given {@
link FieldNumber} to a string which can be used as a field key when
*
implementing
{@link #toBundle()} and {@link Bundleable.Creator}.
*/
protected
static
String
keyForField
(
int
field
)
{
protected
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