当前位置: 首页>>代码示例>>Java>>正文


Java Programs类代码示例

本文整理汇总了Java中android.media.tv.TvContract.Programs的典型用法代码示例。如果您正苦于以下问题:Java Programs类的具体用法?Java Programs怎么用?Java Programs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Programs类属于android.media.tv.TvContract包,在下文中一共展示了Programs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * Starts the manager.
 */
public void start() {
    if (mStarted) {
        return;
    }
    mStarted = true;
    // Should be called directly instead of posting MSG_UPDATE_CURRENT_PROGRAMS message
    // to the handler. If not, another DB task can be executed before loading current programs.
    handleUpdateCurrentPrograms();
    if (mPrefetchEnabled) {
        mHandler.sendEmptyMessage(MSG_UPDATE_PREFETCH_PROGRAM);
    }
    mContentResolver.registerContentObserver(Programs.CONTENT_URI,
            true, mProgramObserver);
    if (mEpgFetcher != null && Experiments.CLOUD_EPG.get()) {
        mEpgFetcher.start();
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:21,代码来源:ProgramDataManager.java

示例2: getLastProgramEndTimeMillis

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
public static long getLastProgramEndTimeMillis(ContentResolver resolver, Uri channelUri) {
    Uri uri = TvContract.buildProgramsUriForChannel(channelUri);
    String[] projection = {Programs.COLUMN_END_TIME_UTC_MILLIS};
    Cursor cursor = null;
    try {
        // TvProvider returns programs chronological order by default.
        cursor = resolver.query(uri, projection, null, null, null);
        if (cursor == null || cursor.getCount() == 0) {
            return 0;
        }
        cursor.moveToLast();
        return cursor.getLong(0);
    } catch (Exception e) {
        Log.w(TAG, "Unable to get last program end time for " + channelUri, e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return 0;
}
 
开发者ID:Fleker,项目名称:ChannelSurfer,代码行数:22,代码来源:TvContractUtils.java

示例3: start

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * Starts the DB sync.
 */
public void start() {
    if (!mChannelDataManager.isDbLoadFinished()) {
        mChannelDataManager.addListener(mChannelDataManagerListener);
        return;
    }
    mContext.getContentResolver().registerContentObserver(Programs.CONTENT_URI, true,
            mContentObserver);
    mDataManager.addScheduledRecordingListener(mScheduleListener);
    onChannelsUpdated();
    onProgramsUpdated();
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:15,代码来源:DvrDbSync.java

示例4: onCreate

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    Bundle args = getArguments();
    if (args != null) {
        mSeriesRecording = args.getParcelable(SERIES_SCHEDULES_KEY_SERIES_RECORDING);
        mPrograms = args.getParcelableArrayList(SERIES_SCHEDULES_KEY_SERIES_PROGRAMS);
    }
    super.onCreate(savedInstanceState);
    ApplicationSingletons singletons = TvApplication.getSingletons(getContext());
    singletons.getDvrDataManager().addSeriesRecordingListener(mSeriesRecordingListener);
    mChannelDataManager = singletons.getChannelDataManager();
    mChannelDataManager.addListener(mChannelListener);
    getContext().getContentResolver().registerContentObserver(Programs.CONTENT_URI, true,
            mContentObserver);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:16,代码来源:DvrSeriesSchedulesFragment.java

示例5: queryPrograms

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
private List<Program> queryPrograms(long channelId, long startTimeMs, long endTimeMs) {
    try (Cursor c = mContext.getContentResolver().query(
            TvContract.buildProgramsUriForChannel(channelId, startTimeMs, endTimeMs),
            Program.PROJECTION, null, null, Programs.COLUMN_START_TIME_UTC_MILLIS)) {
        if (c == null) {
            return Collections.emptyList();
        }
        ArrayList<Program> programs = new ArrayList<>();
        while (c.moveToNext()) {
            programs.add(Program.fromCursor(c));
        }
        return programs;
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:15,代码来源:EpgFetcher.java

示例6: search

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * Search channels, inputs, or programs from TvProvider.
 * This assumes that parental control settings will not be change while searching.
 *
 * @param action One of {@link #ACTION_TYPE_SWITCH_CHANNEL}, {@link #ACTION_TYPE_SWITCH_INPUT},
 *               or {@link #ACTION_TYPE_AMBIGUOUS},
 */
@Override
@WorkerThread
public List<SearchResult> search(String query, int limit, int action) {
    List<SearchResult> results = new ArrayList<>();
    if (!PermissionUtils.hasAccessAllEpg(mContext)) {
        // TODO: support this feature for non-system LC app. b/23939816
        return results;
    }
    Set<Long> channelsFound = new HashSet<>();
    if (action == ACTION_TYPE_SWITCH_CHANNEL) {
        results.addAll(searchChannels(query, channelsFound, limit));
    } else if (action == ACTION_TYPE_SWITCH_INPUT) {
        results.addAll(searchInputs(query, limit));
    } else {
        // Search channels first.
        results.addAll(searchChannels(query, channelsFound, limit));
        if (results.size() >= limit) {
            return results;
        }

        // In case the user wanted to perform the action "switch to XXX", which is indicated by
        // setting the limit to 1, search inputs.
        if (limit == 1) {
            results.addAll(searchInputs(query, limit));
            if (!results.isEmpty()) {
                return results;
            }
        }

        // Lastly, search programs.
        limit -= results.size();
        results.addAll(searchPrograms(query, null, new String[] {
                Programs.COLUMN_TITLE, Programs.COLUMN_SHORT_DESCRIPTION },
                channelsFound, limit));
    }
    return results;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:45,代码来源:TvProviderSearch.java

示例7: fillProgramInfo

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * Replaces the channel information - title, description, channel logo - with the current
 * program information of the channel if the current program information exists and it is not
 * blocked.
 */
@WorkerThread
private void fillProgramInfo(SearchResult result) {
    long now = System.currentTimeMillis();
    Uri uri = TvContract.buildProgramsUriForChannel(result.channelId, now, now);
    String[] projection = new String[] {
            Programs.COLUMN_TITLE,
            Programs.COLUMN_POSTER_ART_URI,
            Programs.COLUMN_CONTENT_RATING,
            Programs.COLUMN_VIDEO_WIDTH,
            Programs.COLUMN_VIDEO_HEIGHT,
            Programs.COLUMN_START_TIME_UTC_MILLIS,
            Programs.COLUMN_END_TIME_UTC_MILLIS
    };

    try (Cursor c = mContentResolver.query(uri, projection, null, null, null)) {
        if (c != null && c.moveToNext() && !isRatingBlocked(c.getString(2))) {
            String channelName = result.title;
            long startUtcMillis = c.getLong(5);
            long endUtcMillis = c.getLong(6);
            result.title = c.getString(0);
            result.description = buildProgramDescription(result.channelNumber, channelName,
                    startUtcMillis, endUtcMillis);
            String imageUri = c.getString(1);
            if (imageUri != null) {
                result.imageUri = imageUri;
            }
            result.videoWidth = c.getInt(3);
            result.videoHeight = c.getInt(4);
            result.duration = endUtcMillis - startUtcMillis;
            result.progressPercentage = getProgressPercentage(startUtcMillis, endUtcMillis);
        }
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:39,代码来源:TvProviderSearch.java

示例8: getLastProgramEndTimeMs

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
private static long getLastProgramEndTimeMs(
        Context context, Uri channelUri, long startTimeMs, long endTimeMs) {
    Uri uri = TvContract.buildProgramsUriForChannel(channelUri, startTimeMs, endTimeMs);
    String[] projection = {Programs.COLUMN_END_TIME_UTC_MILLIS};
    try (Cursor cursor =
            context.getContentResolver().query(uri, projection, null, null, null)) {
        if (cursor != null && cursor.moveToLast()) {
            return cursor.getLong(0);
        }
    }
    return 0;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:13,代码来源:ProgramUtils.java

示例9: createSqlParams

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
private SqlParams createSqlParams() {
    SqlParams sqlParams = new SqlParams();
    if (PermissionUtils.hasAccessAllEpg(mContext)) {
        sqlParams.uri = Programs.CONTENT_URI;
        // Base
        StringBuilder selection = new StringBuilder(mLoadCurrentProgram
                ? PROGRAM_PREDICATE_WITH_CURRENT_PROGRAM : PROGRAM_PREDICATE);
        List<String> args = new ArrayList<>();
        args.add(Long.toString(System.currentTimeMillis()));
        // Channel option
        if (!mQueryAllChannels) {
            selection.append(" AND ").append(CHANNEL_ID_PREDICATE);
            args.add(Long.toString(mSeriesRecordings.get(0).getChannelId()));
        }
        // Title
        if (mSeriesRecordings.size() == 1) {
            selection.append(" AND ").append(PROGRAM_TITLE_PREDICATE);
            args.add(mSeriesRecordings.get(0).getTitle());
        }
        sqlParams.selection = selection.toString();
        sqlParams.selectionArgs = args.toArray(new String[args.size()]);
        sqlParams.filter = new SeriesRecordingCursorFilter(mSeriesRecordings);
    } else {
        // The query includes the current program. Will be filtered if needed.
        if (mQueryAllChannels) {
            sqlParams.uri = Programs.CONTENT_URI.buildUpon()
                    .appendQueryParameter(PARAM_START_TIME,
                            String.valueOf(System.currentTimeMillis()))
                    .appendQueryParameter(PARAM_END_TIME, String.valueOf(Long.MAX_VALUE))
                    .build();
        } else {
            sqlParams.uri = TvContract.buildProgramsUriForChannel(
                    mSeriesRecordings.get(0).getChannelId(),
                    System.currentTimeMillis(), Long.MAX_VALUE);
        }
        sqlParams.selection = null;
        sqlParams.selectionArgs = null;
        sqlParams.filter = new SeriesRecordingCursorFilterForNonSystem(mSeriesRecordings);
    }
    return sqlParams;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:42,代码来源:EpisodicProgramLoadTask.java

示例10: toContentValues

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
@SuppressLint("InlinedApi")
@SuppressWarnings("deprecation")
private static ContentValues toContentValues(Program program) {
    ContentValues values = new ContentValues();
    values.put(TvContract.Programs.COLUMN_CHANNEL_ID, program.getChannelId());
    putValue(values, TvContract.Programs.COLUMN_TITLE, program.getTitle());
    putValue(values, TvContract.Programs.COLUMN_EPISODE_TITLE, program.getEpisodeTitle());
    if (BuildCompat.isAtLeastN()) {
        putValue(values, TvContract.Programs.COLUMN_SEASON_DISPLAY_NUMBER,
                program.getSeasonNumber());
        putValue(values, TvContract.Programs.COLUMN_EPISODE_DISPLAY_NUMBER,
                program.getEpisodeNumber());
    } else {
        putValue(values, TvContract.Programs.COLUMN_SEASON_NUMBER, program.getSeasonNumber());
        putValue(values, TvContract.Programs.COLUMN_EPISODE_NUMBER, program.getEpisodeNumber());
    }
    putValue(values, TvContract.Programs.COLUMN_SHORT_DESCRIPTION, program.getDescription());
    putValue(values, TvContract.Programs.COLUMN_POSTER_ART_URI, program.getPosterArtUri());
    putValue(values, TvContract.Programs.COLUMN_THUMBNAIL_URI, program.getThumbnailUri());
    String[] canonicalGenres = program.getCanonicalGenres();
    if (canonicalGenres != null && canonicalGenres.length > 0) {
        putValue(values, TvContract.Programs.COLUMN_CANONICAL_GENRE,
                Genres.encode(canonicalGenres));
    } else {
        putValue(values, TvContract.Programs.COLUMN_CANONICAL_GENRE, "");
    }
    TvContentRating[] ratings = program.getContentRatings();
    if (ratings != null && ratings.length > 0) {
        StringBuilder sb = new StringBuilder(ratings[0].flattenToString());
        for (int i = 1; i < ratings.length; ++i) {
            sb.append(CONTENT_RATING_SEPARATOR);
            sb.append(ratings[i].flattenToString());
        }
        putValue(values, TvContract.Programs.COLUMN_CONTENT_RATING, sb.toString());
    } else {
        putValue(values, TvContract.Programs.COLUMN_CONTENT_RATING, "");
    }
    values.put(TvContract.Programs.COLUMN_START_TIME_UTC_MILLIS,
            program.getStartTimeUtcMillis());
    values.put(TvContract.Programs.COLUMN_END_TIME_UTC_MILLIS, program.getEndTimeUtcMillis());
    putValue(values, TvContract.Programs.COLUMN_INTERNAL_PROVIDER_DATA,
            InternalDataUtils.serializeInternalProviderData(program));
    return values;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:45,代码来源:EpgFetcher.java

示例11: ProgramsUpdateTask

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
public ProgramsUpdateTask(ContentResolver contentResolver, long time) {
    super(contentResolver, Programs.CONTENT_URI.buildUpon()
                    .appendQueryParameter(PARAM_START_TIME, String.valueOf(time))
                    .appendQueryParameter(PARAM_END_TIME, String.valueOf(time)).build(),
            Program.PROJECTION, null, null, SORT_BY_TIME);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:7,代码来源:ProgramDataManager.java

示例12: searchChannels

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
@WorkerThread
private List<SearchResult> searchChannels(String query, String[] columnForExactMatching,
        String[] columnForPartialMatching, Set<Long> channelsFound, int limit) {
    Assert.assertTrue(
            (columnForExactMatching != null && columnForExactMatching.length > 0) ||
            (columnForPartialMatching != null && columnForPartialMatching.length > 0));

    String[] projection = {
            Channels._ID,
            Channels.COLUMN_DISPLAY_NUMBER,
            Channels.COLUMN_DISPLAY_NAME,
            Channels.COLUMN_DESCRIPTION
    };

    StringBuilder sb = new StringBuilder();
    sb.append(Channels.COLUMN_BROWSABLE).append("=1 AND ")
            .append(Channels.COLUMN_SEARCHABLE).append("=1");
    if (mTvInputManager.isParentalControlsEnabled()) {
        sb.append(" AND ").append(Channels.COLUMN_LOCKED).append("=0");
    }
    sb.append(" AND (");
    appendSelectionString(sb, columnForExactMatching, columnForPartialMatching);
    sb.append(")");
    String selection = sb.toString();

    int len = (columnForExactMatching == null ? 0 : columnForExactMatching.length) +
            (columnForPartialMatching == null ? 0 : columnForPartialMatching.length);
    String[] selectionArgs = new String[len];
    insertSelectionArgumentStrings(selectionArgs, 0, query, columnForExactMatching,
            columnForPartialMatching);

    List<SearchResult> searchResults = new ArrayList<>();

    try (Cursor c = mContentResolver.query(Channels.CONTENT_URI, projection, selection,
            selectionArgs, null)) {
        if (c != null) {
            int count = 0;
            while (c.moveToNext()) {
                long id = c.getLong(0);
                // Filter out the channel which has been already searched.
                if (channelsFound.contains(id)) {
                    continue;
                }
                channelsFound.add(id);

                SearchResult result = new SearchResult();
                result.channelId = id;
                result.channelNumber = c.getString(1);
                result.title = c.getString(2);
                result.description = c.getString(3);
                result.imageUri = TvContract.buildChannelLogoUri(result.channelId).toString();
                result.intentAction = Intent.ACTION_VIEW;
                result.intentData = buildIntentData(result.channelId);
                result.contentType = Programs.CONTENT_ITEM_TYPE;
                result.isLive = true;
                result.progressPercentage = LocalSearchProvider.PROGRESS_PERCENTAGE_HIDE;

                searchResults.add(result);

                if (limit != NO_LIMIT && ++count >= limit) {
                    break;
                }
            }
        }
    }
    return searchResults;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:68,代码来源:TvProviderSearch.java

示例13: addResult

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * If query is matched to channel, {@code program} should be null.
 */
private void addResult(List<SearchResult> results, Set<Long> channelsFound, Channel channel,
        Program program) {
    if (program == null) {
        program = mProgramDataManager.getCurrentProgram(channel.getId());
        if (program != null && isRatingBlocked(program.getContentRatings())) {
            program = null;
        }
    }

    SearchResult result = new SearchResult();

    long channelId = channel.getId();
    result.channelId = channelId;
    result.channelNumber = channel.getDisplayNumber();
    if (program == null) {
        result.title = channel.getDisplayName();
        result.description = channel.getDescription();
        result.imageUri = TvContract.buildChannelLogoUri(channelId).toString();
        result.intentAction = Intent.ACTION_VIEW;
        result.intentData = buildIntentData(channelId);
        result.contentType = Programs.CONTENT_ITEM_TYPE;
        result.isLive = true;
        result.progressPercentage = LocalSearchProvider.PROGRESS_PERCENTAGE_HIDE;
    } else {
        result.title = program.getTitle();
        result.description = buildProgramDescription(channel.getDisplayNumber(),
                channel.getDisplayName(), program.getStartTimeUtcMillis(),
                program.getEndTimeUtcMillis());
        result.imageUri = program.getPosterArtUri();
        result.intentAction = Intent.ACTION_VIEW;
        result.intentData = buildIntentData(channelId);
        result.contentType = Programs.CONTENT_ITEM_TYPE;
        result.isLive = true;
        result.videoWidth = program.getVideoWidth();
        result.videoHeight = program.getVideoHeight();
        result.duration = program.getDurationMillis();
        result.progressPercentage = getProgressPercentage(
                program.getStartTimeUtcMillis(), program.getEndTimeUtcMillis());
    }
    if (DEBUG) {
        Log.d(TAG, "Add a result : channel=" + channel + " program=" + program);
    }
    results.add(result);
    channelsFound.add(channel.getId());
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:49,代码来源:DataManagerSearch.java

示例14: AsyncProgramQueryTask

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
public AsyncProgramQueryTask(ContentResolver contentResolver) {
    super(contentResolver, Programs.CONTENT_URI, Program.PROJECTION, null, null, null);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:4,代码来源:AsyncDbTask.java

示例15: populatePrograms

import android.media.tv.TvContract.Programs; //导入依赖的package包/类
/**
 * Populate programs by repeating given program information.
 * This method will populate programs without any gap nor overlapping
 * starting from the current time.
 */
public static void populatePrograms(Context context, Uri channelUri, ProgramInfo program) {
    ContentValues values = new ContentValues();
    long channelId = ContentUris.parseId(channelUri);

    values.put(Programs.COLUMN_CHANNEL_ID, channelId);
    values.put(Programs.COLUMN_SHORT_DESCRIPTION, program.description);
    values.put(Programs.COLUMN_CONTENT_RATING,
            TvContentRatingCache.contentRatingsToString(program.contentRatings));

    long currentTimeMs = System.currentTimeMillis();
    long targetEndTimeMs = currentTimeMs + PROGRAM_INSERT_DURATION_MS;
    long timeMs = getLastProgramEndTimeMs(context, channelUri, currentTimeMs, targetEndTimeMs);
    if (timeMs <= 0) {
        timeMs = currentTimeMs;
    }
    int index = program.getIndex(timeMs, channelId);
    timeMs = program.getStartTimeMs(index, channelId);

    ArrayList<ContentValues> list = new ArrayList<>();
    while (timeMs < targetEndTimeMs) {
        ProgramInfo programAt = program.build(context, index++);
        values.put(Programs.COLUMN_TITLE, programAt.title);
        values.put(Programs.COLUMN_EPISODE_TITLE, programAt.episode);
        if (programAt.seasonNumber != 0) {
            values.put(Programs.COLUMN_SEASON_NUMBER, programAt.seasonNumber);
        }
        if (programAt.episodeNumber != 0) {
            values.put(Programs.COLUMN_EPISODE_NUMBER, programAt.episodeNumber);
        }
        values.put(Programs.COLUMN_POSTER_ART_URI, programAt.posterArtUri);
        values.put(Programs.COLUMN_START_TIME_UTC_MILLIS, timeMs);
        values.put(Programs.COLUMN_END_TIME_UTC_MILLIS, timeMs + programAt.durationMs);
        values.put(Programs.COLUMN_CANONICAL_GENRE, programAt.genre);
        values.put(Programs.COLUMN_POSTER_ART_URI, programAt.posterArtUri);
        list.add(new ContentValues(values));
        timeMs += programAt.durationMs;

        if (list.size() >= MAX_DB_INSERT_COUNT_AT_ONCE
                || timeMs >= targetEndTimeMs) {
            try {
                context.getContentResolver().bulkInsert(Programs.CONTENT_URI,
                        list.toArray(new ContentValues[list.size()]));
            } catch (SQLiteException e) {
                Log.e(TAG, "Can't insert EPG.", e);
                return;
            }
            if (DEBUG) Log.d(TAG, "Inserted " + list.size() + " programs for " + channelUri);
            list.clear();
        }
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:57,代码来源:ProgramUtils.java


注:本文中的android.media.tv.TvContract.Programs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。