Example usage for android.support.v4.media RatingCompat isThumbUp

List of usage examples for android.support.v4.media RatingCompat isThumbUp

Introduction

In this page you can find the example usage for android.support.v4.media RatingCompat isThumbUp.

Prototype

public boolean isThumbUp() 

Source Link

Document

Return whether the rating is "thumb up".

Usage

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   w  w w .jav  a  2 s  . co m
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;
    }
}