• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.google.android.tv.partner.support;
18 
19 import android.content.ContentValues;
20 import com.google.auto.value.AutoValue;
21 
22 /**
23  * Value class representing a TV Input that uses Live TV EPG.
24  *
25  * @see {@link EpgContract.EpgInputs}
26  */
27 @AutoValue
28 public abstract class EpgInput {
29 
createEpgChannel(long id, String inputId, String lineupId)30     public static EpgInput createEpgChannel(long id, String inputId, String lineupId) {
31         return new AutoValue_EpgInput(id, inputId, lineupId);
32     }
33 
createEpgChannel(ContentValues contentValues)34     public static EpgInput createEpgChannel(ContentValues contentValues) {
35         long id = contentValues.getAsLong(EpgContract.EpgInputs.COLUMN_ID);
36         String inputId = contentValues.getAsString(EpgContract.EpgInputs.COLUMN_INPUT_ID);
37         String lineupId = contentValues.getAsString(EpgContract.EpgInputs.COLUMN_LINEUP_ID);
38         return createEpgChannel(id, inputId, lineupId);
39     }
40 
41     /** The unique ID for a row. */
getId()42     public abstract long getId();
43 
44     /**
45      * The ID of the TV input service that provides this TV channel.
46      *
47      * <p>Use {@link android.media.tv.TvContract#buildInputId} to build the ID.
48      */
getInputId()49     public abstract String getInputId();
50 
51     /**
52      * The line up id.
53      *
54      * <p>This is a opaque string that should not be parsed.
55      */
getLineupId()56     public abstract String getLineupId();
57 
toContentValues()58     public final ContentValues toContentValues() {
59         ContentValues contentValues = new ContentValues();
60         contentValues.put(EpgContract.EpgInputs.COLUMN_ID, getId());
61         contentValues.put(EpgContract.EpgInputs.COLUMN_INPUT_ID, getInputId());
62         contentValues.put(EpgContract.EpgInputs.COLUMN_LINEUP_ID, getLineupId());
63         return contentValues;
64     }
65 }
66