public final class Timer.Builder


Builder for Timer.

Summary

Public constructors

Constructor for Timer.Builder with all the existing values.

Builder(@NonNull String namespace, @NonNull String id)

Constructor for Timer.Builder.

Public methods

@NonNull T

Adds an alias for the item.

@NonNull T

Add a new action to the list of potential actions for this document.

@NonNull Timer

Builds the Timer.

@NonNull Thing

Builds a Thing object.

@NonNull T

Clears the aliases, if any, for the item.

@NonNull T

Clear all the potential actions for this document.

@NonNull T
setBaseTimeMillis(
    long baseTimeMillis,
    long baseTimeMillisInElapsedRealtime,
    int bootCount
)

Sets the point in time that the Timer counts down from, relative to its setRemainingDurationMillis.

@NonNull T
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
setBaseTimeMillis(
    @NonNull Context context,
    long baseTimeMillis,
    long baseTimeMillisInElapsedRealtime
)

Sets the point in time that the Timer counts down from, relative to its setRemainingDurationMillis.

@NonNull T
setCreationTimestampMillis(long creationTimestampMillis)

Sets the creation timestamp for the current AppSearch entity, in milliseconds using the currentTimeMillis time base.

@NonNull T

Sets the description for the item.

@NonNull T
setDocumentScore(int documentScore)

Sets the user-provided opaque document score of the current AppSearch document, which can be used for ranking using RANKING_STRATEGY_DOCUMENT_SCORE.

@NonNull T
setDocumentTtlMillis(long documentTtlMillis)

Sets the time-to-live (TTL) for the current AppSearch document as a duration in milliseconds.

@NonNull T
setDurationMillis(long durationMillis)

Sets the total duration in milliseconds, including additional time added by the user.

@NonNull T

Sets the URL for an image of the item.

@NonNull T

Sets the name of the item.

@NonNull T
setOriginalDurationMillis(long originalDurationMillis)

Sets the original duration in milliseconds when the Timer was first created.

@NonNull T
setRemainingDurationMillis(long remainingDurationMillis)

Sets the amount of time remaining in milliseconds for the Timer relative to its setBaseTimeMillis.

@NonNull T

Sets the content URI for the ringtone to be played, or VALUE_RINGTONE_SILENT if no ringtone will be played.

@NonNull T
setShouldVibrate(boolean shouldVibrate)

Sets whether or not to activate the device vibrator when the Timer expires.

@NonNull T
setStartTimeMillis(long startTimeMillis)

Sets the start time in milliseconds using the currentTimeMillis time base.

@NonNull T
setStatus(int status)

Sets the current status.

@NonNull T

Sets the deeplink URL of the item.

Protected fields

mAlternateNames

protected List<StringmAlternateNames

mBaseTimeMillis

protected long mBaseTimeMillis

mBaseTimeMillisInElapsedRealtime

protected long mBaseTimeMillisInElapsedRealtime

mBootCount

protected int mBootCount

mCreationTimestampMillis

protected long mCreationTimestampMillis

mDescription

protected String mDescription

mDocumentScore

protected int mDocumentScore

mDocumentTtlMillis

protected long mDocumentTtlMillis

mDurationMillis

protected long mDurationMillis

mId

protected final String mId

mImage

protected String mImage

mName

protected String mName

mNamespace

protected final String mNamespace

mOriginalDurationMillis

protected long mOriginalDurationMillis

mPotentialActions

protected List<PotentialActionmPotentialActions

mRemainingDurationMillis

protected long mRemainingDurationMillis

mRingtone

protected String mRingtone

mShouldVibrate

protected boolean mShouldVibrate

mStartTimeMillis

protected long mStartTimeMillis

mStatus

protected int mStatus

mUrl

protected String mUrl

Public constructors

Builder

Added in 1.1.0-alpha04
public Builder(@NonNull Timer timer)

Constructor for Timer.Builder with all the existing values.

Builder

Added in 1.1.0-alpha04
public Builder(@NonNull String namespace, @NonNull String id)

Constructor for Timer.Builder.

Parameters
@NonNull String namespace

Namespace for the Document. See Document.Namespace.

@NonNull String id

Unique identifier for the Document. See Document.Id.

Public methods

addAlternateName

Added in 1.1.0-alpha04
public @NonNulladdAlternateName(@NonNull String alternateName)

Adds an alias for the item.

addPotentialAction

Added in 1.1.0-alpha04
public @NonNulladdPotentialAction(@NonNull PotentialAction newPotentialAction)

Add a new action to the list of potential actions for this document.

build

Added in 1.1.0-alpha04
public @NonNull Timer build()

Builds the Timer.

build

Added in 1.1.0-alpha04
public @NonNull Thing build()

Builds a Thing object.

clearAlternateNames

Added in 1.1.0-alpha04
public @NonNullclearAlternateNames()

Clears the aliases, if any, for the item.

clearPotentialActions

Added in 1.1.0-alpha04
public @NonNullclearPotentialActions()

Clear all the potential actions for this document.

setBaseTimeMillis

Added in 1.1.0-alpha04
public @NonNullsetBaseTimeMillis(
    long baseTimeMillis,
    long baseTimeMillisInElapsedRealtime,
    int bootCount
)

