package tv.ouya.console.api.store;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.TimeZone;
import org.json.JSONException;
import org.json.JSONObject;

public class AppDescription
  implements Parcelable
{
  private static final String[] APP_STATUSES = { "unsubmitted", "submitted", "under_review", "approved", "published", "rejected" };
  public static final Parcelable.Creator<AppDescription> CREATOR = new Parcelable.Creator()
  {
    public AppDescription createFromParcel(Parcel paramAnonymousParcel)
    {
      String str1 = paramAnonymousParcel.readString();
      String str2 = paramAnonymousParcel.readString();
      String str3 = paramAnonymousParcel.readString();
      double d = paramAnonymousParcel.readDouble();
      int j = paramAnonymousParcel.readInt();
      Object localObject = null;
      if (j > -1)
      {
        HashMap localHashMap = new HashMap();
        int i = 0;
        for (;;)
        {
          localObject = localHashMap;
          if (i >= j) {
            break;
          }
          localObject = paramAnonymousParcel.readString();
          AppDescription.AppVersion localAppVersion = new AppDescription.AppVersion();
          localAppVersion.setUuid(paramAnonymousParcel.readString());
          localAppVersion.setUploadedAt(paramAnonymousParcel.readString());
          localAppVersion.setMainImageFullUrl(paramAnonymousParcel.readString());
          localAppVersion.setContentRating(paramAnonymousParcel.readString());
          localHashMap.put(localObject, localAppVersion);
          i += 1;
        }
      }
      return new AppDescription(str1, str2, str3, d, (HashMap)localObject);
    }
    
    public AppDescription[] newArray(int paramAnonymousInt)
    {
      return new AppDescription[paramAnonymousInt];
    }
  };
  private static final String DATE_FORMAT = "yyy-MM-dd'T'HH:mm:ss'Z'";
  private String imageUrl;
  private double percentOff;
  private String title;
  private String uuid;
  private HashMap<String, AppVersion> versions;
  
  public AppDescription() {}
  
  public AppDescription(String paramString1, String paramString2, String paramString3, double paramDouble, HashMap<String, AppVersion> paramHashMap)
  {
    this.uuid = paramString1;
    this.title = paramString2;
    this.imageUrl = paramString3;
    this.versions = paramHashMap;
    this.percentOff = paramDouble;
  }
  
  public AppDescription(String paramString1, String paramString2, HashMap<String, AppVersion> paramHashMap)
  {
    this(paramString1, paramString2, null, 0.0D, paramHashMap);
  }
  
  public AppDescription(JSONObject paramJSONObject)
    throws JSONException
  {
    readFromJSON(paramJSONObject);
  }
  
  private AppVersion getMostRecentVersion()
  {
    if (this.versions == null) {
      return AppVersion.EMPTY_VERSION;
    }
    String[] arrayOfString = APP_STATUSES;
    int j = arrayOfString.length;
    int i = 0;
    while (i < j)
    {
      String str = arrayOfString[i];
      if (this.versions.containsKey(str)) {
        return (AppVersion)this.versions.get(str);
      }
      i += 1;
    }
    return AppVersion.EMPTY_VERSION;
  }
  
  public int describeContents()
  {
    return 0;
  }
  
  public boolean equals(Object paramObject)
  {
    if (this == paramObject) {}
    do
    {
      return true;
      if (!(paramObject instanceof AppDescription)) {
        return false;
      }
      paramObject = (AppDescription)paramObject;
      if (this.title != null)
      {
        if (this.title.equals(((AppDescription)paramObject).title)) {}
      }
      else {
        while (((AppDescription)paramObject).title != null) {
          return false;
        }
      }
      if (this.uuid != null)
      {
        if (this.uuid.equals(((AppDescription)paramObject).uuid)) {}
      }
      else {
        while (((AppDescription)paramObject).uuid != null) {
          return false;
        }
      }
      if (this.imageUrl != null)
      {
        if (this.imageUrl.equals(((AppDescription)paramObject).imageUrl)) {}
      }
      else {
        while (((AppDescription)paramObject).imageUrl != null) {
          return false;
        }
      }
      if (this.percentOff != ((AppDescription)paramObject).percentOff) {
        return false;
      }
      if (this.versions == null) {
        break;
      }
    } while (this.versions.equals(((AppDescription)paramObject).versions));
    for (;;)
    {
      return false;
      if (((AppDescription)paramObject).versions == null) {
        break;
      }
    }
  }
  
  public String getImageUrl()
  {
    return this.imageUrl;
  }
  
  public Intent getLaunchIntent(Context paramContext)
  {
    PackageManager localPackageManager = paramContext.getPackageManager();
    Intent localIntent = new Intent("android.intent.action.MAIN", null);
    localIntent.addFlags(268435456);
    localIntent.addCategory("android.intent.category.LAUNCHER");
    localIntent.addCategory("tv.ouya.intent.category.GAME");
    localIntent.setPackage(getUuid());
    ResolveInfo localResolveInfo = localPackageManager.resolveActivity(localIntent, 0);
    paramContext = localResolveInfo;
    if (localResolveInfo == null)
    {
      localIntent.removeCategory("tv.ouya.intent.category.GAME");
      localIntent.addCategory("tv.ouya.intent.category.APP");
      paramContext = localPackageManager.resolveActivity(localIntent, 0);
    }
    if (paramContext == null) {
      return null;
    }
    localIntent.setClassName(paramContext.activityInfo.applicationInfo.packageName, paramContext.activityInfo.name);
    return localIntent;
  }
  
  public String getMostRecentVersionContentRating()
  {
    return getMostRecentVersion().getContentRating();
  }
  
  public String getMostRecentVersionMainImageFullUrl()
  {
    return getMostRecentVersion().getMainImageFullUrl();
  }
  
  public String getMostRecentVersionUploadedAt()
  {
    return getMostRecentVersion().getUploadedAt();
  }
  
  public String getMostRecentVersionUuid()
  {
    return getMostRecentVersion().getUuid();
  }
  
  public double getPercentOff()
  {
    return this.percentOff;
  }
  
  public String getTitle()
  {
    return this.title;
  }
  
  public String getUuid()
  {
    return this.uuid;
  }
  
  public HashMap<String, AppVersion> getVersions()
  {
    return this.versions;
  }
  
  public int hashCode()
  {
    int k = 0;
    int i;
    if (this.uuid != null)
    {
      i = this.uuid.hashCode();
      if (this.title == null) {
        break label64;
      }
    }
    label64:
    for (int j = this.title.hashCode();; j = 0)
    {
      if (this.versions != null) {
        k = this.versions.hashCode();
      }
      return (i * 31 + j) * 31 + k;
      i = 0;
      break;
    }
  }
  
  public void readFromJSON(JSONObject paramJSONObject)
    throws JSONException
  {
    this.uuid = paramJSONObject.getString("uuid");
    this.title = paramJSONObject.getString("title");
    this.versions = new HashMap();
    if (paramJSONObject.has("versions"))
    {
      localObject = paramJSONObject.getJSONObject("versions");
      Iterator localIterator = ((JSONObject)localObject).keys();
      while (localIterator.hasNext())
      {
        String str = (String)localIterator.next();
        this.versions.put(str, new AppVersion(((JSONObject)localObject).getJSONObject(str)));
      }
    }
    Object localObject = new AppVersion();
    ((AppVersion)localObject).setUuid(paramJSONObject.getString("version"));
    ((AppVersion)localObject).setMainImageFullUrl(paramJSONObject.optString("image"));
    ((AppVersion)localObject).setContentRating(paramJSONObject.optString("content_rating", null));
    this.versions.put("approved", localObject);
    if (paramJSONObject.has("image")) {
      this.imageUrl = paramJSONObject.getString("image");
    }
    this.percentOff = paramJSONObject.optDouble("percentOff", 0.0D);
  }
  
  public void setMainImageFullUrl(String paramString)
  {
    this.imageUrl = paramString;
  }
  
  public void setTitle(String paramString)
  {
    this.title = paramString;
  }
  
  public void setUuid(String paramString)
  {
    this.uuid = paramString;
  }
  
  public void setVersions(HashMap<String, AppVersion> paramHashMap)
  {
    this.versions = paramHashMap;
  }
  
  public String toString()
  {
    return "AppDescription{title='" + this.title + '\'' + ", uuid='" + this.uuid + '\'' + ", versions=" + this.versions + '}';
  }
  
  public void writeToParcel(Parcel paramParcel, int paramInt)
  {
    paramParcel.writeString(this.uuid);
    paramParcel.writeString(this.title);
    paramParcel.writeString(this.imageUrl);
    paramParcel.writeDouble(this.percentOff);
    if (this.versions == null) {
      paramParcel.writeInt(-1);
    }
    for (;;)
    {
      return;
      paramParcel.writeInt(this.versions.size());
      Iterator localIterator = this.versions.keySet().iterator();
      while (localIterator.hasNext())
      {
        String str = (String)localIterator.next();
        paramParcel.writeString(str);
        paramParcel.writeString(((AppVersion)this.versions.get(str)).getUuid());
        paramParcel.writeString(((AppVersion)this.versions.get(str)).getUploadedAt());
        paramParcel.writeString(((AppVersion)this.versions.get(str)).getMainImageFullUrl());
        paramParcel.writeString(((AppVersion)this.versions.get(str)).getContentRating());
      }
    }
  }
  
  public static class AppVersion
  {
    public static final AppVersion EMPTY_VERSION = new AppVersion();
    private String contentRating;
    private String mainImageFullUrl;
    private String uploadedAt;
    private String uuid;
    
    public AppVersion() {}
    
    public AppVersion(JSONObject paramJSONObject)
      throws JSONException
    {
      readFromJSON(paramJSONObject);
    }
    
    private Date parseDate(String paramString)
      throws ParseException
    {
      SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss'Z'");
      localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
      return localSimpleDateFormat.parse(paramString);
    }
    
    public boolean equals(Object paramObject)
    {
      if (this == paramObject) {}
      do
      {
        return true;
        if ((paramObject == null) || (getClass() != paramObject.getClass())) {
          return false;
        }
        paramObject = (AppVersion)paramObject;
        if (this.uploadedAt != null)
        {
          if (this.uploadedAt.equals(((AppVersion)paramObject).uploadedAt)) {}
        }
        else {
          while (((AppVersion)paramObject).uploadedAt != null) {
            return false;
          }
        }
        if (this.uuid != null)
        {
          if (this.uuid.equals(((AppVersion)paramObject).uuid)) {}
        }
        else {
          while (((AppVersion)paramObject).uuid != null) {
            return false;
          }
        }
        if (this.mainImageFullUrl != null)
        {
          if (this.mainImageFullUrl.equals(((AppVersion)paramObject).mainImageFullUrl)) {}
        }
        else {
          while (((AppVersion)paramObject).mainImageFullUrl != null) {
            return false;
          }
        }
        if (this.contentRating == null) {
          break;
        }
      } while (this.contentRating.equals(((AppVersion)paramObject).contentRating));
      for (;;)
      {
        return false;
        if (((AppVersion)paramObject).contentRating == null) {
          break;
        }
      }
    }
    
    public String getContentRating()
    {
      return this.contentRating;
    }
    
    public String getMainImageFullUrl()
    {
      return this.mainImageFullUrl;
    }
    
    public String getUploadedAt()
    {
      return this.uploadedAt;
    }
    
    public Date getUploadedAtDate()
    {
      try
      {
        Date localDate = parseDate(this.uploadedAt);
        return localDate;
      }
      catch (ParseException localParseException)
      {
        throw new RuntimeException(localParseException);
      }
    }
    
    public String getUuid()
    {
      return this.uuid;
    }
    
    public int hashCode()
    {
      int m = 0;
      int i;
      int j;
      if (this.uuid != null)
      {
        i = this.uuid.hashCode();
        if (this.uploadedAt == null) {
          break label87;
        }
        j = this.uploadedAt.hashCode();
        label33:
        if (this.mainImageFullUrl == null) {
          break label92;
        }
      }
      label87:
      label92:
      for (int k = this.mainImageFullUrl.hashCode();; k = 0)
      {
        if (this.contentRating != null) {
          m = this.contentRating.hashCode();
        }
        return ((i * 31 + j) * 31 + k) * 31 + m;
        i = 0;
        break;
        j = 0;
        break label33;
      }
    }
    
    public void readFromJSON(JSONObject paramJSONObject)
      throws JSONException
    {
      this.uuid = paramJSONObject.getString("uuid");
      this.uploadedAt = paramJSONObject.getString("uploadedAt");
      this.mainImageFullUrl = paramJSONObject.getString("mainImageFullUrl");
      this.contentRating = paramJSONObject.optString("contentRating");
    }
    
    public void setContentRating(String paramString)
    {
      this.contentRating = paramString;
    }
    
    public void setMainImageFullUrl(String paramString)
    {
      this.mainImageFullUrl = paramString;
    }
    
    public void setUploadedAt(String paramString)
    {
      this.uploadedAt = paramString;
    }
    
    public void setUuid(String paramString)
    {
      this.uuid = paramString;
    }
    
    public String toString()
    {
      return "AppVersion{uuid='" + this.uuid + '\'' + ", uploadedAt=" + this.uploadedAt + ", mainImageFullUrl='" + this.mainImageFullUrl + '\'' + ", contentRating='" + this.contentRating + '\'' + '}';
    }
  }
}


/* Location:              /home/enzo/Documents/hacking/malwares/viking-horde/classes.jar!/tv/ouya/console/api/store/AppDescription.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */