AvatarInfoDeserializer.java 3.09 KB
package com.bitstrips.imoji.deserializers;

import com.bitstrips.imoji.models.AvatarInfo;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;

public class AvatarInfoDeserializer
  implements JsonDeserializer<AvatarInfo>
{
  private static final String[] b = { "bare", "shirt04", "pants05" };
  private static final String[] c = { "barebm0a" };
  PreferenceUtils a;
  
  public AvatarInfoDeserializer(PreferenceUtils paramPreferenceUtils)
  {
    this.a = paramPreferenceUtils;
  }
  
  private static boolean a(JsonArray paramJsonArray, String[] paramArrayOfString)
  {
    boolean bool2 = false;
    paramArrayOfString = Arrays.asList(paramArrayOfString);
    int i = 0;
    for (;;)
    {
      boolean bool1 = bool2;
      if (i < paramJsonArray.size())
      {
        if (paramArrayOfString.indexOf(paramJsonArray.get(i).getAsString()) == -1) {
          bool1 = true;
        }
      }
      else {
        return bool1;
      }
      i += 1;
    }
  }
  
  public AvatarInfo deserialize(JsonElement paramJsonElement, Type paramType, JsonDeserializationContext paramJsonDeserializationContext)
    throws JsonParseException
  {
    paramJsonElement = paramJsonElement.getAsJsonObject();
    this.a.putString(2131231236, paramJsonElement.toString());
    if (paramJsonElement.get("style") != null)
    {
      int i = paramJsonElement.get("style").getAsInt();
      paramJsonDeserializationContext = paramJsonElement.get("styled_char_data").getAsJsonObject().get(Integer.toString(i)).getAsJsonObject();
      paramType = paramJsonDeserializationContext.get("colours").getAsJsonObject();
      paramJsonDeserializationContext = paramJsonDeserializationContext.get("body").getAsJsonObject();
      i = paramType.get("ffcc99").getAsInt();
      int j = paramJsonDeserializationContext.get("body_type").getAsInt();
      int k = paramJsonDeserializationContext.get("breast_type").getAsInt();
      paramJsonElement.addProperty("skinTone", Integer.valueOf(i));
      paramJsonElement.addProperty("bodyType", Integer.valueOf(j));
      paramJsonElement.addProperty("breastType", Integer.valueOf(k));
      paramType = paramJsonDeserializationContext.get("new_clothes");
      if (paramType == null) {
        break label203;
      }
    }
    label203:
    for (boolean bool = a(paramType.getAsJsonArray(), c);; bool = a(paramJsonDeserializationContext.get("clothes").getAsJsonArray(), b))
    {
      paramJsonElement.addProperty("isDressed", Boolean.valueOf(bool));
      paramJsonElement.remove("styled_char_data");
      return (AvatarInfo)new Gson().fromJson(paramJsonElement, AvatarInfo.class);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/bitstrips/imoji/deserializers/AvatarInfoDeserializer.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */