StarRating
public final class StarRating extends Rating
A rating expressed as a fractional number of stars.
Summary
Public fields |
|
|---|---|
final @IntRange(from = 1) int |
|
final float |
Public constructors |
|---|
StarRating(@IntRange(from = 1) int maxStars)Creates a unrated instance with |
StarRating(Creates a rated instance with |
Public methods |
|
|---|---|
boolean |
|
static StarRating |
@UnstableApiRestores a |
@IntRange(from = 1) int |
Returns the maximum number of stars. |
float |
Returns the fractional number of stars of this rating. |
int |
hashCode() |
boolean |
isRated()Whether the rating exists or not. |
Bundle |
Returns a |
Inherited methods |
||
|---|---|---|
|
Public fields
Public constructors
StarRating
public StarRating(@IntRange(from = 1) int maxStars)
Creates a unrated instance with maxStars. If maxStars is not a positive integer, it will throw an IllegalArgumentException.
| Parameters | |
|---|---|
@IntRange(from = 1) int maxStars |
The maximum number of stars this rating can have. |
StarRating
public StarRating(
@IntRange(from = 1) int maxStars,
@FloatRange(from = 0.0) float starRating
)
Creates a rated instance with maxStars and the given fractional number of stars. Non-integer values may be used to represent an average rating value. If maxStars is not a positive integer or starRating is out of range, it will throw an IllegalArgumentException.
| Parameters | |
|---|---|
@IntRange(from = 1) int maxStars |
The maximum number of stars this rating can have. |
@FloatRange(from = 0.0) float starRating |
A fractional number of stars of this rating from |
Public methods
fromBundle
@UnstableApi
public static StarRating fromBundle(Bundle bundle)
Restores a StarRating from a Bundle.
getMaxStars
public @IntRange(from = 1) int getMaxStars()
Returns the maximum number of stars. Must be a positive number.
getStarRating
public float getStarRating()
Returns the fractional number of stars of this rating. Will range from 0f to maxStars, or RATING_UNSET if unrated.
toBundle
@UnstableApi
public Bundle toBundle()
Returns a Bundle representing the information stored in this rating.