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
3dc72a69
authored
Dec 17, 2018
by
eguven
Committed by
Oliver Woodman
Dec 18, 2018
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove targetState in DownloadManager.Download
PiperOrigin-RevId: 225849846
parent
3d6707e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
22 deletions
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadManager.java
View file @
3dc72a69
...
@@ -553,12 +553,6 @@ public final class DownloadManager {
...
@@ -553,12 +553,6 @@ public final class DownloadManager {
private
static
final
class
Download
{
private
static
final
class
Download
{
/** Target states for the download thread. */
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
STATE_QUEUED
,
STATE_COMPLETED
})
public
@interface
TargetState
{}
private
final
String
id
;
private
final
String
id
;
private
final
DownloadManager
downloadManager
;
private
final
DownloadManager
downloadManager
;
private
final
DownloaderFactory
downloaderFactory
;
private
final
DownloaderFactory
downloaderFactory
;
...
@@ -568,11 +562,6 @@ public final class DownloadManager {
...
@@ -568,11 +562,6 @@ public final class DownloadManager {
private
DownloadAction
action
;
private
DownloadAction
action
;
/** The current state of the download. */
/** The current state of the download. */
@DownloadState
.
State
private
int
state
;
@DownloadState
.
State
private
int
state
;
/**
* When started, this is the target state that the download will transition to when the download
* thread stops.
*/
@TargetState
private
volatile
int
targetState
;
@MonotonicNonNull
private
Downloader
downloader
;
@MonotonicNonNull
private
Downloader
downloader
;
@MonotonicNonNull
private
DownloadThread
downloadThread
;
@MonotonicNonNull
private
DownloadThread
downloadThread
;
...
@@ -590,7 +579,6 @@ public final class DownloadManager {
...
@@ -590,7 +579,6 @@ public final class DownloadManager {
this
.
minRetryCount
=
minRetryCount
;
this
.
minRetryCount
=
minRetryCount
;
this
.
startTimeMs
=
System
.
currentTimeMillis
();
this
.
startTimeMs
=
System
.
currentTimeMillis
();
state
=
STATE_QUEUED
;
state
=
STATE_QUEUED
;
targetState
=
STATE_COMPLETED
;
actionQueue
=
new
ArrayDeque
<>();
actionQueue
=
new
ArrayDeque
<>();
actionQueue
.
add
(
action
);
actionQueue
.
add
(
action
);
}
}
...
@@ -603,9 +591,7 @@ public final class DownloadManager {
...
@@ -603,9 +591,7 @@ public final class DownloadManager {
return
;
return
;
}
}
if
(
state
==
STATE_STARTED
)
{
if
(
state
==
STATE_STARTED
)
{
if
(
targetState
==
STATE_COMPLETED
)
{
stopDownloadThread
();
stopDownloadThread
();
}
}
else
{
}
else
{
Assertions
.
checkState
(
state
==
STATE_QUEUED
);
Assertions
.
checkState
(
state
==
STATE_QUEUED
);
action
=
updatedAction
;
action
=
updatedAction
;
...
@@ -648,9 +634,7 @@ public final class DownloadManager {
...
@@ -648,9 +634,7 @@ public final class DownloadManager {
+
' '
+
' '
+
(
action
.
isRemoveAction
?
"remove"
:
"download"
)
+
(
action
.
isRemoveAction
?
"remove"
:
"download"
)
+
' '
+
' '
+
DownloadState
.
getStateString
(
state
)
+
DownloadState
.
getStateString
(
state
);
+
' '
+
DownloadState
.
getStateString
(
targetState
);
}
}
public
boolean
canStart
()
{
public
boolean
canStart
()
{
...
@@ -661,7 +645,6 @@ public final class DownloadManager {
...
@@ -661,7 +645,6 @@ public final class DownloadManager {
if
(
state
==
STATE_QUEUED
)
{
if
(
state
==
STATE_QUEUED
)
{
state
=
STATE_STARTED
;
state
=
STATE_STARTED
;
action
=
actionQueue
.
peek
();
action
=
actionQueue
.
peek
();
targetState
=
STATE_COMPLETED
;
downloader
=
downloaderFactory
.
createDownloader
(
action
);
downloader
=
downloaderFactory
.
createDownloader
(
action
);
downloadThread
=
downloadThread
=
new
DownloadThread
(
new
DownloadThread
(
...
@@ -679,14 +662,12 @@ public final class DownloadManager {
...
@@ -679,14 +662,12 @@ public final class DownloadManager {
// Internal methods running on the main thread.
// Internal methods running on the main thread.
private
void
stopDownloadThread
()
{
private
void
stopDownloadThread
()
{
this
.
targetState
=
DownloadState
.
STATE_QUEUED
;
Assertions
.
checkNotNull
(
downloadThread
).
cancel
();
Assertions
.
checkNotNull
(
downloadThread
).
cancel
();
}
}
private
void
onDownloadThreadStopped
(
@Nullable
Throwable
finalError
)
{
private
void
onDownloadThreadStopped
(
@Nullable
Throwable
finalError
)
{
state
=
targetState
;
failureReason
=
FAILURE_REASON_NONE
;
failureReason
=
FAILURE_REASON_NONE
;
if
(
targetState
==
STATE_COMPLETED
)
{
if
(
!
downloadThread
.
isCanceled
)
{
if
(
finalError
!=
null
)
{
if
(
finalError
!=
null
)
{
state
=
STATE_FAILED
;
state
=
STATE_FAILED
;
failureReason
=
FAILURE_REASON_UNKNOWN
;
failureReason
=
FAILURE_REASON_UNKNOWN
;
...
@@ -696,8 +677,12 @@ public final class DownloadManager {
...
@@ -696,8 +677,12 @@ public final class DownloadManager {
// Don't continue running. Wait to be restarted by maybeStartDownloads().
// Don't continue running. Wait to be restarted by maybeStartDownloads().
state
=
STATE_QUEUED
;
state
=
STATE_QUEUED
;
action
=
actionQueue
.
peek
();
action
=
actionQueue
.
peek
();
}
else
{
state
=
STATE_COMPLETED
;
}
}
}
}
}
else
{
state
=
STATE_QUEUED
;
}
}
downloadManager
.
onDownloadStateChange
(
this
);
downloadManager
.
onDownloadStateChange
(
this
);
}
}
...
...
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