DvrDataManager.java revision ba5845f23b8fbc985890f892961abc8b39886611
1/* 2 * Copyright (C) 2015 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 17package com.android.tv.dvr; 18 19import android.support.annotation.MainThread; 20import android.support.annotation.Nullable; 21import android.util.Range; 22 23import java.util.List; 24 25/** 26 * Read only data manager. 27 */ 28@MainThread 29public interface DvrDataManager { 30 long NEXT_START_TIME_NOT_FOUND = -1; 31 32 boolean isInitialized(); 33 34 /** 35 * Returns recordings. 36 */ 37 List<Recording> getRecordings(); 38 39 /** 40 * Returns past recordings. 41 */ 42 List<Recording> getFinishedRecordings(); 43 44 /** 45 * Returns started recordings. 46 */ 47 List<Recording> getStartedRecordings(); 48 49 /** 50 * Returns scheduled recordings 51 */ 52 List<Recording> getScheduledRecordings(); 53 54 /** 55 * Returns season recordings. 56 */ 57 List<SeasonRecording> getSeasonRecordings(); 58 59 /** 60 * Returns the next start time after {@code time} or {@link #NEXT_START_TIME_NOT_FOUND} 61 * if none is found. 62 * 63 * @param time time milliseconds 64 */ 65 long getNextScheduledStartTimeAfter(long time); 66 67 /** 68 * Returns a list of all Recordings with a overlap with the given time period inclusive. 69 * 70 * <p> A recording overlaps with a period when 71 * {@code recording.getStartTime() <= period.getUpper() && 72 * recording.getEndTime() >= period.getLower()}. 73 * 74 * @param period a time period in milliseconds. 75 */ 76 List<Recording> getRecordingsThatOverlapWith(Range<Long> period); 77 78 /** 79 * Add a {@link Listener}. 80 */ 81 void addListener(Listener listener); 82 83 /** 84 * Remove a {@link Listener}. 85 */ 86 void removeListener(Listener listener); 87 88 /** 89 * Returns the recording with the given recordingId or null if is not found 90 */ 91 @Nullable 92 Recording getRecording(long recordingId); 93 94 interface Listener { 95 void onRecordingAdded(Recording recording); 96 void onRecordingRemoved(Recording recording); 97 void onRecordingStatusChanged(Recording recording); 98 } 99} 100