StarRating

class StarRating : Rating
kotlin.Any
   ↳ androidx.media2.session.StarRating

A class for rating expressed as the number of stars.

Summary

Public constructors

<init>(maxStars: Int)

Creates a unrated StarRating instance with maxStars.

<init>(maxStars: Int, starRating: Float)

Creates a StarRating instance with maxStars and the given integer or fractional number of stars.

Public methods

Boolean
equals(other: Any?)

Int

Returns the max stars.

Float

Returns the star-based rating value.

Int

Boolean

String

Public constructors

<init>

StarRating(maxStars: Int)

Creates a unrated StarRating instance with maxStars. If maxStars is not a positive integer, it will throw IllegalArgumentException.

Parameters
maxStars Int: a range of this star rating from 0.0f to maxStars

<init>

StarRating(maxStars: Int, starRating: Float)

Creates a StarRating instance with maxStars and the given integer or fractional number of stars. Non integer values can for instance be used to represent an average rating value, which might not be an integer number of stars. If maxStars is not a positive integer or starRating has invalid value, it will throw IllegalArgumentException.

Parameters
maxStars Int: the maximum number of stars which this rating can have.
starRating Int: a number ranging from 0.0f to maxStars

Public methods

equals

fun equals(other: Any?): Boolean

getMaxStars

fun getMaxStars(): Int

Returns the max stars.

Return
Int: a max number of stars for this star rating.

getStarRating

fun getStarRating(): Float

Returns the star-based rating value.

Return
Float: a rating value greater or equal to 0.0f, or a negative value if it is unrated.

hashCode

fun hashCode(): Int

isRated

fun isRated(): Boolean

toString

fun toString(): String