WatchNextProgram


class WatchNextProgram


A convenience class to access WatchNextPrograms entries in the system content provider.

This class makes it easy to insert or retrieve a program from the system content provider, which is defined in TvContractCompat.

Usage example when inserting a "watch next" program:

WatchNextProgram watchNextProgram = new WatchNextProgram.Builder()
        .setWatchNextType(WatchNextPrograms.WATCH_NEXT_TYPE_CONTINUE)
        .setType(PreviewPrograms.TYPE_MOVIE)
        .setTitle("Program Title")
        .setDescription("Program Description")
        .setPosterArtUri(Uri.parse("http://example.com/poster_art.png"))
        // Set more attributes...
        .build();
Uri watchNextProgramUri = getContentResolver().insert(WatchNextPrograms.CONTENT_URI,
        watchNextProgram.toContentValues());

Usage example when retrieving a "watch next" program:

WatchNextProgram watchNextProgram;
try (Cursor cursor = resolver.query(watchNextProgramUri, null, null, null, null)) {
    if (cursor != null && cursor.getCount() != 0) {
        cursor.moveToNext();
        watchNextProgram = WatchNextProgram.fromCursor(cursor);
    }
}

Usage example when updating an existing "watch next" program:

WatchNextProgram updatedProgram = new WatchNextProgram.Builder(watchNextProgram)
        .setLastEngagementTimeUtcMillis(System.currentTimeMillis())
        .build();
getContentResolver().update(TvContractCompat.buildWatchNextProgramUri(updatedProgram.getId()),
        updatedProgram.toContentValues(), null, null);

Usage example when deleting a "watch next" program:

getContentResolver().delete(TvContractCompat.buildWatchNextProgramUri(existingProgram.getId()),
        null, null);

Summary

Nested types

This Builder class simplifies the creation of a WatchNextProgram object.

Constants

const Int

The unknown watch next type.

Public functions

Boolean
equals(other: Any!)
java-static WatchNextProgram!
fromCursor(cursor: Cursor!)

Creates a WatchNextProgram object from a cursor including the fields defined in WatchNextPrograms.

Long
Int
Boolean

Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes.

ContentValues!
String!

Constants

WATCH_NEXT_TYPE_UNKNOWN

Added in 1.1.0-alpha02
const val WATCH_NEXT_TYPE_UNKNOWN = -1: Int

The unknown watch next type. Use this type when the actual type is not known.

Public functions

equals

fun equals(other: Any!): Boolean

fromCursor

Added in 1.1.0-alpha02
java-static fun fromCursor(cursor: Cursor!): WatchNextProgram!

Creates a WatchNextProgram object from a cursor including the fields defined in WatchNextPrograms.

Parameters
cursor: Cursor!

A row from the TV Input Framework database.

Returns
WatchNextProgram!

A Program with the values taken from the cursor.

getLastEngagementTimeUtcMillis

Added in 1.1.0-alpha02
fun getLastEngagementTimeUtcMillis(): Long
Returns
Long

The value of COLUMN_LAST_ENGAGEMENT_TIME_UTC_MILLIS for the program.

getWatchNextType

Added in 1.1.0-alpha02
fun getWatchNextType(): Int
Returns
Int

The value of COLUMN_WATCH_NEXT_TYPE for the program, or WATCH_NEXT_TYPE_UNKNOWN if it's unknown.

hasAnyUpdatedValues

Added in 1.1.0-alpha02
fun hasAnyUpdatedValues(update: WatchNextProgram!): Boolean

Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes. An attribute is considered "set" if its key is present in the ContentValues vector.

toContentValues

Added in 1.1.0-alpha02
fun toContentValues(): ContentValues!
Returns
ContentValues!

The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database.

toString

fun toString(): String!