- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
219 lines
6.8 KiB
Java
219 lines
6.8 KiB
Java
package android.support.v4.media;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.media.Rating;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import android.util.Log;
|
|
import androidx.annotation.RestrictTo;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
@SuppressLint({"BanParcelableUsage"})
|
|
/* loaded from: classes.dex */
|
|
public final class RatingCompat implements Parcelable {
|
|
public static final Parcelable.Creator<RatingCompat> CREATOR = new Parcelable.Creator<RatingCompat>() { // from class: android.support.v4.media.RatingCompat.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public RatingCompat createFromParcel(Parcel parcel) {
|
|
return new RatingCompat(parcel.readInt(), parcel.readFloat());
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public RatingCompat[] newArray(int i) {
|
|
return new RatingCompat[i];
|
|
}
|
|
};
|
|
public static final int RATING_3_STARS = 3;
|
|
public static final int RATING_4_STARS = 4;
|
|
public static final int RATING_5_STARS = 5;
|
|
public static final int RATING_HEART = 1;
|
|
public static final int RATING_NONE = 0;
|
|
private static final float RATING_NOT_RATED = -1.0f;
|
|
public static final int RATING_PERCENTAGE = 6;
|
|
public static final int RATING_THUMB_UP_DOWN = 2;
|
|
private static final String TAG = "Rating";
|
|
private Object mRatingObj;
|
|
private final int mRatingStyle;
|
|
private final float mRatingValue;
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public @interface StarStyle {
|
|
}
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public @interface Style {
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return this.mRatingStyle;
|
|
}
|
|
|
|
public int getRatingStyle() {
|
|
return this.mRatingStyle;
|
|
}
|
|
|
|
public boolean hasHeart() {
|
|
return this.mRatingStyle == 1 && this.mRatingValue == 1.0f;
|
|
}
|
|
|
|
public boolean isRated() {
|
|
return this.mRatingValue >= 0.0f;
|
|
}
|
|
|
|
public boolean isThumbUp() {
|
|
return this.mRatingStyle == 2 && this.mRatingValue == 1.0f;
|
|
}
|
|
|
|
public RatingCompat(int i, float f) {
|
|
this.mRatingStyle = i;
|
|
this.mRatingValue = f;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Rating:style=");
|
|
sb.append(this.mRatingStyle);
|
|
sb.append(" rating=");
|
|
float f = this.mRatingValue;
|
|
sb.append(f < 0.0f ? "unrated" : String.valueOf(f));
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
parcel.writeInt(this.mRatingStyle);
|
|
parcel.writeFloat(this.mRatingValue);
|
|
}
|
|
|
|
public static RatingCompat newUnratedRating(int i) {
|
|
switch (i) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
case 6:
|
|
return new RatingCompat(i, -1.0f);
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static RatingCompat newHeartRating(boolean z) {
|
|
return new RatingCompat(1, z ? 1.0f : 0.0f);
|
|
}
|
|
|
|
public static RatingCompat newThumbRating(boolean z) {
|
|
return new RatingCompat(2, z ? 1.0f : 0.0f);
|
|
}
|
|
|
|
public static RatingCompat newStarRating(int i, float f) {
|
|
float f2;
|
|
if (i == 3) {
|
|
f2 = 3.0f;
|
|
} else if (i == 4) {
|
|
f2 = 4.0f;
|
|
} else {
|
|
if (i != 5) {
|
|
Log.e(TAG, "Invalid rating style (" + i + ") for a star rating");
|
|
return null;
|
|
}
|
|
f2 = 5.0f;
|
|
}
|
|
if (f < 0.0f || f > f2) {
|
|
Log.e(TAG, "Trying to set out of range star-based rating");
|
|
return null;
|
|
}
|
|
return new RatingCompat(i, f);
|
|
}
|
|
|
|
public static RatingCompat newPercentageRating(float f) {
|
|
if (f < 0.0f || f > 100.0f) {
|
|
Log.e(TAG, "Invalid percentage-based rating value");
|
|
return null;
|
|
}
|
|
return new RatingCompat(6, f);
|
|
}
|
|
|
|
public float getStarRating() {
|
|
int i = this.mRatingStyle;
|
|
if ((i == 3 || i == 4 || i == 5) && isRated()) {
|
|
return this.mRatingValue;
|
|
}
|
|
return -1.0f;
|
|
}
|
|
|
|
public float getPercentRating() {
|
|
if (this.mRatingStyle == 6 && isRated()) {
|
|
return this.mRatingValue;
|
|
}
|
|
return -1.0f;
|
|
}
|
|
|
|
public static RatingCompat fromRating(Object obj) {
|
|
RatingCompat ratingCompat = null;
|
|
if (obj != null) {
|
|
Rating rating = (Rating) obj;
|
|
int ratingStyle = rating.getRatingStyle();
|
|
if (rating.isRated()) {
|
|
switch (ratingStyle) {
|
|
case 1:
|
|
ratingCompat = newHeartRating(rating.hasHeart());
|
|
break;
|
|
case 2:
|
|
ratingCompat = newThumbRating(rating.isThumbUp());
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
ratingCompat = newStarRating(ratingStyle, rating.getStarRating());
|
|
break;
|
|
case 6:
|
|
ratingCompat = newPercentageRating(rating.getPercentRating());
|
|
break;
|
|
default:
|
|
return null;
|
|
}
|
|
} else {
|
|
ratingCompat = newUnratedRating(ratingStyle);
|
|
}
|
|
ratingCompat.mRatingObj = obj;
|
|
}
|
|
return ratingCompat;
|
|
}
|
|
|
|
public Object getRating() {
|
|
if (this.mRatingObj == null) {
|
|
if (isRated()) {
|
|
int i = this.mRatingStyle;
|
|
switch (i) {
|
|
case 1:
|
|
this.mRatingObj = Rating.newHeartRating(hasHeart());
|
|
break;
|
|
case 2:
|
|
this.mRatingObj = Rating.newThumbRating(isThumbUp());
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
this.mRatingObj = Rating.newStarRating(i, getStarRating());
|
|
break;
|
|
case 6:
|
|
this.mRatingObj = Rating.newPercentageRating(getPercentRating());
|
|
break;
|
|
default:
|
|
return null;
|
|
}
|
|
} else {
|
|
this.mRatingObj = Rating.newUnratedRating(this.mRatingStyle);
|
|
}
|
|
}
|
|
return this.mRatingObj;
|
|
}
|
|
}
|