WatchNextProgram
public final 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 |
|---|
public final class WatchNextProgram.BuilderThis Builder class simplifies the creation of a |
Constants |
|
|---|---|
static final @NonNull String[] |
The projection for a |
static final int |
The unknown watch next type. |
Public methods |
|
|---|---|
boolean |
|
static WatchNextProgram |
fromCursor(Cursor cursor)Creates a WatchNextProgram object from a cursor including the fields defined in |
long |
|
int |
|
boolean |
hasAnyUpdatedValues(WatchNextProgram update)Indicates whether some other WatchNextProgram has any set attribute that is different from this WatchNextProgram's respective attributes. |
ContentValues |
|
String |
toString() |
Constants
PROJECTION
public static final @NonNull String[] PROJECTION
The projection for a WatchNextProgram query.
This provides a array of strings containing the columns to be used in the query and in creating a Cursor object, which is used to iterate through the rows in the table.
WATCH_NEXT_TYPE_UNKNOWN
public static final int WATCH_NEXT_TYPE_UNKNOWN = -1
The unknown watch next type. Use this type when the actual type is not known.
Public methods
fromCursor
public static WatchNextProgram fromCursor(Cursor cursor)
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
public long getLastEngagementTimeUtcMillis()
| Returns | |
|---|---|
long |
The value of |
getWatchNextType
public int getWatchNextType()
| Returns | |
|---|---|
int |
The value of |
hasAnyUpdatedValues
public boolean hasAnyUpdatedValues(WatchNextProgram update)
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
public ContentValues toContentValues()
| Returns | |
|---|---|
ContentValues |
The fields of the Program in the ContentValues format to be easily inserted into the TV Input Framework database. |