Sets the point in time that the Timer counts down from, relative to its setRemainingDurationMillis.

The expire time of the Timer can be calculated using the sum of its base time and remaining time.

Base time should be sampled in both the currentTimeMillis and elapsedRealtime time base. In addition, the boot count of the device is needed to check if the elapsedRealtime time base is valid.

Parameters
long baseTimeMillis

The base time in milliseconds using the currentTimeMillis time base.

long baseTimeMillisInElapsedRealtime

The base time in milliseconds using the elapsedRealtime time base.

int bootCount

The current boot count of the device. See BOOT_COUNT.

setBaseTimeMillis

Added in 1.1.0-alpha04
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public @NonNullsetBaseTimeMillis(
    @NonNull Context context,
    long baseTimeMillis,
    long baseTimeMillisInElapsedRealtime
)

Sets the point in time that the Timer counts down from, relative to its setRemainingDurationMillis.

The expire time of the Timer can be calculated using the sum of its base time and remaining time.

See setBaseTimeMillis.

Parameters
@NonNull Context context

The app context used to fetch boot count.

long baseTimeMillis

The base time in milliseconds using the currentTimeMillis time base.

long baseTimeMillisInElapsedRealtime

The base time in milliseconds using the elapsedRealtime time base.

setCreationTimestampMillis

Added in 1.1.0-alpha04
public @NonNullsetCreationTimestampMillis(long creationTimestampMillis)

Sets the creation timestamp for the current AppSearch entity, in milliseconds using the currentTimeMillis time base.

This timestamp refers to the creation time of the AppSearch entity, not when the document is written into AppSearch.

If not set, then the current timestamp will be used.

See androidx.appsearch.annotation.Document.CreationTimestampMillis for more information on creation timestamp.

setDescription

Added in 1.1.0-alpha04
public @NonNullsetDescription(@Nullable String description)

Sets the description for the item.

setDocumentScore

Added in 1.1.0-alpha04
public @NonNullsetDocumentScore(int documentScore)

Sets the user-provided opaque document score of the current AppSearch document, which can be used for ranking using RANKING_STRATEGY_DOCUMENT_SCORE.

See androidx.appsearch.annotation.Document.Score for more information on score.

setDocumentTtlMillis

Added in 1.1.0-alpha04
public @NonNullsetDocumentTtlMillis(long documentTtlMillis)

Sets the time-to-live (TTL) for the current AppSearch document as a duration in milliseconds.

The document will be automatically deleted when the TTL expires.

If not set, then the document will never expire.

See androidx.appsearch.annotation.Document.TtlMillis for more information on TTL.

setDurationMillis

Added in 1.1.0-alpha04
public @NonNullsetDurationMillis(long durationMillis)

Sets the total duration in milliseconds, including additional time added by the user.

setImage

Added in 1.1.0-alpha04
public @NonNullsetImage(@Nullable String image)

Sets the URL for an image of the item.

setName

Added in 1.1.0-alpha04
public @NonNullsetName(@Nullable String name)

Sets the name of the item.

setOriginalDurationMillis

Added in 1.1.0-alpha04
public @NonNullsetOriginalDurationMillis(long originalDurationMillis)

Sets the original duration in milliseconds when the Timer was first created.

setRemainingDurationMillis

Added in 1.1.0-alpha04
public @NonNullsetRemainingDurationMillis(long remainingDurationMillis)

Sets the amount of time remaining in milliseconds for the Timer relative to its setBaseTimeMillis.

The expire time of the Timer can be calculated using the sum of its base time and remaining time.

setRingtone

Added in 1.1.0-alpha04
public @NonNullsetRingtone(@Nullable String ringtone)

Sets the content URI for the ringtone to be played, or VALUE_RINGTONE_SILENT if no ringtone will be played.

setShouldVibrate

Added in 1.1.0-alpha04
public @NonNullsetShouldVibrate(boolean shouldVibrate)

Sets whether or not to activate the device vibrator when the Timer expires.

setStartTimeMillis

Added in 1.1.0-alpha04
public @NonNullsetStartTimeMillis(long startTimeMillis)

Sets the start time in milliseconds using the currentTimeMillis time base.

The start time is the first time that a new Timer, or a Timer that has been reset is started. Pausing and resuming should not change its start time.

setStatus

Added in 1.1.0-alpha04
public @NonNullsetStatus(int status)

Sets the current status.

Status can be STATUS_UNKNOWN, STATUS_STARTED, STATUS_PAUSED, STATUS_EXPIRED, STATUS_MISSED, or STATUS_RESET.

setUrl

Added in 1.1.0-alpha04
public @NonNullsetUrl(@Nullable String url)

Sets the deeplink URL of the item.

If this item can be displayed by any system UI surface, or can be read by another Android package, through one of the androidx.appsearch.app.SetSchemaRequest.Builder methods, this url should act as a deeplink into the activity that can open it. Callers should be able to construct an ACTION_VIEW intent with the url as the setData to view the item inside your application.

See Allowing Other Apps to Start Your Activity for more details on how to make activities in your app open for use by other apps by defining intent filters.