StarRating
class StarRating : Rating
kotlin.Any | |
↳ | androidx.media2.session.StarRating |
A class for rating expressed as the number of stars.
Summary
Public constructors | |
---|---|
Creates a unrated StarRating instance with |
|
Creates a StarRating instance with |
Public methods | |
---|---|
Boolean | |
Int |
Returns the max stars. |
Float |
Returns the star-based rating value. |
Int |
hashCode() |
Boolean |
isRated() |
String |
toString() |
Public constructors
<init>
StarRating(@IntRange(1) 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(
@IntRange(1) 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 |
Float: a number ranging from 0.0f to maxStars |
Public methods
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