Experiments.java 5.87 KB
package com.bitstrips.imoji.experiments;

import android.util.Log;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.util.PreferenceUtils;
import com.google.gson.Gson;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import retrofit.Callback;
import retrofit.RetrofitError;

@Singleton
public class Experiments
{
  public static final String EXPERIMENT_BIGGER_SELFIE_ENABLED = "experiments.bigger-selfie.enabled";
  public static final String EXPERIMENT_FILTER_OPTION_TRAITS_ENABLED = "experiments.filter-option-traits.enabled";
  public static final String SETTINGS_FACE_RECOGNITION_ENABLE_RATIO = "settings.face-recognition-v2-enable-ratio";
  public static final String SETTINGS_MIRROR_SAVE_RATIO = "settings.mirror-save-ratio-android";
  public static final String SETTINGS_MIRROR_SHOW_ENABLED = "settings.mirror-show-enabled";
  public static final String SETTINGS_MONOUSER_ENABLE_RATIO = "settings.monouser-enable";
  public static final String STUDY_CHILLVIBES_CONTENT_GROUP = "experiments.chillvibes.content-group";
  public static final String STUDY_CHILLVIBES_CONTENT_GROUP_DEFAULT = "default";
  public static final String STUDY_MIRROR_SHOW_ENABLED = "experiments.mirror-show.enabled";
  public static final String STUDY_SMARTVIBES_REORDER_CONTENT_ENABLED = "experiments.smartvibes.reorderContentEnabled";
  public static final String STUDY_SMARTVIBES_SUGGEST_CONTENT_ENABLED = "experiments.smartvibes.suggestContentEnabled";
  public static final String STUDY_UPGRADE_TEASER_ENABLED = "experiments.full-upgrade-teaser-android.enabled";
  private static final String a = Experiments.class.getSimpleName();
  private ExperimentsResult b;
  private ExperimentsResult c;
  private final BitmojiApi d;
  private final PreferenceUtils e;
  
  @Inject
  public Experiments(BitmojiApi paramBitmojiApi, PreferenceUtils paramPreferenceUtils)
  {
    this.d = paramBitmojiApi;
    this.e = paramPreferenceUtils;
  }
  
  private Object a(String paramString)
  {
    boolean bool;
    Object localObject;
    if (paramString.split("\\.").length == 2)
    {
      bool = true;
      if (!Boolean.valueOf(bool).booleanValue()) {
        break label93;
      }
      if (this.c == null) {
        break label53;
      }
      localObject = this.c;
    }
    for (;;)
    {
      if ((localObject != null) && (((ExperimentsResult)localObject).settings != null)) {
        break label101;
      }
      return null;
      bool = false;
      break;
      label53:
      localObject = this.e.getString(2131231223, "");
      this.c = ((ExperimentsResult)new Gson().fromJson((String)localObject, ExperimentsResult.class));
      localObject = this.c;
      continue;
      label93:
      localObject = b();
    }
    label101:
    return ((ExperimentsResult)localObject).settings.get(paramString);
  }
  
  private ExperimentsResult b()
  {
    if (this.b != null) {
      return this.b;
    }
    String str = this.e.getString(2131231224, "");
    this.b = ((ExperimentsResult)new Gson().fromJson(str, ExperimentsResult.class));
    return this.b;
  }
  
  public boolean getBoolean(String paramString, boolean paramBoolean)
  {
    paramString = a(paramString);
    if (paramString == null) {
      return paramBoolean;
    }
    if ((paramString instanceof Boolean)) {
      return ((Boolean)paramString).booleanValue();
    }
    Log.e(a, "Non-boolean value detected.");
    return paramBoolean;
  }
  
  public int[] getExperimentIds()
  {
    ExperimentsResult localExperimentsResult = b();
    if ((localExperimentsResult == null) || (localExperimentsResult.experimentIds == null)) {
      return new int[0];
    }
    return (int[])localExperimentsResult.experimentIds.clone();
  }
  
  public float getFloat(String paramString, float paramFloat)
  {
    paramString = a(paramString);
    if (paramString == null) {
      return paramFloat;
    }
    if ((paramString instanceof Number)) {
      return ((Number)paramString).floatValue();
    }
    Log.e(a, "Non-float value detected.");
    return paramFloat;
  }
  
  public int getInt(String paramString, int paramInt)
  {
    paramString = a(paramString);
    if (paramString == null) {
      return paramInt;
    }
    if ((paramString instanceof Number)) {
      return ((Number)paramString).intValue();
    }
    Log.e(a, "Non-integer value detected.");
    return paramInt;
  }
  
  public String getString(String paramString1, String paramString2)
  {
    paramString1 = a(paramString1);
    if (paramString1 == null) {
      return paramString2;
    }
    if ((paramString1 instanceof String)) {
      return (String)paramString1;
    }
    Log.e(a, "Non-string value detected.");
    return paramString2;
  }
  
  public void init(ExperimentsResult paramExperimentsResult)
  {
    ExperimentsResult localExperimentsResult = paramExperimentsResult;
    if (paramExperimentsResult == null) {
      localExperimentsResult = new ExperimentsResult();
    }
    this.e.putString(2131231224, new Gson().toJson(localExperimentsResult));
    this.e.putString(2131231223, new Gson().toJson(localExperimentsResult));
    this.c = localExperimentsResult;
  }
  
  public void reset()
  {
    this.b = null;
    this.e.clearKey(2131231224);
  }
  
  public void updateABConfig()
  {
    this.d.getExperiments(new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        Log.e(Experiments.a(), "Failed to obtain experiments.", paramAnonymousRetrofitError);
      }
    });
  }
  
  public void updateGlobalVars()
  {
    this.d.getExperimentsGlobal(new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        Log.e(Experiments.a(), "Failed to obtain globalVars.", paramAnonymousRetrofitError);
      }
    });
  }
}


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