Java 类android.media.tv.TvContentRating 实例源码
项目:android_packages_apps_tv
文件:ParentalControlSettings.java
public void setContentRatingSystemEnabled(ContentRatingsManager manager,
ContentRatingSystem contentRatingSystem, boolean enabled) {
if (enabled) {
TvSettings.addContentRatingSystem(mContext, contentRatingSystem.getId());
// Ensure newly added system has ratings for current level set
updateRatingsForCurrentLevel(manager);
} else {
// Ensure no ratings are blocked for the selected rating system
for (TvContentRating tvContentRating : mTvInputManager.getBlockedRatings()) {
if (contentRatingSystem.ownsRating(tvContentRating)) {
mTvInputManager.removeBlockedRating(tvContentRating);
}
}
TvSettings.removeContentRatingSystem(mContext, contentRatingSystem.getId());
}
}
项目:android_packages_apps_tv
文件:ParentalControlSettings.java
private boolean setRatingBlockedInternal(ContentRatingSystem contentRatingSystem, Rating rating,
SubRating subRating, boolean blocked) {
TvContentRating tvContentRating = (subRating == null)
? toTvContentRating(contentRatingSystem, rating)
: toTvContentRating(contentRatingSystem, rating, subRating);
boolean changed;
if (blocked) {
changed = mRatings.add(tvContentRating);
mTvInputManager.addBlockedRating(tvContentRating);
} else {
changed = mRatings.remove(tvContentRating);
mTvInputManager.removeBlockedRating(tvContentRating);
}
if (changed) {
changeToCustomLevel();
}
return changed;
}
项目:android_packages_apps_tv
文件:ContentRatingsManager.java
/**
* Returns the long name of a given content rating including descriptors (sub-ratings) that is
* displayed to the user. For example, "TV-PG (L, S)".
*/
public String getDisplayNameForRating(TvContentRating canonicalRating) {
Rating rating = getRating(canonicalRating);
if (rating == null) {
return null;
}
List<SubRating> subRatings = getSubRatings(rating, canonicalRating);
if (!subRatings.isEmpty()) {
StringBuilder builder = new StringBuilder();
for (SubRating subRating : subRatings) {
builder.append(subRating.getTitle());
builder.append(", ");
}
return rating.getTitle() + " (" + builder.substring(0, builder.length() - 2) + ")";
}
return rating.getTitle();
}
项目:android_packages_apps_tv
文件:ContentRatingsManager.java
private Rating getRating(TvContentRating canonicalRating) {
if (canonicalRating == null || mContentRatingSystems == null) {
return null;
}
for (ContentRatingSystem system : mContentRatingSystems) {
if (system.getDomain().equals(canonicalRating.getDomain())
&& system.getName().equals(canonicalRating.getRatingSystem())) {
for (Rating rating : system.getRatings()) {
if (rating.getName().equals(canonicalRating.getMainRating())) {
return rating;
}
}
}
}
return null;
}
项目:android_packages_apps_tv
文件:ContentRatingsManager.java
private List<SubRating> getSubRatings(Rating rating, TvContentRating canonicalRating) {
List<SubRating> subRatings = new ArrayList<>();
if (rating == null || rating.getSubRatings() == null
|| canonicalRating == null || canonicalRating.getSubRatings() == null) {
return subRatings;
}
for (String subRatingString : canonicalRating.getSubRatings()) {
for (SubRating subRating : rating.getSubRatings()) {
if (subRating.getName().equals(subRatingString)) {
subRatings.add(subRating);
break;
}
}
}
return subRatings;
}
项目:android_packages_apps_tv
文件:DataManagerSearch.java
private boolean isRatingBlocked(TvContentRating[] ratings) {
if (ratings == null || ratings.length == 0
|| !mTvInputManager.isParentalControlsEnabled()) {
return false;
}
for (TvContentRating rating : ratings) {
try {
if (mTvInputManager.isRatingBlocked(rating)) {
return true;
}
} catch (IllegalArgumentException e) {
// Do nothing.
}
}
return false;
}
项目:android_packages_apps_tv
文件:MainActivity.java
@Override
public void onContentBlocked() {
mTuneDurationTimer.reset();
TvContentRating rating = mTvView.getBlockedContentRating();
// When tuneTo was called while TV view was shrunken, if the channel id is the same
// with the channel watched before shrunken, we allow the rating which was allowed
// before.
if (mWasUnderShrunkenTvView && mUnlockAllowedRatingBeforeShrunken
&& mChannelBeforeShrunkenTvView.equals(mChannel)
&& rating.equals(mAllowedRatingBeforeShrunken)) {
mUnlockAllowedRatingBeforeShrunken = isUnderShrunkenTvView();
mTvView.unblockContent(rating);
}
mChannelBannerView.setBlockingContentRating(rating);
updateChannelBannerAndShowIfNeeded(UPDATE_CHANNEL_BANNER_REASON_LOCK_OR_UNLOCK);
mTvViewUiManager.fadeInTvView();
}
项目:android_packages_apps_tv
文件:ChannelBannerView.java
private void updateProgramRatings(Program program) {
if (mBlockingContentRating != null) {
mContentRatingsTextViews[0].setText(
mContentRatingsManager.getDisplayNameForRating(mBlockingContentRating));
mContentRatingsTextViews[0].setVisibility(View.VISIBLE);
for (int i = 1; i < DISPLAYED_CONTENT_RATINGS_COUNT; i++) {
mContentRatingsTextViews[i].setVisibility(View.GONE);
}
return;
}
TvContentRating[] ratings = (program == null) ? null : program.getContentRatings();
for (int i = 0; i < DISPLAYED_CONTENT_RATINGS_COUNT; i++) {
if (ratings == null || ratings.length <= i) {
mContentRatingsTextViews[i].setVisibility(View.GONE);
} else {
mContentRatingsTextViews[i].setText(
mContentRatingsManager.getDisplayNameForRating(ratings[i]));
mContentRatingsTextViews[i].setVisibility(View.VISIBLE);
}
}
}
项目:android_packages_apps_tv
文件:TunerSessionWorker.java
private void doParentalControls() {
boolean isParentalControlsEnabled = mTvInputManager.isParentalControlsEnabled();
if (isParentalControlsEnabled) {
TvContentRating blockContentRating = getContentRatingOfCurrentProgramBlocked();
if (DEBUG) {
if (blockContentRating != null) {
Log.d(TAG, "Check parental controls: blocked by content rating - "
+ blockContentRating);
} else {
Log.d(TAG, "Check parental controls: available");
}
}
updateChannelBlockStatus(blockContentRating != null, blockContentRating);
} else {
if (DEBUG) {
Log.d(TAG, "Check parental controls: available");
}
updateChannelBlockStatus(false, null);
}
}
项目:android_packages_apps_tv
文件:TunerSessionWorker.java
private TvContentRating getContentRatingOfCurrentProgramBlocked() {
EitItem currentProgram = getCurrentProgram();
if (currentProgram == null) {
return null;
}
TvContentRating[] ratings = mTvContentRatingCache
.getRatings(currentProgram.getContentRating());
if (ratings == null) {
return null;
}
for (TvContentRating rating : ratings) {
if (!Objects.equals(mUnblockedContentRating, rating) && mTvInputManager
.isRatingBlocked(rating)) {
return rating;
}
}
return null;
}
项目:android_packages_apps_tv
文件:TunerSessionWorker.java
private void updateChannelBlockStatus(boolean channelBlocked,
TvContentRating contentRating) {
if (mChannelBlocked == channelBlocked) {
return;
}
mChannelBlocked = channelBlocked;
if (mChannelBlocked) {
mHandler.removeCallbacksAndMessages(null);
stopPlayback();
resetTvTracks();
if (contentRating != null) {
mSession.notifyContentBlocked(contentRating);
}
mHandler.sendEmptyMessageDelayed(MSG_PARENTAL_CONTROLS, PARENTAL_CONTROLS_INTERVAL_MS);
} else {
mHandler.removeCallbacksAndMessages(null);
resetPlayback();
mSession.notifyContentAllowed();
mHandler.sendEmptyMessageDelayed(MSG_RESCHEDULE_PROGRAMS,
RESCHEDULE_PROGRAMS_INITIAL_DELAY_MS);
mHandler.removeMessages(MSG_CHECK_SIGNAL);
mHandler.sendEmptyMessageDelayed(MSG_CHECK_SIGNAL, CHECK_NO_SIGNAL_INITIAL_DELAY_MS);
}
}
项目:android_packages_apps_tv
文件:TvContentRatingCache.java
/**
* Returns an array TvContentRatings from a string of comma separated set of rating strings
* creating each from {@link TvContentRating#unflattenFromString(String)} if needed.
* Returns {@code null} if the string is empty or contains no valid ratings.
*/
@Nullable
public TvContentRating[] getRatings(String commaSeparatedRatings) {
if (TextUtils.isEmpty(commaSeparatedRatings)) {
return null;
}
TvContentRating[] tvContentRatings;
if (mRatingsMultiMap.containsKey(commaSeparatedRatings)) {
tvContentRatings = mRatingsMultiMap.get(commaSeparatedRatings);
} else {
String normalizedRatings = TextUtils
.join(",", getSortedSetFromCsv(commaSeparatedRatings));
if (mRatingsMultiMap.containsKey(normalizedRatings)) {
tvContentRatings = mRatingsMultiMap.get(normalizedRatings);
} else {
tvContentRatings = stringToContentRatings(commaSeparatedRatings);
mRatingsMultiMap.put(normalizedRatings, tvContentRatings);
}
if (!normalizedRatings.equals(commaSeparatedRatings)) {
// Add an entry so the non normalized entry points to the same result;
mRatingsMultiMap.put(commaSeparatedRatings, tvContentRatings);
}
}
return tvContentRatings;
}
项目:android_packages_apps_tv
文件:TvContentRatingCache.java
/**
* Returns a sorted array of TvContentRatings from a comma separated string of ratings.
*/
@VisibleForTesting
static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) {
if (TextUtils.isEmpty(commaSeparatedRatings)) {
return null;
}
Set<String> ratingStrings = getSortedSetFromCsv(commaSeparatedRatings);
List<TvContentRating> contentRatings = new ArrayList<>();
for (String rating : ratingStrings) {
try {
contentRatings.add(TvContentRating.unflattenFromString(rating));
} catch (IllegalArgumentException e) {
Log.e(TAG, "Can't parse the content rating: '" + rating + "'", e);
}
}
return contentRatings.size() == 0 ?
null : contentRatings.toArray(new TvContentRating[contentRatings.size()]);
}
项目:ChannelSurfer
文件:TvInputProvider.java
/**
* If you don't have access to an EPG or don't want to supply programs, you can simply
* add several instances of this generic program object.
*
* Note you will have to set the start and end times manually.
* @param channel The channel for which the program will be displayed
* @return A very generic program object
*/
public Program getGenericProgram(Channel channel) {
TvContentRating rating = RATING_PG;
return new Program.Builder()
.setTitle(channel.getName() + " Live")
.setProgramId(channel.getServiceId())
// .setEpisodeNumber(1)
// .setSeasonNumber(1)
// .setEpisodeTitle("Streaming")
.setDescription("Currently streaming")
.setLongDescription(channel.getName() + " is currently streaming live.")
.setCanonicalGenres(new String[]{TvContract.Programs.Genres.ENTERTAINMENT})
.setThumbnailUri(channel.getLogoUrl())
.setPosterArtUri(channel.getLogoUrl())
.setInternalProviderData(channel.getName())
.setContentRatings(new TvContentRating[] {rating})
.setVideoHeight(1080)
.setVideoWidth(1920)
.build();
}
项目:androidtv-sample
文件:XmlTvParser.java
public static TvContentRating[] xmlTvRatingToTvContentRating(
XmlTvParser.XmlTvRating[] ratings) {
List<TvContentRating> list = new ArrayList<>();
for (XmlTvParser.XmlTvRating rating : ratings) {
if (ANDROID_TV_RATING.equals(rating.system)) {
list.add(TvContentRating.unflattenFromString(rating.value));
}
}
return list.toArray(new TvContentRating[list.size()]);
}
项目:androidtv-sample
文件:TvContractUtils.java
public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) {
if (TextUtils.isEmpty(commaSeparatedRatings)) {
return null;
}
String[] ratings = commaSeparatedRatings.split("\\s*,\\s*");
TvContentRating[] contentRatings = new TvContentRating[ratings.length];
for (int i = 0; i < contentRatings.length; ++i) {
contentRatings[i] = TvContentRating.unflattenFromString(ratings[i]);
}
return contentRatings;
}
项目:androidtv-sample
文件:TvContractUtils.java
public static String contentRatingsToString(TvContentRating[] contentRatings) {
if (contentRatings == null || contentRatings.length == 0) {
return null;
}
final String DELIMITER = ",";
StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString());
for (int i = 1; i < contentRatings.length; ++i) {
ratings.append(DELIMITER);
ratings.append(contentRatings[i].flattenToString());
}
return ratings.toString();
}
项目:androidtv-sample
文件:RichTvInputService.java
private void unblockContent(TvContentRating rating) {
// TIS should unblock content only if unblock request is legitimate.
if (rating == null || mLastBlockedRating == null || rating.equals(mLastBlockedRating)) {
mLastBlockedRating = null;
if (rating != null) {
mUnblockedRatingSet.add(rating);
}
if (mPlayer == null && mCurrentProgram != null) {
playProgram(mCurrentProgram);
}
notifyContentAllowed();
}
}
项目:android_packages_apps_tv
文件:ParentalControlSettings.java
/**
* Checks whether any of given ratings is blocked and returns the first blocked rating.
*
* @param ratings The array of ratings to check
* @return The {@link TvContentRating} that is blocked.
*/
public TvContentRating getBlockedRating(TvContentRating[] ratings) {
if (ratings == null) {
return null;
}
for (TvContentRating rating : ratings) {
if (mTvInputManager.isRatingBlocked(rating)) {
return rating;
}
}
return null;
}
项目:android_packages_apps_tv
文件:ContentRatingLevelPolicy.java
public static Set<TvContentRating> getRatingsForLevel(
ParentalControlSettings settings, ContentRatingsManager manager,
@ContentRatingLevel int level) {
if (level == TvSettings.CONTENT_RATING_LEVEL_NONE) {
return new HashSet<>();
} else if (level == TvSettings.CONTENT_RATING_LEVEL_HIGH) {
return getRatingsForAge(settings, manager, AGE_THRESHOLD_FOR_LEVEL_HIGH);
} else if (level == TvSettings.CONTENT_RATING_LEVEL_MEDIUM) {
return getRatingsForAge(settings, manager, AGE_THRESHOLD_FOR_LEVEL_MEDIUM);
} else if (level == TvSettings.CONTENT_RATING_LEVEL_LOW) {
return getRatingsForAge(settings, manager, AGE_THRESHOLD_FOR_LEVEL_LOW);
}
throw new IllegalArgumentException("Unexpected rating level");
}
项目:android_packages_apps_tv
文件:ContentRatingLevelPolicy.java
private static Set<TvContentRating> getRatingsForAge(
ParentalControlSettings settings, ContentRatingsManager manager, int age) {
Set<TvContentRating> ratings = new HashSet<>();
for (ContentRatingSystem contentRatingSystem : manager.getContentRatingSystems()) {
if (!settings.isContentRatingSystemEnabled(contentRatingSystem)) {
continue;
}
int ageLimit = age;
if (ageLimit == AGE_THRESHOLD_FOR_LEVEL_LOW) {
ageLimit = getMaxAge(contentRatingSystem);
}
for (Rating rating : contentRatingSystem.getRatings()) {
if (rating.getAgeHint() < ageLimit) {
continue;
}
TvContentRating tvContentRating = TvContentRating.createRating(
contentRatingSystem.getDomain(), contentRatingSystem.getName(),
rating.getName());
ratings.add(tvContentRating);
for (SubRating subRating : rating.getSubRatings()) {
tvContentRating = TvContentRating.createRating(
contentRatingSystem.getDomain(), contentRatingSystem.getName(),
rating.getName(), subRating.getName());
ratings.add(tvContentRating);
}
}
}
return ratings;
}
项目:android_packages_apps_tv
文件:ProgramTableAdapter.java
private TvContentRating getProgramBlock(Program program) {
ParentalControlSettings parental = mTvInputManagerHelper.getParentalControlSettings();
if (!parental.isParentalControlsEnabled()) {
return null;
}
return parental.getBlockedRating(program.getContentRatings());
}
项目:android_packages_apps_tv
文件:ProgramTableAdapter.java
private String getBlockedDescription(TvContentRating blockedRating) {
String name = mTvInputManagerHelper.getContentRatingsManager()
.getDisplayNameForRating(blockedRating);
if (TextUtils.isEmpty(name)) {
return mContext.getString(R.string.program_guide_content_locked);
} else {
return mContext.getString(R.string.program_guide_content_locked_format, name);
}
}
项目:android_packages_apps_tv
文件:DvrDetailsFragment.java
protected void startPlayback(RecordedProgram recordedProgram, long seekTimeMs) {
if (Utils.isInBundledPackageSet(recordedProgram.getPackageName()) &&
!isDataUriAccessible(recordedProgram.getDataUri())) {
// Since cleaning RecordedProgram from forgotten storage will take some time,
// ignore playback until cleaning is finished.
ToastUtils.show(getContext(),
getContext().getResources().getString(R.string.dvr_toast_recording_deleted),
Toast.LENGTH_SHORT);
return;
}
ParentalControlSettings parental = TvApplication.getSingletons(getActivity())
.getTvInputManagerHelper().getParentalControlSettings();
if (!parental.isParentalControlsEnabled()) {
launchPlaybackActivity(recordedProgram, seekTimeMs, false);
return;
}
ChannelDataManager channelDataManager =
TvApplication.getSingletons(getActivity()).getChannelDataManager();
Channel channel = channelDataManager.getChannel(recordedProgram.getChannelId());
if (channel != null && channel.isLocked()) {
checkPinToPlay(recordedProgram, seekTimeMs);
return;
}
String ratingString = recordedProgram.getContentRating();
if (TextUtils.isEmpty(ratingString)) {
launchPlaybackActivity(recordedProgram, seekTimeMs, false);
return;
}
String[] ratingList = ratingString.split(",");
TvContentRating[] programRatings = new TvContentRating[ratingList.length];
for (int i = 0; i < ratingList.length; i++) {
programRatings[i] = TvContentRating.unflattenFromString(ratingList[i]);
}
TvContentRating blockRatings = parental.getBlockedRating(programRatings);
if (blockRatings != null) {
checkPinToPlay(recordedProgram, seekTimeMs);
} else {
launchPlaybackActivity(recordedProgram, seekTimeMs, false);
}
}
项目:android_packages_apps_tv
文件:Program.java
public static Program fromParcel(Parcel in) {
Program program = new Program();
program.mId = in.readLong();
program.mPackageName = in.readString();
program.mChannelId = in.readLong();
program.mTitle = in.readString();
program.mSeriesId = in.readString();
program.mEpisodeTitle = in.readString();
program.mSeasonNumber = in.readString();
program.mSeasonTitle = in.readString();
program.mEpisodeNumber = in.readString();
program.mStartTimeUtcMillis = in.readLong();
program.mEndTimeUtcMillis = in.readLong();
program.mDescription = in.readString();
program.mLongDescription = in.readString();
program.mVideoWidth = in.readInt();
program.mVideoHeight = in.readInt();
program.mCriticScores = in.readArrayList(Thread.currentThread().getContextClassLoader());
program.mPosterArtUri = in.readString();
program.mThumbnailUri = in.readString();
program.mCanonicalGenreIds = in.createIntArray();
int length = in.readInt();
if (length > 0) {
program.mContentRatings = new TvContentRating[length];
for (int i = 0; i < length; ++i) {
program.mContentRatings[i] = TvContentRating.unflattenFromString(in.readString());
}
}
program.mRecordingProhibited = in.readByte() != (byte) 0;
return program;
}
项目:android_packages_apps_tv
文件:Program.java
@Override
public void writeToParcel(Parcel out, int paramInt) {
out.writeLong(mId);
out.writeString(mPackageName);
out.writeLong(mChannelId);
out.writeString(mTitle);
out.writeString(mSeriesId);
out.writeString(mEpisodeTitle);
out.writeString(mSeasonNumber);
out.writeString(mSeasonTitle);
out.writeString(mEpisodeNumber);
out.writeLong(mStartTimeUtcMillis);
out.writeLong(mEndTimeUtcMillis);
out.writeString(mDescription);
out.writeString(mLongDescription);
out.writeInt(mVideoWidth);
out.writeInt(mVideoHeight);
out.writeList(mCriticScores);
out.writeString(mPosterArtUri);
out.writeString(mThumbnailUri);
out.writeIntArray(mCanonicalGenreIds);
out.writeInt(mContentRatings == null ? 0 : mContentRatings.length);
if (mContentRatings != null) {
for (TvContentRating rating : mContentRatings) {
out.writeString(rating.flattenToString());
}
}
out.writeByte((byte) (mRecordingProhibited ? 1 : 0));
}
项目:android_packages_apps_tv
文件:TvProviderSearch.java
private boolean isRatingBlocked(String ratings) {
if (TextUtils.isEmpty(ratings) || !mTvInputManager.isParentalControlsEnabled()) {
return false;
}
TvContentRating[] ratingArray = mTvContentRatingCache.getRatings(ratings);
if (ratingArray != null) {
for (TvContentRating r : ratingArray) {
if (mTvInputManager.isRatingBlocked(r)) {
return true;
}
}
}
return false;
}
项目:android_packages_apps_tv
文件:TunableTvView.java
@Override
public void onContentBlocked(String inputId, TvContentRating rating) {
blockScreenByContentRating(rating);
if (mOnTuneListener != null) {
mOnTuneListener.onContentBlocked();
}
}
项目:android_packages_apps_tv
文件:SectionParser.java
private static String generateContentRating(List<TsDescriptor> descriptors) {
List<String> contentRatings = new ArrayList<>();
for (TsDescriptor descriptor : descriptors) {
if (descriptor instanceof ContentAdvisoryDescriptor) {
ContentAdvisoryDescriptor contentAdvisoryDescriptor =
(ContentAdvisoryDescriptor) descriptor;
for (RatingRegion ratingRegion : contentAdvisoryDescriptor.getRatingRegions()) {
for (RegionalRating index : ratingRegion.getRegionalRatings()) {
String ratingSystem = null;
String rating = null;
switch (ratingRegion.getName()) {
case RATING_REGION_US_TV:
ratingSystem = RATING_REGION_RATING_SYSTEM_US_TV;
if (index.getDimension() == 0 && index.getRating() >= 0
&& index.getRating() < RATING_REGION_TABLE_US_TV.length) {
rating = RATING_REGION_TABLE_US_TV[index.getRating()];
}
break;
case RATING_REGION_KR_TV:
ratingSystem = RATING_REGION_RATING_SYSTEM_KR_TV;
if (index.getDimension() == 0 && index.getRating() >= 0
&& index.getRating() < RATING_REGION_TABLE_KR_TV.length) {
rating = RATING_REGION_TABLE_KR_TV[index.getRating()];
}
break;
default:
break;
}
if (ratingSystem != null && rating != null) {
contentRatings.add(TvContentRating
.createRating("com.android.tv", ratingSystem, rating)
.flattenToString());
}
}
}
}
}
return TextUtils.join(",", contentRatings);
}
项目:android_packages_apps_tv
文件:TvContentRatingCacheTest.java
public void testStringToContentRatings_double() {
TvContentRating[] results = TvContentRatingCache.stringToContentRatings(
TvContentRatingConstants.STRING_US_TV_MA + ","
+ TvContentRatingConstants.STRING_US_TV_MA);
MoreAsserts
.assertEquals("ratings", asArray(TvContentRatingConstants.CONTENT_RATING_US_TV_MA),
results);
}
项目:android_packages_apps_tv
文件:ProgramInfo.java
public ProgramInfo(String title, String episode, int seasonNumber, int episodeNumber,
String posterArtUri, String description, long durationMs,
TvContentRating[] contentRatings, String genre, String resourceUri) {
this.title = title;
this.episode = episode;
this.seasonNumber = seasonNumber;
this.episodeNumber = episodeNumber;
this.posterArtUri = posterArtUri;
this.description = description;
this.durationMs = durationMs;
this.contentRatings = contentRatings;
this.genre = genre;
this.resourceUri = resourceUri;
}
项目:android_packages_apps_tv
文件:TvContentRatingCache.java
/**
* Returns a string of each flattened content rating, sorted and concatenated together
* with a comma.
*/
public static String contentRatingsToString(TvContentRating[] contentRatings) {
if (contentRatings == null || contentRatings.length == 0) {
return null;
}
String[] ratingStrings = new String[contentRatings.length];
for (int i = 0; i < contentRatings.length; i++) {
ratingStrings[i] = contentRatings[i].flattenToString();
}
if (ratingStrings.length == 1) {
return ratingStrings[0];
} else {
return TextUtils.join(",", toSortedSet(ratingStrings));
}
}
项目:ChannelSurfer
文件:TvContractUtils.java
public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) {
if (TextUtils.isEmpty(commaSeparatedRatings)) {
return null;
}
String[] ratings = commaSeparatedRatings.split("\\s*,\\s*");
TvContentRating[] contentRatings = new TvContentRating[ratings.length];
for (int i = 0; i < contentRatings.length; ++i) {
contentRatings[i] = TvContentRating.unflattenFromString(ratings[i]);
}
return contentRatings;
}
项目:ChannelSurfer
文件:TvContractUtils.java
public static String contentRatingsToString(TvContentRating[] contentRatings) {
if (contentRatings == null || contentRatings.length == 0) {
return null;
}
final String DELIMITER = ",";
StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString());
for (int i = 1; i < contentRatings.length; ++i) {
ratings.append(DELIMITER);
ratings.append(contentRatings[i].flattenToString());
}
return ratings.toString();
}
项目:ChannelSurfer
文件:SimpleSessionImpl.java
@Override
public void onUnblockContent(TvContentRating unblockedRating) {
super.onUnblockContent(unblockedRating);
if(tvInputProvider.getApplicationContext().getResources().getBoolean(R.bool.channel_surfer_lifecycle_toasts))
Toast.makeText(tvInputProvider.getApplicationContext(), "Unblocked "+unblockedRating.flattenToString(), Toast.LENGTH_SHORT).show();
notifyContentAllowed();
}
项目:iWediaSimpleTvInputService
文件:EpgProgram.java
private String contentRatingsToString(TvContentRating[] contentRatings) {
if (contentRatings == null || contentRatings.length == 0) {
return null;
}
final String DELIMITER = ",";
StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString());
for (int i = 1; i < contentRatings.length; ++i) {
ratings.append(DELIMITER);
ratings.append(contentRatings[i].flattenToString());
}
return ratings.toString();
}
项目:iWediaSimpleTvInputService
文件:TvSession.java
@Override
public void onUnblockContent(TvContentRating rating) {
mLog.d("[onUnblockContent][rating: " + rating + "]");
if (mCurrentChannel != null && mContentIsBlocked) {
mContentIsBlocked = false;
startPlayback();
}
}
项目:CumulusTV
文件:CumulusXmlParser.java
/**
* Converts a TV ratings from an XML file to {@link TvContentRating}.
*
* @param rating An XmlTvRating.
* @return A TvContentRating.
*/
private static TvContentRating xmlTvRatingToTvContentRating(
CumulusXmlParser.XmlTvRating rating) {
if (ANDROID_TV_RATING.equals(rating.system)) {
return TvContentRating.unflattenFromString(rating.value);
}
return null;
}
项目:androidtv-sample-inputs
文件:TvContractUtils.java
/**
* Parses a string of comma-separated ratings into an array of {@link TvContentRating}.
*
* @param commaSeparatedRatings String containing various ratings, separated by commas.
* @return An array of TvContentRatings.
* @hide
*/
public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) {
if (TextUtils.isEmpty(commaSeparatedRatings)) {
return null;
}
String[] ratings = commaSeparatedRatings.split("\\s*,\\s*");
TvContentRating[] contentRatings = new TvContentRating[ratings.length];
for (int i = 0; i < contentRatings.length; ++i) {
contentRatings[i] = TvContentRating.unflattenFromString(ratings[i]);
}
return contentRatings;
}
项目:androidtv-sample-inputs
文件:TvContractUtils.java
/**
* Flattens an array of {@link TvContentRating} into a String to be inserted into a database.
*
* @param contentRatings An array of TvContentRatings.
* @return A comma-separated String of ratings.
* @hide
*/
public static String contentRatingsToString(TvContentRating[] contentRatings) {
if (contentRatings == null || contentRatings.length == 0) {
return null;
}
final String DELIMITER = ",";
StringBuilder ratings = new StringBuilder(contentRatings[0].flattenToString());
for (int i = 1; i < contentRatings.length; ++i) {
ratings.append(DELIMITER);
ratings.append(contentRatings[i].flattenToString());
}
return ratings.toString();
}