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.ContentResolver;
20 import android.content.ContentValues;
21 import android.database.Cursor;
22 import android.database.DatabaseUtils;
23 import java.util.HashSet;
24 import java.util.Set;
25 
26 /** Static utilities for {@link Lineup}. */
27 public final class Lineups {
28 
query(ContentResolver contentResolver, String postalCode)29     public static Set<Lineup> query(ContentResolver contentResolver, String postalCode) {
30         Set<Lineup> result = new HashSet<>();
31         try (Cursor cursor =
32                 contentResolver.query(
33                         EpgContract.Lineups.uriForPostalCode(postalCode), null, null, null, null)) {
34             ContentValues contentValues = new ContentValues();
35             while (cursor.moveToNext()) {
36                 contentValues.clear();
37                 DatabaseUtils.cursorRowToContentValues(cursor, contentValues);
38                 result.add(Lineup.createLineup(contentValues));
39             }
40             return result;
41         }
42     }
43 
Lineups()44     private Lineups() {}
45 }
46