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
df1536ab
authored
Jul 20, 2020
by
olly
Committed by
Oliver Woodman
Jul 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Migrate WorkManagerScheduler to non-deprecated WorkManager.getInstance
PiperOrigin-RevId: 322143769
parent
0cd15d91
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
extensions/workmanager/src/main/java/com/google/android/exoplayer2/ext/workmanager/WorkManagerScheduler.java
extensions/workmanager/src/main/java/com/google/android/exoplayer2/ext/workmanager/WorkManagerScheduler.java
View file @
df1536ab
...
@@ -46,16 +46,27 @@ public final class WorkManagerScheduler implements Scheduler {
...
@@ -46,16 +46,27 @@ public final class WorkManagerScheduler implements Scheduler {
|
Requirements
.
DEVICE_CHARGING
|
Requirements
.
DEVICE_CHARGING
|
Requirements
.
DEVICE_STORAGE_NOT_LOW
;
|
Requirements
.
DEVICE_STORAGE_NOT_LOW
;
private
final
WorkManager
workManager
;
private
final
String
workName
;
private
final
String
workName
;
/** @deprecated Call {@link #WorkManagerScheduler(Context, String)} instead. */
@Deprecated
@SuppressWarnings
(
"deprecation"
)
public
WorkManagerScheduler
(
String
workName
)
{
this
.
workName
=
workName
;
workManager
=
WorkManager
.
getInstance
();
}
/**
/**
* @param context A context.
* @param workName A name for work scheduled by this instance. If the same name was used by a
* @param workName A name for work scheduled by this instance. If the same name was used by a
* previous instance, anything scheduled by the previous instance will be canceled by this
* previous instance, anything scheduled by the previous instance will be canceled by this
* instance if {@link #schedule(Requirements, String, String)} or {@link #cancel()} are
* instance if {@link #schedule(Requirements, String, String)} or {@link #cancel()} are
* called.
* called.
*/
*/
public
WorkManagerScheduler
(
String
workName
)
{
public
WorkManagerScheduler
(
Context
context
,
String
workName
)
{
this
.
workName
=
workName
;
this
.
workName
=
workName
;
workManager
=
WorkManager
.
getInstance
(
context
.
getApplicationContext
());
}
}
@Override
@Override
...
@@ -63,13 +74,13 @@ public final class WorkManagerScheduler implements Scheduler {
...
@@ -63,13 +74,13 @@ public final class WorkManagerScheduler implements Scheduler {
Constraints
constraints
=
buildConstraints
(
requirements
);
Constraints
constraints
=
buildConstraints
(
requirements
);
Data
inputData
=
buildInputData
(
requirements
,
servicePackage
,
serviceAction
);
Data
inputData
=
buildInputData
(
requirements
,
servicePackage
,
serviceAction
);
OneTimeWorkRequest
workRequest
=
buildWorkRequest
(
constraints
,
inputData
);
OneTimeWorkRequest
workRequest
=
buildWorkRequest
(
constraints
,
inputData
);
WorkManager
.
getInstance
()
.
enqueueUniqueWork
(
workName
,
ExistingWorkPolicy
.
REPLACE
,
workRequest
);
workManager
.
enqueueUniqueWork
(
workName
,
ExistingWorkPolicy
.
REPLACE
,
workRequest
);
return
true
;
return
true
;
}
}
@Override
@Override
public
boolean
cancel
()
{
public
boolean
cancel
()
{
WorkManager
.
getInstance
()
.
cancelUniqueWork
(
workName
);
workManager
.
cancelUniqueWork
(
workName
);
return
true
;
return
true
;
}
}
...
...
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