RatingCompat.java 5.47 KB
package android.support.v4.media;

import android.media.Rating;
import android.os.Build.VERSION;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.support.annotation.RestrictTo;
import android.util.Log;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public final class RatingCompat
  implements Parcelable
{
  public static final Parcelable.Creator<RatingCompat> CREATOR = new Parcelable.Creator() {};
  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;
  public static final int RATING_PERCENTAGE = 6;
  public static final int RATING_THUMB_UP_DOWN = 2;
  private final int a;
  private final float b;
  private Object c;
  
  RatingCompat(int paramInt, float paramFloat)
  {
    this.a = paramInt;
    this.b = paramFloat;
  }
  
  public static RatingCompat fromRating(Object paramObject)
  {
    if ((paramObject == null) || (Build.VERSION.SDK_INT < 19)) {
      return null;
    }
    int i = ((Rating)paramObject).getRatingStyle();
    RatingCompat localRatingCompat;
    if (((Rating)paramObject).isRated()) {
      switch (i)
      {
      default: 
        return null;
      case 1: 
        localRatingCompat = newHeartRating(((Rating)paramObject).hasHeart());
      }
    }
    for (;;)
    {
      localRatingCompat.c = paramObject;
      return localRatingCompat;
      localRatingCompat = newThumbRating(((Rating)paramObject).isThumbUp());
      continue;
      localRatingCompat = newStarRating(i, ((Rating)paramObject).getStarRating());
      continue;
      localRatingCompat = newPercentageRating(((Rating)paramObject).getPercentRating());
      continue;
      localRatingCompat = newUnratedRating(i);
    }
  }
  
  public static RatingCompat newHeartRating(boolean paramBoolean)
  {
    if (paramBoolean) {}
    for (float f = 1.0F;; f = 0.0F) {
      return new RatingCompat(1, f);
    }
  }
  
  public static RatingCompat newPercentageRating(float paramFloat)
  {
    if ((paramFloat < 0.0F) || (paramFloat > 100.0F))
    {
      Log.e("Rating", "Invalid percentage-based rating value");
      return null;
    }
    return new RatingCompat(6, paramFloat);
  }
  
  public static RatingCompat newStarRating(int paramInt, float paramFloat)
  {
    float f;
    switch (paramInt)
    {
    default: 
      Log.e("Rating", "Invalid rating style (" + paramInt + ") for a star rating");
      return null;
    case 3: 
      f = 3.0F;
    }
    while ((paramFloat < 0.0F) || (paramFloat > f))
    {
      Log.e("Rating", "Trying to set out of range star-based rating");
      return null;
      f = 4.0F;
      continue;
      f = 5.0F;
    }
    return new RatingCompat(paramInt, paramFloat);
  }
  
  public static RatingCompat newThumbRating(boolean paramBoolean)
  {
    if (paramBoolean) {}
    for (float f = 1.0F;; f = 0.0F) {
      return new RatingCompat(2, f);
    }
  }
  
  public static RatingCompat newUnratedRating(int paramInt)
  {
    switch (paramInt)
    {
    default: 
      return null;
    }
    return new RatingCompat(paramInt, -1.0F);
  }
  
  public final int describeContents()
  {
    return this.a;
  }
  
  public final float getPercentRating()
  {
    if ((this.a != 6) || (!isRated())) {
      return -1.0F;
    }
    return this.b;
  }
  
  public final Object getRating()
  {
    if ((this.c != null) || (Build.VERSION.SDK_INT < 19)) {
      return this.c;
    }
    if (isRated()) {
      switch (this.a)
      {
      default: 
        return null;
      case 1: 
        this.c = Rating.newHeartRating(hasHeart());
      }
    }
    for (;;)
    {
      return this.c;
      this.c = Rating.newThumbRating(isThumbUp());
      continue;
      this.c = Rating.newStarRating(this.a, getStarRating());
      continue;
      this.c = Rating.newPercentageRating(getPercentRating());
      break;
      this.c = Rating.newUnratedRating(this.a);
    }
  }
  
  public final int getRatingStyle()
  {
    return this.a;
  }
  
  public final float getStarRating()
  {
    switch (this.a)
    {
    }
    do
    {
      return -1.0F;
    } while (!isRated());
    return this.b;
  }
  
  public final boolean hasHeart()
  {
    if (this.a != 1) {}
    while (this.b != 1.0F) {
      return false;
    }
    return true;
  }
  
  public final boolean isRated()
  {
    return this.b >= 0.0F;
  }
  
  public final boolean isThumbUp()
  {
    if (this.a != 2) {}
    while (this.b != 1.0F) {
      return false;
    }
    return true;
  }
  
  public final String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder("Rating:style=").append(this.a).append(" rating=");
    if (this.b < 0.0F) {}
    for (String str = "unrated";; str = String.valueOf(this.b)) {
      return str;
    }
  }
  
  public final void writeToParcel(Parcel paramParcel, int paramInt)
  {
    paramParcel.writeInt(this.a);
    paramParcel.writeFloat(this.b);
  }
  
  @Retention(RetentionPolicy.SOURCE)
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public static @interface StarStyle {}
  
  @Retention(RetentionPolicy.SOURCE)
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public static @interface Style {}
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/media/RatingCompat.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */