Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 976aa3d4 authored by Hyundo Moon's avatar Hyundo Moon Committed by Android (Google) Code Review
Browse files

Merge "Rating: Disallow putting Float.NaN as star/percent values"

parents 30e1d45e 76da1da5
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -206,11 +206,12 @@ public final class Rating implements Parcelable {
                Log.e(TAG, "Invalid rating style (" + starRatingStyle + ") for a star rating");
                Log.e(TAG, "Invalid rating style (" + starRatingStyle + ") for a star rating");
                return null;
                return null;
        }
        }
        if ((starRating < 0.0f) || (starRating > maxRating)) {
        if (starRating >= 0.0f && starRating <= maxRating) {
            return new Rating(starRatingStyle, starRating);
        } else {
            Log.e(TAG, "Trying to set out of range star-based rating");
            Log.e(TAG, "Trying to set out of range star-based rating");
            return null;
            return null;
        }
        }
        return new Rating(starRatingStyle, starRating);
    }
    }


    /**
    /**
@@ -221,11 +222,11 @@ public final class Rating implements Parcelable {
     * @return null if the rating is out of range, a new Rating instance otherwise.
     * @return null if the rating is out of range, a new Rating instance otherwise.
     */
     */
    public static Rating newPercentageRating(float percent) {
    public static Rating newPercentageRating(float percent) {
        if ((percent < 0.0f) || (percent > 100.0f)) {
        if (percent >= 0.0f && percent <= 100.0f) {
            return new Rating(RATING_PERCENTAGE, percent);
        } else {
            Log.e(TAG, "Invalid percentage-based rating value");
            Log.e(TAG, "Invalid percentage-based rating value");
            return null;
            return null;
        } else {
            return new Rating(RATING_PERCENTAGE, percent);
        }
        }
    }
    }