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


Java TvContract类代码示例

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


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

示例1: buildChannelMap

import android.media.tv.TvContract; //导入依赖的package包/类
public static LongSparseArray<XmlTvParser.XmlTvChannel> buildChannelMap(
        ContentResolver resolver, String inputId, List<XmlTvParser.XmlTvChannel> channels) {
    Uri uri = TvContract.buildChannelsUriForInput(inputId);
    String[] projection = {
            TvContract.Channels._ID,
            TvContract.Channels.COLUMN_DISPLAY_NUMBER
    };

    LongSparseArray<XmlTvParser.XmlTvChannel> channelMap = new LongSparseArray<>();
    try (Cursor cursor = resolver.query(uri, projection, null, null, null)) {
        if (cursor == null || cursor.getCount() == 0) {
            return null;
        }

        while (cursor.moveToNext()) {
            long channelId = cursor.getLong(0);
            String channelNumber = cursor.getString(1);
            channelMap.put(channelId, getChannelByNumber(channelNumber, channels));
        }
    } catch (Exception e) {
        Log.d(TAG, "Content provider query: " + Arrays.toString(e.getStackTrace()));
        return null;
    }
    return channelMap;
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:26,代码来源:TvContractUtils.java

示例2: getPrograms

import android.media.tv.TvContract; //导入依赖的package包/类
public static List<Program> getPrograms(ContentResolver resolver, Uri channelUri) {
    Uri uri = TvContract.buildProgramsUriForChannel(channelUri);
    List<Program> programs = new ArrayList<>();
    // TvProvider returns programs in chronological order by default.
    try (Cursor cursor = resolver.query(uri, null, null, null, null)) {
        if (cursor == null || cursor.getCount() == 0) {
            return programs;
        }
        while (cursor.moveToNext()) {
            programs.add(Program.fromCursor(cursor));
        }
    } catch (Exception e) {
        Log.w(TAG, "Unable to get programs for " + channelUri, e);
    }
    return programs;
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:17,代码来源:TvContractUtils.java

示例3: handleStartRecording

import android.media.tv.TvContract; //导入依赖的package包/类
private void handleStartRecording() {
    if (DEBUG) Log.d(TAG, "handleStartRecording " + mScheduledRecording);
    long programId = mScheduledRecording.getProgramId();
    mRecordingSession.startRecording(programId == ScheduledRecording.ID_NOT_SET ? null
            : TvContract.buildProgramUri(programId));
    updateRecordingState(ScheduledRecording.STATE_RECORDING_IN_PROGRESS);
    // If it starts late, it's clipped.
    if (mScheduledRecording.getStartTimeMs() + CLIPPED_THRESHOLD_MS
            < mClock.currentTimeMillis()) {
        mStartedWithClipping = true;
    }
    mState = State.RECORDING_STARTED;

    if (!sendEmptyMessageAtAbsoluteTime(MSG_STOP_RECORDING,
            mScheduledRecording.getEndTimeMs())) {
        failAndQuit();
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:19,代码来源:RecordingTask.java

示例4: doInBackground

import android.media.tv.TvContract; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
    @DvrStorageStatusManager.StorageStatus int storageStatus = getDvrStorageStatus();
    if (storageStatus == DvrStorageStatusManager.STORAGE_STATUS_MISSING) {
        return null;
    }
    List<ContentProviderOperation> ops = getDeleteOps(storageStatus
            == DvrStorageStatusManager.STORAGE_STATUS_TOTAL_CAPACITY_TOO_SMALL);
    if (ops == null || ops.isEmpty()) {
        return null;
    }
    Log.i(TAG, "New device storage mounted. # of recordings to be forgotten : "
            + ops.size());
    for (int i = 0 ; i < ops.size() && !isCancelled() ; i += BATCH_OPERATION_COUNT) {
        int toIndex = (i + BATCH_OPERATION_COUNT) > ops.size()
                ? ops.size() : (i + BATCH_OPERATION_COUNT);
        ArrayList<ContentProviderOperation> batchOps =
                new ArrayList<>(ops.subList(i, toIndex));
        try {
            mContext.getContentResolver().applyBatch(TvContract.AUTHORITY, batchOps);
        } catch (RemoteException | OperationApplicationException e) {
            Log.e(TAG, "Failed to clean up  RecordedPrograms.", e);
        }
    }
    return null;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:27,代码来源:DvrStorageStatusManager.java

示例5: setTitleAndImage

import android.media.tv.TvContract; //导入依赖的package包/类
private void setTitleAndImage(RecordingCardView cardView, ScheduledRecording recording) {
    Channel channel = mChannelDataManager.getChannel(recording.getChannelId());
    SpannableString title = recording.getProgramTitleWithEpisodeNumber(mContext) == null ?
            null : new SpannableString(recording.getProgramTitleWithEpisodeNumber(mContext));
    if (TextUtils.isEmpty(title)) {
        title = new SpannableString(channel != null ? channel.getDisplayName()
                : mContext.getResources().getString(R.string.no_program_information));
    } else {
        String programTitle = recording.getProgramTitle();
        title.setSpan(new TextAppearanceSpan(mContext,
                R.style.text_appearance_card_view_episode_number),
                programTitle == null ? 0 : programTitle.length(), title.length(),
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    String imageUri = recording.getProgramPosterArtUri();
    boolean isChannelLogo = false;
    if (TextUtils.isEmpty(imageUri)) {
        imageUri = channel != null ?
                TvContract.buildChannelLogoUri(channel.getId()).toString() : null;
        isChannelLogo = true;
    }
    cardView.setTitle(title);
    cardView.setImageUri(imageUri, isChannelLogo);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:25,代码来源:ScheduledRecordingPresenter.java

示例6: setImageUris

import android.media.tv.TvContract; //导入依赖的package包/类
/**
 * Sets background image and logo image URI and channel is used for fallback images.
 */
public Builder setImageUris(@Nullable String posterArtUri,
        @Nullable String thumbnailUri, @Nullable Channel channel) {
    mDetailsContent.mLogoImageUri = null;
    mDetailsContent.mBackgroundImageUri = null;
    if (!TextUtils.isEmpty(posterArtUri) && !TextUtils.isEmpty(thumbnailUri)) {
        mDetailsContent.mLogoImageUri = posterArtUri;
        mDetailsContent.mBackgroundImageUri = thumbnailUri;
    } else if (!TextUtils.isEmpty(posterArtUri)) {
        // thumbnailUri is empty
        mDetailsContent.mLogoImageUri = posterArtUri;
        mDetailsContent.mBackgroundImageUri = posterArtUri;
    } else if (!TextUtils.isEmpty(thumbnailUri)) {
        // posterArtUri is empty
        mDetailsContent.mLogoImageUri = thumbnailUri;
        mDetailsContent.mBackgroundImageUri = thumbnailUri;
    }
    if (TextUtils.isEmpty(mDetailsContent.mLogoImageUri) && channel != null) {
        String channelLogoUri = TvContract.buildChannelLogoUri(channel.getId())
                .toString();
        mDetailsContent.mLogoImageUri = channelLogoUri;
        mDetailsContent.mBackgroundImageUri = channelLogoUri;
    }
    return this;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:28,代码来源:DetailsContent.java

示例7: setupMediaSession

import android.media.tv.TvContract; //导入依赖的package包/类
private void setupMediaSession(RecordedProgram program) {
    mProgramDurationMs = program.getDurationMillis();
    String cardTitleText = program.getTitle();
    if (TextUtils.isEmpty(cardTitleText)) {
        Channel channel = mChannelDataManager.getChannel(program.getChannelId());
        cardTitleText = (channel != null) ? channel.getDisplayName()
                : mActivity.getString(R.string.no_program_information);
    }
    updateMediaMetadata(program.getId(), cardTitleText, program.getDescription(),
            mProgramDurationMs, null, 0);
    String posterArtUri = program.getPosterArtUri();
    if (posterArtUri == null) {
        posterArtUri = TvContract.buildChannelLogoUri(program.getChannelId()).toString();
    }
    updatePosterArt(program, cardTitleText, program.getDescription(),
            mProgramDurationMs, null, posterArtUri);
    mMediaSession.setActive(true);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:19,代码来源:DvrPlaybackMediaSessionHelper.java

示例8: onStart

import android.media.tv.TvContract; //导入依赖的package包/类
private void onStart() {
    if (!mStarted) {
        mStarted = true;
        mCancelLoadTask = false;
        if (!PermissionUtils.hasAccessWatchedHistory(mContext)) {
            mWatchedHistoryManager = new WatchedHistoryManager(mContext);
            mWatchedHistoryManager.setListener(this);
            mWatchedHistoryManager.start();
        } else {
            mContext.getContentResolver().registerContentObserver(
                    TvContract.WatchedPrograms.CONTENT_URI, true, mContentObserver);
            mHandler.obtainMessage(MSG_UPDATE_WATCH_HISTORY,
                    TvContract.WatchedPrograms.CONTENT_URI)
                    .sendToTarget();
        }
        mTvInputManager = (TvInputManager) mContext.getSystemService(Context.TV_INPUT_SERVICE);
        mTvInputManager.registerCallback(mInternalCallback, mHandler);
        for (TvInputInfo input : mTvInputManager.getTvInputList()) {
            mInputs.add(input.getId());
        }
    }
    if (mChannelRecordMapLoaded) {
        mHandler.sendEmptyMessage(MSG_NOTIFY_CHANNEL_RECORD_MAP_LOADED);
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:26,代码来源:RecommendationDataManager.java

示例9: updateOneColumnValue

import android.media.tv.TvContract; //导入依赖的package包/类
/**
 * Updates a column {@code columnName} of DB table {@code uri} with the value
 * {@code columnValue}. The selective rows in the ID list {@code ids} will be updated.
 * The DB operations will run on {@link AsyncDbTask#getExecutor()}.
 */
private void updateOneColumnValue(
        final String columnName, final int columnValue, final List<Long> ids) {
    if (!PermissionUtils.hasAccessAllEpg(mContext)) {
        // TODO: support this feature for non-system LC app. b/23939816
        return;
    }
    AsyncDbTask.execute(new Runnable() {
        @Override
        public void run() {
            String selection = Utils.buildSelectionForIds(Channels._ID, ids);
            ContentValues values = new ContentValues();
            values.put(columnName, columnValue);
            mContentResolver.update(TvContract.Channels.CONTENT_URI, values, selection, null);
        }
    });
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:22,代码来源:ChannelDataManager.java

示例10: onCreateView

import android.media.tv.TvContract; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    if (mSelectedPosition != INVALID_POSITION) {
        setSelectedPosition(mSelectedPosition);
    }
    VerticalGridView listView = (VerticalGridView) view.findViewById(R.id.side_panel_list);
    listView.setOnKeyInterceptListener(new OnRepeatedKeyInterceptListener(listView) {
        @Override
        public boolean onInterceptKeyEvent(KeyEvent event) {
            // In order to send tune operation once for continuous channel up/down events,
            // we only call the moveToChannel method on ACTION_UP event of channel switch keys.
            if (event.getAction() == KeyEvent.ACTION_UP) {
                switch (event.getKeyCode()) {
                    case KeyEvent.KEYCODE_DPAD_UP:
                    case KeyEvent.KEYCODE_DPAD_DOWN:
                        if (mLastFocusedChannelId != Channel.INVALID_ID) {
                            getMainActivity().tuneToChannel(
                                    getChannelDataManager().getChannel(mLastFocusedChannelId));
                        }
                        break;
                }
            }
            return super.onInterceptKeyEvent(event);
        }
    });
    getActivity().getContentResolver().registerContentObserver(TvContract.Programs.CONTENT_URI,
            true, mProgramUpdateObserver);
    getMainActivity().startShrunkenTvView(true, true);
    return view;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:33,代码来源:ChannelsBlockedFragment.java

示例11: SetupUtils

import android.media.tv.TvContract; //导入依赖的package包/类
private SetupUtils(TvApplication tvApplication) {
    mTvApplication = tvApplication;
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(tvApplication);
    mSetUpInputs = new ArraySet<>();
    mSetUpInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_SET_UP_INPUTS,
            Collections.emptySet()));
    mKnownInputs = new ArraySet<>();
    mKnownInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_KNOWN_INPUTS,
            Collections.emptySet()));
    mRecognizedInputs = new ArraySet<>();
    mRecognizedInputs.addAll(mSharedPreferences.getStringSet(PREF_KEY_RECOGNIZED_INPUTS,
            mKnownInputs));
    mIsFirstTune = mSharedPreferences.getBoolean(PREF_KEY_IS_FIRST_TUNE, true);
    mTunerInputId = TvContract.buildInputId(new ComponentName(tvApplication,
            TunerTvInputService.class));
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:17,代码来源:SetupUtils.java

示例12: grantEpgPermission

import android.media.tv.TvContract; //导入依赖的package包/类
/**
 * Grants permission for writing EPG data to a given package.
 *
 * @param context The Context used for granting permission.
 * @param packageName The name of the package to give permission.
 */
public static void grantEpgPermission(Context context, String packageName) {
    if (DEBUG) {
        Log.d(TAG, "grantEpgPermission(context=" + context + ", packageName=" + packageName
                + ")");
    }
    try {
        int modeFlags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PREFIX_URI_PERMISSION;
        context.grantUriPermission(packageName, TvContract.Channels.CONTENT_URI, modeFlags);
        context.grantUriPermission(packageName, TvContract.Programs.CONTENT_URI, modeFlags);
    } catch (SecurityException e) {
        Log.e(TAG, "Either TvProvider does not allow granting of Uri permissions or the app"
                + " does not have permission.", e);
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:22,代码来源:SetupUtils.java

示例13: getProgramAt

import android.media.tv.TvContract; //导入依赖的package包/类
/**
 * Gets the info of the program on particular time.
 */
@WorkerThread
public static Program getProgramAt(Context context, long channelId, long timeMs) {
    if (channelId == Channel.INVALID_ID) {
        Log.e(TAG, "getCurrentProgramAt - channelId is invalid");
        return null;
    }
    if (context.getMainLooper().getThread().equals(Thread.currentThread())) {
        String message = "getCurrentProgramAt called on main thread";
        if (DEBUG) {
            // Generating a stack trace can be expensive, only do it in debug mode.
            Log.w(TAG, message, new IllegalStateException(message));
        } else {
            Log.w(TAG, message);
        }
    }
    Uri uri = TvContract.buildProgramsUriForChannel(TvContract.buildChannelUri(channelId),
            timeMs, timeMs);
    try (Cursor cursor = context.getContentResolver().query(uri, Program.PROJECTION,
            null, null, null)) {
        if (cursor != null && cursor.moveToNext()) {
            return Program.fromCursor(cursor);
        }
    }
    return null;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:29,代码来源:Utils.java

示例14: getRecordedProgram

import android.media.tv.TvContract; //导入依赖的package包/类
private Program getRecordedProgram() {
    ContentResolver resolver = mContext.getContentResolver();
    Uri programUri = mProgramUri;
    if (mProgramUri == null) {
        long avg = mRecordStartTime / 2 + mRecordEndTime / 2;
        programUri = TvContract.buildProgramsUriForChannel(mChannel.getChannelId(), avg, avg);
    }
    try (Cursor c = resolver.query(programUri, Program.PROJECTION, null, null, SORT_BY_TIME)) {
        if (c != null) {
            Program result = Program.onQuery(c);
            if (DEBUG) {
                Log.v(TAG, "Finished query for " + this);
            }
            return result;
        } else {
            if (c == null) {
                Log.e(TAG, "Unknown query error for " + this);
            } else {
                if (DEBUG) Log.d(TAG, "Canceled query for " + this);
            }
            return null;
        }
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:25,代码来源:TunerRecordingSessionWorker.java

示例15: insertRecordedProgram

import android.media.tv.TvContract; //导入依赖的package包/类
private Uri insertRecordedProgram(Program program, long channelId, String storageUri,
        long totalBytes, long startTime, long endTime) {
    // TODO: Set title even though program is null.
    RecordedProgram recordedProgram = RecordedProgram.builder()
            .setInputId(mInputId)
            .setChannelId(channelId)
            .setDataUri(storageUri)
            .setDurationMillis(endTime - startTime)
            .setDataBytes(totalBytes)
            // startTime and endTime could be overridden by program's start and end value.
            .setStartTimeUtcMillis(startTime)
            .setEndTimeUtcMillis(endTime)
            .build();
    ContentValues values = RecordedProgram.toValues(recordedProgram);
    if (program != null) {
        values.putAll(program.buildValues());
    }
    return mContext.getContentResolver().insert(TvContract.RecordedPrograms.CONTENT_URI,
            values);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:21,代码来源:TunerRecordingSessionWorker.java


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