List of usage examples for android.support.v4.media RatingCompat RATING_5_STARS
int RATING_5_STARS
To view the source code for android.support.v4.media RatingCompat RATING_5_STARS.
Click Source Link
From source file:android.support.mediacompat.service.ServiceBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras();/*from w ww .j ava2 s. com*/ if (ACTION_CALL_MEDIA_BROWSER_SERVICE_METHOD.equals(intent.getAction()) && extras != null) { StubMediaBrowserServiceCompat service = StubMediaBrowserServiceCompat.sInstance; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case NOTIFY_CHILDREN_CHANGED: service.notifyChildrenChanged(extras.getString(KEY_ARGUMENT)); break; case SEND_DELAYED_NOTIFY_CHILDREN_CHANGED: service.sendDelayedNotifyChildrenChanged(); break; case SEND_DELAYED_ITEM_LOADED: service.sendDelayedItemLoaded(); break; case CUSTOM_ACTION_SEND_PROGRESS_UPDATE: service.mCustomActionResult.sendProgressUpdate(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_ERROR: service.mCustomActionResult.sendError(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_RESULT: service.mCustomActionResult.sendResult(extras.getBundle(KEY_ARGUMENT)); break; case SET_SESSION_TOKEN: StubMediaBrowserServiceCompatWithDelayedMediaSession.sInstance.callSetSessionToken(); break; } } else if (ACTION_CALL_MEDIA_SESSION_METHOD.equals(intent.getAction()) && extras != null) { MediaSessionCompat session = StubMediaBrowserServiceCompat.sSession; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case SET_EXTRAS: session.setExtras(extras.getBundle(KEY_ARGUMENT)); break; case SET_FLAGS: session.setFlags(extras.getInt(KEY_ARGUMENT)); break; case SET_METADATA: session.setMetadata((MediaMetadataCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_PLAYBACK_STATE: session.setPlaybackState((PlaybackStateCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_QUEUE: List<QueueItem> items = extras.getParcelableArrayList(KEY_ARGUMENT); session.setQueue(items); break; case SET_QUEUE_TITLE: session.setQueueTitle(extras.getCharSequence(KEY_ARGUMENT)); break; case SET_SESSION_ACTIVITY: session.setSessionActivity((PendingIntent) extras.getParcelable(KEY_ARGUMENT)); break; case SET_CAPTIONING_ENABLED: session.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT)); break; case SET_REPEAT_MODE: session.setRepeatMode(extras.getInt(KEY_ARGUMENT)); break; case SET_SHUFFLE_MODE: session.setShuffleMode(extras.getInt(KEY_ARGUMENT)); break; case SEND_SESSION_EVENT: Bundle arguments = extras.getBundle(KEY_ARGUMENT); session.sendSessionEvent(arguments.getString("event"), arguments.getBundle("extras")); break; case SET_ACTIVE: session.setActive(extras.getBoolean(KEY_ARGUMENT)); break; case RELEASE: session.release(); break; case SET_PLAYBACK_TO_LOCAL: session.setPlaybackToLocal(extras.getInt(KEY_ARGUMENT)); break; case SET_PLAYBACK_TO_REMOTE: ParcelableVolumeInfo volumeInfo = extras.getParcelable(KEY_ARGUMENT); session.setPlaybackToRemote(new VolumeProviderCompat(volumeInfo.controlType, volumeInfo.maxVolume, volumeInfo.currentVolume) { }); break; case SET_RATING_TYPE: session.setRatingType(RatingCompat.RATING_5_STARS); break; } } }
From source file:androidx.media.MediaUtils2.java
/** * Creates a {@link Rating2} from the {@link RatingCompat}. * * @param ratingCompat A {@link RatingCompat} object. * @return The newly created {@link Rating2} object. *//*from ww w. j a v a 2 s . c om*/ Rating2 createRating2(RatingCompat ratingCompat) { if (ratingCompat == null) { return null; } if (!ratingCompat.isRated()) { return Rating2.newUnratedRating(ratingCompat.getRatingStyle()); } switch (ratingCompat.getRatingStyle()) { case RatingCompat.RATING_3_STARS: case RatingCompat.RATING_4_STARS: case RatingCompat.RATING_5_STARS: return Rating2.newStarRating(ratingCompat.getRatingStyle(), ratingCompat.getStarRating()); case RatingCompat.RATING_HEART: return Rating2.newHeartRating(ratingCompat.hasHeart()); case RatingCompat.RATING_THUMB_UP_DOWN: return Rating2.newThumbRating(ratingCompat.isThumbUp()); case RatingCompat.RATING_PERCENTAGE: return Rating2.newPercentageRating(ratingCompat.getPercentRating()); default: return null; } }