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
709a712a
authored
Mar 26, 2019
by
eguven
Committed by
Toni
Mar 29, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
DownloadAction custom id
PiperOrigin-RevId: 240363716
parent
30d66f50
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadAction.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadAction.java
View file @
709a712a
...
...
@@ -87,7 +87,29 @@ public final class DownloadAction {
List
<
StreamKey
>
keys
,
@Nullable
String
customCacheKey
,
@Nullable
byte
[]
data
)
{
return
new
DownloadAction
(
type
,
uri
,
/* isRemoveAction= */
false
,
keys
,
customCacheKey
,
data
);
return
createDownloadAction
(
generateId
(
uri
,
customCacheKey
),
type
,
uri
,
keys
,
customCacheKey
,
data
);
}
/**
* Creates a DASH download action.
*
* @param id The content id.
* @param type The type of the action.
* @param uri The URI of the media to be downloaded.
* @param keys Keys of streams to be downloaded. If empty, all streams will be downloaded.
* @param customCacheKey A custom key for cache indexing, or null.
* @param data Optional custom data for this action. If {@code null} an empty array will be used.
*/
public
static
DownloadAction
createDownloadAction
(
String
id
,
String
type
,
Uri
uri
,
List
<
StreamKey
>
keys
,
@Nullable
String
customCacheKey
,
@Nullable
byte
[]
data
)
{
return
new
DownloadAction
(
id
,
type
,
uri
,
/* isRemoveAction= */
false
,
keys
,
customCacheKey
,
data
);
}
/**
...
...
@@ -100,6 +122,7 @@ public final class DownloadAction {
public
static
DownloadAction
createRemoveAction
(
String
type
,
Uri
uri
,
@Nullable
String
customCacheKey
)
{
return
new
DownloadAction
(
generateId
(
uri
,
customCacheKey
),
type
,
uri
,
/* isRemoveAction= */
true
,
...
...
@@ -127,6 +150,7 @@ public final class DownloadAction {
public
final
byte
[]
data
;
/**
* @param id The content id.
* @param type The type of the action.
* @param uri The uri being downloaded or removed.
* @param isRemoveAction Whether this is a remove action. If false, this is a download action.
...
...
@@ -136,13 +160,14 @@ public final class DownloadAction {
* @param data Custom data for this action. Null if this action is a remove action.
*/
private
DownloadAction
(
String
id
,
String
type
,
Uri
uri
,
boolean
isRemoveAction
,
List
<
StreamKey
>
keys
,
@Nullable
String
customCacheKey
,
@Nullable
byte
[]
data
)
{
this
.
id
=
customCacheKey
!=
null
?
customCacheKey
:
uri
.
toString
()
;
this
.
id
=
id
;
this
.
type
=
type
;
this
.
uri
=
uri
;
this
.
isRemoveAction
=
isRemoveAction
;
...
...
@@ -272,7 +297,12 @@ public final class DownloadAction {
customCacheKey
=
input
.
readBoolean
()
?
input
.
readUTF
()
:
null
;
}
return
new
DownloadAction
(
type
,
uri
,
isRemoveAction
,
keys
,
customCacheKey
,
data
);
return
new
DownloadAction
(
generateId
(
uri
,
customCacheKey
),
type
,
uri
,
isRemoveAction
,
keys
,
customCacheKey
,
data
);
}
private
static
String
generateId
(
Uri
uri
,
@Nullable
String
customCacheKey
)
{
return
customCacheKey
!=
null
?
customCacheKey
:
uri
.
toString
();
}
private
static
StreamKey
readKey
(
String
type
,
int
version
,
DataInputStream
input
)
...
...
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