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 android.support.annotation.Nullable; 21 import java.util.ArrayList; 22 import java.util.Collections; 23 import java.util.List; 24 25 /** Value class for {@link com.google.android.tv.partner.support.EpgContract.Lineups} */ 26 // TODO(b/72052568): Get autovalue to work in aosp master 27 public abstract class Lineup { 28 /** Lineup type for cable. */ 29 public static final int LINEUP_CABLE = 0; 30 31 /** Lineup type for satelite. */ 32 public static final int LINEUP_SATELLITE = 1; 33 34 /** Lineup type for broadcast digital. */ 35 public static final int LINEUP_BROADCAST_DIGITAL = 2; 36 37 /** Lineup type for broadcast analog. */ 38 public static final int LINEUP_BROADCAST_ANALOG = 3; 39 40 /** Lineup type for IPTV. */ 41 public static final int LINEUP_IPTV = 4; 42 43 /** 44 * Indicates the lineup is either satellite, cable or IPTV but we are not sure which specific 45 * type. 46 */ 47 public static final int LINEUP_MVPD = 5; 48 49 /** Lineup type for Internet. */ 50 public static final int LINEUP_INTERNET = 6; 51 52 /** Lineup type for other. */ 53 public static final int LINEUP_OTHER = 7; 54 55 public static Lineup createLineup(String id, int type, String name, List<String> channels) { 56 return new AutoValue_Lineup( 57 id, type, name, Collections.unmodifiableList(new ArrayList<>(channels))); 58 } 59 60 public static Lineup createLineup(ContentValues contentValues) { 61 String id = contentValues.getAsString(EpgContract.Lineups.COLUMN_ID); 62 int type = contentValues.getAsInteger(EpgContract.Lineups.COLUMN_TYPE); 63 String name = contentValues.getAsString(EpgContract.Lineups.COLUMN_NAME); 64 String channels = contentValues.getAsString(EpgContract.Lineups.COLUMN_CHANNELS); 65 List<String> channelList = EpgContract.toChannelList(channels); 66 return new AutoValue_Lineup(id, type, name, Collections.unmodifiableList(channelList)); 67 } 68 69 /** The ID of this lineup. */ 70 public abstract String getId(); 71 72 /** The type associated with this lineup. */ 73 public abstract int getType(); 74 75 /** The human readable name associated with this lineup. */ 76 @Nullable 77 public abstract String getName(); 78 79 /** An unmodifiable list of channel numbers that this lineup has. */ 80 public abstract List<String> getChannels(); 81 } 82