AvatarFlowBuilder.java 7.55 KB
package com.bitstrips.imoji.abv3;

import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Color;
import com.bitstrips.imoji.abv3.bottombar.AvatarBottomBarItem;
import com.bitstrips.imoji.abv3.bottombar.AvatarBottomBarSubCategory;
import com.bitstrips.imoji.abv3.category.AvatarCategoryDetails;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import org.apache.commons.lang3.StringUtils;

public class AvatarFlowBuilder
{
  public static final String TYPE_BODY = "body";
  public static final String TYPE_CREATE = "create";
  public static final String TYPE_EDIT = "edit";
  private final Resources a;
  private final String b;
  private final BottomBarJson c;
  private final AvatarCategoryDetailsJson d;
  
  public AvatarFlowBuilder(String paramString1, Resources paramResources, String paramString2)
    throws IOException
  {
    this.a = paramResources;
    this.b = paramString2;
    paramResources = a("avatar-builder/bottom_bar.json");
    this.c = ((BottomBarJson)new Gson().fromJson(paramResources, BottomBarJson.class));
    paramString1 = a(paramString1);
    this.d = ((AvatarCategoryDetailsJson)new Gson().fromJson(paramString1, AvatarCategoryDetailsJson.class));
  }
  
  private String a(String paramString)
    throws IOException
  {
    paramString = new Scanner(this.a.getAssets().open(paramString)).useDelimiter("\\A");
    if (paramString.hasNext()) {
      return paramString.next();
    }
    return "";
  }
  
  public AvatarBuilderFlow getFlow(AvatarBuilderStyle paramAvatarBuilderStyle, AvatarBuilderGender paramAvatarBuilderGender, String paramString)
  {
    Object localObject1 = this.c.bitstrips;
    if (paramAvatarBuilderStyle == AvatarBuilderStyle.STYLE_BITMOJI)
    {
      localObject1 = this.c.bitmoji;
      paramAvatarBuilderStyle = ((BottomBarJsonStyle)localObject1).create;
      if (!"body".equals(paramString)) {
        break label419;
      }
      paramAvatarBuilderStyle = ((BottomBarJsonStyle)localObject1).body;
    }
    label46:
    label152:
    label255:
    label419:
    label443:
    label503:
    label515:
    for (;;)
    {
      paramString = paramAvatarBuilderStyle.male;
      if (paramAvatarBuilderGender == AvatarBuilderGender.GENDER_FEMALE) {}
      for (paramAvatarBuilderStyle = paramAvatarBuilderStyle.female;; paramAvatarBuilderStyle = paramString)
      {
        paramString = new ArrayList();
        localObject1 = new ArrayList();
        Iterator localIterator1 = paramAvatarBuilderStyle.iterator();
        Object localObject2;
        int k;
        if (localIterator1.hasNext())
        {
          paramAvatarBuilderStyle = (BottomBarJsonItem)localIterator1.next();
          localObject2 = paramAvatarBuilderStyle.iconName;
          k = this.a.getIdentifier((String)localObject2, "drawable", this.b);
          localObject2 = new ArrayList();
          Iterator localIterator2 = paramAvatarBuilderStyle.subCategoryKeys.iterator();
          if (localIterator2.hasNext())
          {
            String str = (String)localIterator2.next();
            AvatarCategoryDetailsJsonItem localAvatarCategoryDetailsJsonItem = (AvatarCategoryDetailsJsonItem)this.d.categoryDetailsMap.get(str);
            paramAvatarBuilderStyle = "";
            if (!StringUtils.isEmpty(localAvatarCategoryDetailsJsonItem.titleStringResource))
            {
              i = this.a.getIdentifier(localAvatarCategoryDetailsJsonItem.titleStringResource, "string", this.b);
              paramAvatarBuilderStyle = this.a.getString(i);
            }
            if (localAvatarCategoryDetailsJsonItem.backgroundColor != null)
            {
              i = Color.parseColor(localAvatarCategoryDetailsJsonItem.backgroundColor);
              if (localAvatarCategoryDetailsJsonItem.backgroundColor == null) {
                break label443;
              }
            }
            for (int j = Color.parseColor(localAvatarCategoryDetailsJsonItem.titleColor);; j = -16777216)
            {
              ((List)localObject1).add(new AvatarCategoryDetails(paramAvatarBuilderStyle, str, localAvatarCategoryDetailsJsonItem.columnCount, localAvatarCategoryDetailsJsonItem.displayType, localAvatarCategoryDetailsJsonItem.previewDisplayType, localAvatarCategoryDetailsJsonItem.rotation, i, j));
              j = this.a.getIdentifier(localAvatarCategoryDetailsJsonItem.iconResource, "drawable", this.b);
              i = j;
              if (paramAvatarBuilderGender == AvatarBuilderGender.GENDER_FEMALE)
              {
                i = j;
                if (localAvatarCategoryDetailsJsonItem.femaleIconResource != null) {
                  i = this.a.getIdentifier(localAvatarCategoryDetailsJsonItem.femaleIconResource, "drawable", this.b);
                }
              }
              ((List)localObject2).add(new AvatarBottomBarSubCategory(i, str));
              break label152;
              if (paramAvatarBuilderStyle != AvatarBuilderStyle.STYLE_CM) {
                break;
              }
              localObject1 = this.c.cm;
              break;
              if (!"edit".equals(paramString)) {
                break label515;
              }
              paramAvatarBuilderStyle = ((BottomBarJsonStyle)localObject1).edit;
              break label46;
              i = -1;
              break label255;
            }
          }
          if (k != 0) {
            break label503;
          }
        }
        for (int i = ((AvatarBottomBarSubCategory)((List)localObject2).get(0)).getIconResource();; i = k)
        {
          paramString.add(new AvatarBottomBarItem(i, (List)localObject2));
          break;
          return new AvatarBuilderFlow((List)localObject1, paramString);
        }
      }
    }
  }
  
  public static class AvatarCategoryDetailsJson
  {
    @SerializedName("category_details")
    public Map<String, AvatarFlowBuilder.AvatarCategoryDetailsJsonItem> categoryDetailsMap;
  }
  
  public static class AvatarCategoryDetailsJsonItem
  {
    @SerializedName("background_color")
    public String backgroundColor;
    @SerializedName("column_count")
    public int columnCount;
    @SerializedName("display_type")
    public String displayType;
    @SerializedName("female_icon_resource")
    public String femaleIconResource;
    @SerializedName("icon_resource")
    public String iconResource;
    @SerializedName("preview_display_type")
    public String previewDisplayType;
    @SerializedName("rotation")
    public int rotation;
    @SerializedName("title_color")
    public String titleColor;
    @SerializedName("title_string_resource")
    public String titleStringResource;
  }
  
  public static class BottomBarJson
  {
    public AvatarFlowBuilder.BottomBarJsonStyle bitmoji;
    public AvatarFlowBuilder.BottomBarJsonStyle bitstrips;
    public AvatarFlowBuilder.BottomBarJsonStyle cm;
  }
  
  public static class BottomBarJsonItem
  {
    public String iconName;
    public List<String> subCategoryKeys;
  }
  
  public static class BottomBarJsonStyle
  {
    public AvatarFlowBuilder.BottomBarJsonType body;
    public AvatarFlowBuilder.BottomBarJsonType create;
    public AvatarFlowBuilder.BottomBarJsonType edit;
  }
  
  public static class BottomBarJsonType
  {
    public List<AvatarFlowBuilder.BottomBarJsonItem> female;
    public List<AvatarFlowBuilder.BottomBarJsonItem> male;
  }
}


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