The Android Developer Challenge is back! Submit your idea before December 2.

TestListenableWorkerBuilder

public class TestListenableWorkerBuilder
extends Object

java.lang.Object
   ↳ androidx.work.testing.TestListenableWorkerBuilder<W extends androidx.work.ListenableWorker>


Builds instances of ListenableWorker which can be used for testing.

Summary

Public methods

W build()

Builds the ListenableWorker.

static TestListenableWorkerBuilder from(Context context, WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

static <W extends ListenableWorker> TestListenableWorkerBuilder<W> from(Context context, Class<W> workerClass)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

TestListenableWorkerBuilder setForegroundUpdater(ForegroundUpdater updater)

Sets the ForegroundUpdater to be used to construct the ListenableWorker.

TestListenableWorkerBuilder setId(UUID id)

Sets the id for this unit of work.

TestListenableWorkerBuilder setInputData(Data inputData)

Adds input Data to the work.

TestListenableWorkerBuilder setNetwork(Network network)

Sets the network associated with this unit of work.

TestListenableWorkerBuilder setProgressUpdater(ProgressUpdater updater)

Sets the ProgressUpdater to be used to construct the ListenableWorker.

TestListenableWorkerBuilder setRunAttemptCount(int runAttemptCount)

Sets the initial run attempt count for this work.

TestListenableWorkerBuilder setTags(List<String> tags)

Sets the tags associated with this unit of work.

TestListenableWorkerBuilder setTriggeredContentAuthorities(List<String> authorities)

Sets the authorities for content Uri's associated with this unit of work.

TestListenableWorkerBuilder setTriggeredContentUris(List<Uri> contentUris)

Sets the list of Content Uris associated with this unit of work.

TestListenableWorkerBuilder setWorkerFactory(WorkerFactory workerFactory)

Sets the WorkerFactory to be used to construct the ListenableWorker.

Inherited methods

Public methods

build

public W build ()

Builds the ListenableWorker.

Returns
W the instance of a ListenableWorker.

from

public static TestListenableWorkerBuilder from (Context context, 
                WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

Parameters
context Context: The Context

workRequest WorkRequest: The WorkRequest

Returns
TestListenableWorkerBuilder The new instance of a ListenableWorker

from

public static TestListenableWorkerBuilder<W> from (Context context, 
                Class<W> workerClass)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

Parameters
context Context: The Context

workerClass Class: The subtype of ListenableWorker being built

Returns
TestListenableWorkerBuilder<W> The new instance of a ListenableWorker

setForegroundUpdater

public TestListenableWorkerBuilder setForegroundUpdater (ForegroundUpdater updater)

Sets the ForegroundUpdater to be used to construct the ListenableWorker.

Parameters
updater ForegroundUpdater: The ForegroundUpdater which can handle notification updates.

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setId

public TestListenableWorkerBuilder setId (UUID id)

Sets the id for this unit of work.

Parameters
id UUID: The UUID

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setInputData

public TestListenableWorkerBuilder setInputData (Data inputData)

Adds input Data to the work.

Parameters
inputData Data: key/value pairs that will be provided to the worker

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setNetwork

public TestListenableWorkerBuilder setNetwork (Network network)

Sets the network associated with this unit of work.

Parameters
network Network: The Network associated with this unit of work

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setProgressUpdater

public TestListenableWorkerBuilder setProgressUpdater (ProgressUpdater updater)

Sets the ProgressUpdater to be used to construct the ListenableWorker.

Parameters
updater ProgressUpdater: The ProgressUpdater which can handle progress updates.

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setRunAttemptCount

public TestListenableWorkerBuilder setRunAttemptCount (int runAttemptCount)

Sets the initial run attempt count for this work.

Parameters
runAttemptCount int: The initial run attempt count

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setTags

public TestListenableWorkerBuilder setTags (List<String> tags)

Sets the tags associated with this unit of work.

Parameters
tags List: The List of tags to be used

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setTriggeredContentAuthorities

public TestListenableWorkerBuilder setTriggeredContentAuthorities (List<String> authorities)

Sets the authorities for content Uri's associated with this unit of work.

Parameters
authorities List: The List of authorities

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setTriggeredContentUris

public TestListenableWorkerBuilder setTriggeredContentUris (List<Uri> contentUris)

Sets the list of Content Uris associated with this unit of work.

Parameters
contentUris List: The list of content Uris

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder

setWorkerFactory

public TestListenableWorkerBuilder setWorkerFactory (WorkerFactory workerFactory)

Sets the WorkerFactory to be used to construct the ListenableWorker.

Parameters
workerFactory WorkerFactory: The WorkerFactory to use to construct the ListenableWorker

Returns
TestListenableWorkerBuilder The current TestListenableWorkerBuilder