aboutsummaryrefslogtreecommitdiff
path: root/partner_support/src/com/google/android/tv/partner/support/EpgInput.java
blob: 82cc463ae14a7cd3e9ffcd5a0b65f3c1dd280c50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.google.android.tv.partner.support;

import android.content.ContentValues;

/**
 * Value class representing a TV Input that uses Live TV EPG.
 *
 * @see {@link EpgContract.EpgInputs}
 */
// TODO(b/72052568): Get autovalue to work in aosp master
public abstract class EpgInput {

    public static EpgInput createEpgChannel(long id, String inputId, String lineupId) {
        return new AutoValue_EpgInput(id, inputId, lineupId);
    }

    public static EpgInput createEpgChannel(ContentValues contentValues) {
        long id = contentValues.getAsLong(EpgContract.EpgInputs.COLUMN_ID);
        String inputId = contentValues.getAsString(EpgContract.EpgInputs.COLUMN_INPUT_ID);
        String lineupId = contentValues.getAsString(EpgContract.EpgInputs.COLUMN_LINEUP_ID);
        return createEpgChannel(id, inputId, lineupId);
    }

    /** The unique ID for a row. */
    public abstract long getId();

    /**
     * The ID of the TV input service that provides this TV channel.
     *
     * <p>Use {@link android.media.tv.TvContract#buildInputId} to build the ID.
     */
    public abstract String getInputId();

    /**
     * The line up id.
     *
     * <p>This is a opaque string that should not be parsed.
     */
    public abstract String getLineupId();

    public final ContentValues toContentValues() {
        ContentValues contentValues = new ContentValues();
        contentValues.put(EpgContract.EpgInputs.COLUMN_ID, getId());
        contentValues.put(EpgContract.EpgInputs.COLUMN_INPUT_ID, getInputId());
        contentValues.put(EpgContract.EpgInputs.COLUMN_LINEUP_ID, getLineupId());
        return contentValues;
    }
}