Rating
public
final
class
Rating
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.media.Rating |
A class to encapsulate rating information used as content metadata.
A rating is defined by its rating style (see RATING_HEART,
RATING_THUMB_UP_DOWN, RATING_3_STARS, RATING_4_STARS,
RATING_5_STARS or RATING_PERCENTAGE) and the actual rating value (which may
be defined as "unrated"), both of which are defined when the rating instance is constructed
through one of the factory methods.
Summary
Constants | |
|---|---|
int |
RATING_3_STARS
A rating style with 0 to 3 stars. |
int |
RATING_4_STARS
A rating style with 0 to 4 stars. |
int |
RATING_5_STARS
A rating style with 0 to 5 stars. |
int |
RATING_HEART
A rating style with a single degree of rating, "heart" vs "no heart". |
int |
RATING_NONE
Indicates a rating style is not supported. |
int |
RATING_PERCENTAGE
A rating style expressed as a percentage. |
int |
RATING_THUMB_UP_DOWN
A rating style for "thumb up" vs "thumb down". |
Inherited constants |
|---|
android.os.Parcelable
|
Fields | |
|---|---|
public
static
final
Creator<Rating> |
CREATOR
|
Public methods | |
|---|---|
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
float
|
getPercentRating()
Return the percentage-based rating value. |
int
|
getRatingStyle()
Return the rating style. |
float
|
getStarRating()
Return the star-based rating value. |
boolean
|
hasHeart()
Return whether the rating is "heart selected". |
boolean
|
isRated()
Return whether there is a rating value available. |
boolean
|
isThumbUp()
Return whether the rating is "thumb up". |
static
Rating
|
newHeartRating(boolean hasHeart)
Return a Rating instance with a heart-based rating. |
static
Rating
|
newPercentageRating(float percent)
Return a Rating instance with a percentage-based rating. |
static
Rating
|
newStarRating(int starRatingStyle, float starRating)
Return a Rating instance with a star-based rating. |
static
Rating
|
newThumbRating(boolean thumbIsUp)
Return a Rating instance with a thumb-based rating. |
static
Rating
|
newUnratedRating(int ratingStyle)
Return a Rating instance with no rating. |
String
|
toString()
Returns a string representation of the object. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
|---|---|
java.lang.Object
| |
android.os.Parcelable
| |
Constants
RATING_3_STARS
int RATING_3_STARS
A rating style with 0 to 3 stars.
Constant Value: 3 (0x00000003)
RATING_4_STARS
int RATING_4_STARS
A rating style with 0 to 4 stars.
Constant Value: 4 (0x00000004)
RATING_5_STARS
int RATING_5_STARS
A rating style with 0 to 5 stars.
Constant Value: 5 (0x00000005)
RATING_HEART
int RATING_HEART
A rating style with a single degree of rating, "heart" vs "no heart". Can be used to indicate the content referred to is a favorite (or not).
Constant Value: 1 (0x00000001)
RATING_NONE
int RATING_NONE
Indicates a rating style is not supported. A Rating will never have this type, but can be used by other classes to indicate they do not support Rating.
Constant Value: 0 (0x00000000)
RATING_PERCENTAGE
int RATING_PERCENTAGE
A rating style expressed as a percentage.
Constant Value: 6 (0x00000006)
RATING_THUMB_UP_DOWN
int RATING_THUMB_UP_DOWN
A rating style for "thumb up" vs "thumb down".
Constant Value: 2 (0x00000002)
Fields
Public methods
describeContents
int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(Parcel, int),
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR bit.
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
getPercentRating
float getPercentRating ()
Return the percentage-based rating value.
| Returns | |
|---|---|
float |
a rating value greater or equal to 0.0f, or a negative value if the rating style is not percentage-based, or if it is unrated. |
getRatingStyle
int getRatingStyle ()
Return the rating style.
| Returns | |
|---|---|
int |
one of RATING_HEART, RATING_THUMB_UP_DOWN,
RATING_3_STARS, RATING_4_STARS, RATING_5_STARS,
or RATING_PERCENTAGE.
|
getStarRating
float getStarRating ()
Return the star-based rating value.
| Returns | |
|---|---|
float |
a rating value greater or equal to 0.0f, or a negative value if the rating style is not star-based, or if it is unrated. |
hasHeart
boolean hasHeart ()
Return whether the rating is "heart selected".
| Returns | |
|---|---|
boolean |
true if the rating is "heart selected", false if the rating is "heart unselected",
if the rating style is not RATING_HEART or if it is unrated.
|
isRated
boolean isRated ()
Return whether there is a rating value available.
| Returns | |
|---|---|
boolean |
true if the instance was not created with newUnratedRating(int).
|
isThumbUp
boolean isThumbUp ()
Return whether the rating is "thumb up".
| Returns | |
|---|---|
boolean |
true if the rating is "thumb up", false if the rating is "thumb down",
if the rating style is not RATING_THUMB_UP_DOWN or if it is unrated.
|
newHeartRating
Rating newHeartRating (boolean hasHeart)
Return a Rating instance with a heart-based rating.
Create and return a new Rating instance with a rating style of RATING_HEART,
and a heart-based rating.
| Parameters | |
|---|---|
hasHeart |
boolean:
true for a "heart selected" rating, false for "heart unselected". |
| Returns | |
|---|---|
Rating |
a new Rating instance. |
newPercentageRating
Rating newPercentageRating (float percent)
Return a Rating instance with a percentage-based rating.
Create and return a new Rating instance with a RATING_PERCENTAGE
rating style, and a rating of the given percentage.
| Parameters | |
|---|---|
percent |
float:
the value of the rating |
| Returns | |
|---|---|
Rating |
null if the rating is out of range, a new Rating instance otherwise. |
newStarRating
Rating newStarRating (int starRatingStyle, float starRating)
Return a Rating instance with a star-based rating. Create and return a new Rating instance with one of the star-base rating styles 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.
| Parameters | |
|---|---|
starRatingStyle |
int:
one of RATING_3_STARS, RATING_4_STARS,
RATING_5_STARS. |
starRating |
float:
a number ranging from 0.0f to 3.0f, 4.0f or 5.0f according to
the rating style. |
| Returns | |
|---|---|
Rating |
null if the rating style is invalid, or the rating is out of range, a new Rating instance otherwise. |
newThumbRating
Rating newThumbRating (boolean thumbIsUp)
Return a Rating instance with a thumb-based rating.
Create and return a new Rating instance with a RATING_THUMB_UP_DOWN
rating style, and a "thumb up" or "thumb down" rating.
| Parameters | |
|---|---|
thumbIsUp |
boolean:
true for a "thumb up" rating, false for "thumb down". |
| Returns | |
|---|---|
Rating |
a new Rating instance. |
newUnratedRating
Rating newUnratedRating (int ratingStyle)
Return a Rating instance with no rating. Create and return a new Rating instance with no rating known for the given rating style.
| Parameters | |
|---|---|
ratingStyle |
int:
one of RATING_HEART, RATING_THUMB_UP_DOWN,
RATING_3_STARS, RATING_4_STARS, RATING_5_STARS,
or RATING_PERCENTAGE. |
| Returns | |
|---|---|
Rating |
null if an invalid rating style is passed, a new Rating instance otherwise. |
toString
String toString ()
Returns a string representation of the object. In general, the
toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
| Returns | |
|---|---|
String |
a string representation of the object. |
writeToParcel
void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
| Parameters | |
|---|---|
dest |
Parcel:
The Parcel in which the object should be written. |
flags |
int:
Additional flags about how the object should be written.
May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
|
Interfaces
- AudioManager.OnAudioFocusChangeListener
- AudioRecord.OnRecordPositionUpdateListener
- AudioRecord.OnRoutingChangedListener
- AudioRouting
- AudioRouting.OnRoutingChangedListener
- AudioTrack.OnPlaybackPositionUpdateListener
- AudioTrack.OnRoutingChangedListener
- ImageReader.OnImageAvailableListener
- ImageWriter.OnImageReleasedListener
- JetPlayer.OnJetEventListener
- MediaCodec.OnFrameRenderedListener
- MediaDrm.OnEventListener
- MediaDrm.OnExpirationUpdateListener
- MediaDrm.OnKeyStatusChangeListener
- MediaPlayer.OnBufferingUpdateListener
- MediaPlayer.OnCompletionListener
- MediaPlayer.OnErrorListener
- MediaPlayer.OnInfoListener
- MediaPlayer.OnPreparedListener
- MediaPlayer.OnSeekCompleteListener
- MediaPlayer.OnTimedMetaDataAvailableListener
- MediaPlayer.OnTimedTextListener
- MediaPlayer.OnVideoSizeChangedListener
- MediaRecorder.OnErrorListener
- MediaRecorder.OnInfoListener
- MediaScannerConnection.MediaScannerConnectionClient
- MediaScannerConnection.OnScanCompletedListener
- MediaSync.OnErrorListener
- RemoteControlClient.OnGetPlaybackPositionListener
- RemoteControlClient.OnMetadataUpdateListener
- RemoteControlClient.OnPlaybackPositionUpdateListener
- RemoteController.OnClientUpdateListener
- SoundPool.OnLoadCompleteListener
Classes
- AsyncPlayer
- AudioAttributes
- AudioAttributes.Builder
- AudioDeviceCallback
- AudioDeviceInfo
- AudioFormat
- AudioFormat.Builder
- AudioManager
- AudioManager.AudioRecordingCallback
- AudioRecord
- AudioRecord.Builder
- AudioRecordingConfiguration
- AudioTimestamp
- AudioTrack
- AudioTrack.Builder
- CamcorderProfile
- CameraProfile
- DrmInitData
- DrmInitData.SchemeInitData
- ExifInterface
- FaceDetector
- FaceDetector.Face
- Image
- Image.Plane
- ImageReader
- ImageWriter
- JetPlayer
- MediaActionSound
- MediaCodec
- MediaCodec.BufferInfo
- MediaCodec.Callback
- MediaCodec.CryptoInfo
- MediaCodec.CryptoInfo.Pattern
- MediaCodecInfo
- MediaCodecInfo.AudioCapabilities
- MediaCodecInfo.CodecCapabilities
- MediaCodecInfo.CodecProfileLevel
- MediaCodecInfo.EncoderCapabilities
- MediaCodecInfo.VideoCapabilities
- MediaCodecList
- MediaCrypto
- MediaDataSource
- MediaDescription
- MediaDescription.Builder
- MediaDrm
- MediaDrm.CryptoSession
- MediaDrm.KeyRequest
- MediaDrm.KeyStatus
- MediaDrm.ProvisionRequest
- MediaExtractor
- MediaFormat
- MediaMetadata
- MediaMetadata.Builder
- MediaMetadataEditor
- MediaMetadataRetriever
- MediaMuxer
- MediaMuxer.OutputFormat
- MediaPlayer
- MediaPlayer.TrackInfo
- MediaRecorder
- MediaRecorder.AudioEncoder
- MediaRecorder.AudioSource
- MediaRecorder.OutputFormat
- MediaRecorder.VideoEncoder
- MediaRecorder.VideoSource
- MediaRouter
- MediaRouter.Callback
- MediaRouter.RouteCategory
- MediaRouter.RouteGroup
- MediaRouter.RouteInfo
- MediaRouter.SimpleCallback
- MediaRouter.UserRouteInfo
- MediaRouter.VolumeCallback
- MediaScannerConnection
- MediaSync
- MediaSync.Callback
- MediaSyncEvent
- MediaTimestamp
- PlaybackParams
- Rating
- RemoteControlClient
- RemoteControlClient.MetadataEditor
- RemoteController
- RemoteController.MetadataEditor
- Ringtone
- RingtoneManager
- SoundPool
- SoundPool.Builder
- SyncParams
- ThumbnailUtils
- TimedMetaData
- TimedText
- ToneGenerator
- VolumeProvider
Exceptions


