AvatarBuilderUriBuilder.java 6.08 KB
package com.bitstrips.imoji.abv3;

import android.net.Uri;
import android.net.Uri.Builder;
import android.support.annotation.NonNull;
import com.bitstrips.imoji.abv3.category.AvatarCategoryDetails;
import com.bitstrips.imoji.abv3.model.AvatarLookAlike;
import com.bitstrips.imoji.abv3.model.AvatarOption;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.experiments.Experiments;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

public class AvatarBuilderUriBuilder
{
  public static final String PATH_AVATAR_BUILDER = "avatar-builder";
  public static final String PATH_AVATAR_BUILDER_V3 = "avatar-builder-v3";
  public static final String PATH_FASHION = "fashion";
  public static final String PATH_LOOKING_GOOD = "looking-good";
  public static final String PATH_PREVIEW = "preview";
  public static final String QUERY_PARAM_GENDER = "gender";
  public static final String QUERY_PARAM_ROTATION = "rotation";
  public static final String QUERY_PARAM_SCALE = "scale";
  public static final String QUERY_PARAM_STYLE = "style";
  private final AvatarBuilderConfig a;
  private final AvatarBuilderSelection b;
  private final Uri c;
  private final String d;
  private final BehaviourHelper e;
  private final Experiments f;
  
  public AvatarBuilderUriBuilder(String paramString1, String paramString2, AvatarBuilderConfig paramAvatarBuilderConfig, AvatarBuilderSelection paramAvatarBuilderSelection, BehaviourHelper paramBehaviourHelper, Experiments paramExperiments)
  {
    this.a = paramAvatarBuilderConfig;
    this.d = paramString2;
    this.b = paramAvatarBuilderSelection;
    this.c = Uri.parse(paramString1);
    this.e = paramBehaviourHelper;
    this.f = paramExperiments;
  }
  
  private Uri a(Integer paramInteger, float paramFloat, @NonNull String paramString, Map<String, Integer> paramMap)
  {
    return a(paramInteger, paramFloat, paramString, paramMap, null);
  }
  
  private Uri a(Integer paramInteger, float paramFloat, @NonNull String paramString1, Map<String, Integer> paramMap, String paramString2)
  {
    Uri.Builder localBuilder = new Uri.Builder();
    localBuilder.scheme(this.c.getScheme());
    localBuilder.authority(this.c.getAuthority());
    localBuilder.appendPath(this.d).appendPath("preview").appendPath(paramString1);
    localBuilder.appendQueryParameter("scale", String.valueOf(paramFloat));
    localBuilder.appendQueryParameter("gender", String.valueOf(this.a.getGender().getValue()));
    localBuilder.appendQueryParameter("style", String.valueOf(this.a.getStyle().getValue()));
    if (paramInteger != null) {
      localBuilder.appendQueryParameter("rotation", String.valueOf(paramInteger));
    }
    paramInteger = new TreeSet(paramMap.keySet()).iterator();
    while (paramInteger.hasNext())
    {
      paramString1 = (String)paramInteger.next();
      Integer localInteger = (Integer)paramMap.get(paramString1);
      if (localInteger != null) {
        localBuilder.appendQueryParameter(paramString1, String.valueOf(localInteger));
      }
    }
    if (paramString2 != null) {
      localBuilder.appendQueryParameter("format", paramString2);
    }
    return localBuilder.build();
  }
  
  public Uri getLookAlikeUri(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails, @NonNull AvatarLookAlike paramAvatarLookAlike)
  {
    HashMap localHashMap = new HashMap();
    Map localMap1 = this.a.getInitialUserAvatarData();
    Map localMap2 = this.b.getSelectedOptions();
    localHashMap.putAll(paramAvatarLookAlike.getValueMap());
    localHashMap.putAll(localMap1);
    localHashMap.putAll(localMap2);
    return a(Integer.valueOf(paramAvatarCategoryDetails.getRotation()), 0.75F, paramAvatarCategoryDetails.getDisplayType(), localHashMap);
  }
  
  public Uri getOptionUri(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails, @NonNull AvatarOption paramAvatarOption)
  {
    HashMap localHashMap = new HashMap();
    Object localObject1 = this.a.getInitialUserAvatarData();
    Object localObject2 = this.b.getSelectedOptionsWithLookAlike();
    localHashMap.putAll((Map)localObject1);
    localHashMap.putAll((Map)localObject2);
    localHashMap.put(paramAvatarCategoryDetails.getCategoryKey(), Integer.valueOf(paramAvatarOption.getValue()));
    paramAvatarOption = new UriBuilderWhitelistCategoryHelper(this.e.isFewerOptionTraitsEnabled(this.f), this.a.getGender());
    localObject1 = new HashMap();
    localObject2 = localHashMap.keySet().iterator();
    while (((Iterator)localObject2).hasNext())
    {
      String str = (String)((Iterator)localObject2).next();
      if (paramAvatarOption.shouldKeepCategory(str, paramAvatarCategoryDetails.getCategoryKey())) {
        ((Map)localObject1).put(str, localHashMap.get(str));
      }
    }
    return a(Integer.valueOf(paramAvatarCategoryDetails.getRotation()), 0.75F, paramAvatarCategoryDetails.getDisplayType(), (Map)localObject1);
  }
  
  public Uri getPreviewUri(AvatarCategoryDetails paramAvatarCategoryDetails, int paramInt)
  {
    return getPreviewUri(paramAvatarCategoryDetails, paramInt, null);
  }
  
  public Uri getPreviewUri(AvatarCategoryDetails paramAvatarCategoryDetails, int paramInt, String paramString)
  {
    paramAvatarCategoryDetails = new HashMap();
    Map localMap1 = this.a.getInitialUserAvatarData();
    Map localMap2 = this.b.getSelectedOptionsWithLookAlike();
    paramAvatarCategoryDetails.putAll(localMap1);
    paramAvatarCategoryDetails.putAll(localMap2);
    return a(Integer.valueOf(paramInt), 2.5F, "body", paramAvatarCategoryDetails, paramString);
  }
  
  public Uri getSaveUri(@NonNull AvatarCategoryDetails paramAvatarCategoryDetails)
  {
    paramAvatarCategoryDetails = new HashMap();
    Map localMap1 = this.a.getInitialUserAvatarData();
    Map localMap2 = this.b.getSelectedOptions();
    paramAvatarCategoryDetails.putAll(localMap1);
    paramAvatarCategoryDetails.putAll(localMap2);
    return a(null, 2.5F, "fashion", paramAvatarCategoryDetails);
  }
}


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