diff options
Diffstat (limited to 'src/com/android/tv/parental/ContentRatingSystem.java')
-rw-r--r-- | src/com/android/tv/parental/ContentRatingSystem.java | 87 |
1 files changed, 50 insertions, 37 deletions
diff --git a/src/com/android/tv/parental/ContentRatingSystem.java b/src/com/android/tv/parental/ContentRatingSystem.java index 5672b793..600aaca1 100644 --- a/src/com/android/tv/parental/ContentRatingSystem.java +++ b/src/com/android/tv/parental/ContentRatingSystem.java @@ -20,9 +20,7 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.media.tv.TvContentRating; import android.text.TextUtils; - import com.android.tv.R; - import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -86,7 +84,7 @@ public class ContentRatingSystem { return mDomain + DELIMITER + mName; } - public String getName(){ + public String getName() { return mName; } @@ -94,19 +92,19 @@ public class ContentRatingSystem { return mDomain; } - public String getTitle(){ + public String getTitle() { return mTitle; } - public String getDescription(){ + public String getDescription() { return mDescription; } - public List<String> getCountries(){ + public List<String> getCountries() { return mCountries; } - public List<Rating> getRatings(){ + public List<Rating> getRatings() { return mRatings; } @@ -119,11 +117,11 @@ public class ContentRatingSystem { return null; } - public List<SubRating> getSubRatings(){ + public List<SubRating> getSubRatings() { return mSubRatings; } - public List<Order> getOrders(){ + public List<Order> getOrders() { return mOrders; } @@ -139,9 +137,7 @@ public class ContentRatingSystem { return mIsCustom; } - /** - * Returns true if the ratings is owned by this content rating system. - */ + /** Returns true if the ratings is owned by this content rating system. */ public boolean ownsRating(TvContentRating rating) { return mDomain.equals(rating.getDomain()) && mName.equals(rating.getRatingSystem()); } @@ -161,9 +157,16 @@ public class ContentRatingSystem { } private ContentRatingSystem( - String name, String domain, String title, String description, List<String> countries, - String displayName, List<Rating> ratings, List<SubRating> subRatings, - List<Order> orders, boolean isCustom) { + String name, + String domain, + String title, + String description, + List<String> countries, + String displayName, + List<Rating> ratings, + List<SubRating> subRatings, + List<Order> orders, + boolean isCustom) { mName = name; mDomain = domain; mTitle = title; @@ -298,8 +301,8 @@ public class ContentRatingSystem { } } if (!used) { - throw new IllegalArgumentException("Subrating " + subRating.getName() + - " isn't used by any rating"); + throw new IllegalArgumentException( + "Subrating " + subRating.getName() + " isn't used by any rating"); } } @@ -310,8 +313,17 @@ public class ContentRatingSystem { } } - return new ContentRatingSystem(mName, mDomain, mTitle, mDescription, mCountries, - displayName, ratings, subRatings, orders, mIsCustom); + return new ContentRatingSystem( + mName, + mDomain, + mTitle, + mDescription, + mCountries, + displayName, + ratings, + subRatings, + orders, + mIsCustom); } } @@ -347,8 +359,13 @@ public class ContentRatingSystem { return mSubRatings; } - private Rating(String name, String title, String description, Drawable icon, - int contentAgeHint, List<SubRating> subRatings) { + private Rating( + String name, + String title, + String description, + Drawable icon, + int contentAgeHint, + List<SubRating> subRatings) { mName = name; mTitle = title; mDescription = description; @@ -365,8 +382,7 @@ public class ContentRatingSystem { private int mContentAgeHint = -1; private final List<String> mSubRatingNames = new ArrayList<>(); - public Builder() { - } + public Builder() {} public void setName(String name) { mName = name; @@ -400,8 +416,8 @@ public class ContentRatingSystem { throw new IllegalArgumentException("Invalid subrating for rating " + mName); } if (mContentAgeHint < 0) { - throw new IllegalArgumentException("Rating " + mName + " should define " + - "non-negative contentAgeHint"); + throw new IllegalArgumentException( + "Rating " + mName + " should define " + "non-negative contentAgeHint"); } List<SubRating> subRatings = new ArrayList<>(); @@ -415,12 +431,11 @@ public class ContentRatingSystem { } } if (!found) { - throw new IllegalArgumentException("Unknown subrating name " + subRatingId + - " in rating " + mName); + throw new IllegalArgumentException( + "Unknown subrating name " + subRatingId + " in rating " + mName); } } - return new Rating( - mName, mTitle, mDescription, mIcon, mContentAgeHint, subRatings); + return new Rating(mName, mTitle, mDescription, mIcon, mContentAgeHint, subRatings); } } } @@ -460,8 +475,7 @@ public class ContentRatingSystem { private String mDescription; private Drawable mIcon; - public Builder() { - } + public Builder() {} public void setName(String name) { mName = name; @@ -500,8 +514,8 @@ public class ContentRatingSystem { } /** - * Returns index of the rating in this order. - * Returns -1 if this order doesn't contain the rating. + * Returns index of the rating in this order. Returns -1 if this order doesn't contain the + * rating. */ public int getRatingIndex(Rating rating) { for (int i = 0; i < mRatingOrder.size(); i++) { @@ -515,8 +529,7 @@ public class ContentRatingSystem { public static class Builder { private final List<String> mRatingNames = new ArrayList<>(); - public Builder() { - } + public Builder() {} private Order build(List<Rating> ratings) { List<Rating> ratingOrder = new ArrayList<>(); @@ -531,8 +544,8 @@ public class ContentRatingSystem { } if (!found) { - throw new IllegalArgumentException("Unknown rating " + ratingName + - " in rating-order tag"); + throw new IllegalArgumentException( + "Unknown rating " + ratingName + " in rating-order tag"); } } |