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
9c6c74d5
authored
Mar 12, 2019
by
eguven
Committed by
Oliver Woodman
Mar 15, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix merging download action to completed and stop flag set download
PiperOrigin-RevId: 238002393
parent
76e99504
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadState.java
View file @
9c6c74d5
...
...
@@ -247,7 +247,7 @@ public final class DownloadState {
type
,
action
.
uri
,
action
.
customCacheKey
,
getNextState
(
state
,
action
.
isRemoveAction
),
getNextState
(
state
,
stopFlags
!=
0
,
action
.
isRemoveAction
),
/* downloadPercentage= */
C
.
PERCENTAGE_UNSET
,
downloadedBytes
,
/* totalBytes= */
C
.
LENGTH_UNSET
,
...
...
@@ -261,14 +261,14 @@ public final class DownloadState {
action
.
data
);
}
private
static
int
getNextState
(
int
currentState
,
boolean
remove
)
{
private
static
int
getNextState
(
int
currentState
,
boolean
stopFlagsSet
,
boolean
remove
)
{
int
nextState
;
if
(
remove
)
{
nextState
=
STATE_REMOVING
;
}
else
{
if
(
currentState
==
STATE_REMOVING
||
currentState
==
STATE_RESTARTING
)
{
nextState
=
STATE_RESTARTING
;
}
else
if
(
currentState
==
STATE_STOPPED
)
{
}
else
if
(
stopFlagsSet
)
{
nextState
=
STATE_STOPPED
;
}
else
{
nextState
=
STATE_QUEUED
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadStateTest.java
View file @
9c6c74d5
...
...
@@ -196,6 +196,22 @@ public class DownloadStateTest {
}
@Test
public
void
mergeAction_stopFlagSetButNotInStoppedState_stateBecomesStopped
()
{
DownloadAction
downloadAction
=
createDownloadAction
();
DownloadStateBuilder
downloadStateBuilder
=
new
DownloadStateBuilder
(
downloadAction
)
.
setState
(
DownloadState
.
STATE_COMPLETED
)
.
setStopFlags
(
DownloadState
.
STOP_FLAG_MANUAL
);
DownloadState
downloadState
=
downloadStateBuilder
.
build
();
DownloadState
mergedDownloadState
=
downloadState
.
mergeAction
(
downloadAction
);
DownloadState
expectedDownloadState
=
downloadStateBuilder
.
setState
(
DownloadState
.
STATE_STOPPED
).
build
();
assertEqual
(
mergedDownloadState
,
expectedDownloadState
);
}
@Test
public
void
mergeAction_restartingDownloadRemoveAction_stateBecomesRemoving
()
{
DownloadAction
downloadAction
=
createRemoveAction
();
DownloadStateBuilder
downloadStateBuilder
=
...
...
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