MirrorUploadHelper.java 5.43 KB
package com.bitstrips.imoji.experiments;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Build.VERSION;
import android.util.Log;
import com.bitstrips.imoji.abv3.AvatarBuilderActivityMode;
import com.bitstrips.imoji.api.BitmojiApi;
import com.bitstrips.imoji.api.BitmojiMirrorImageUploadRequest;
import com.bitstrips.imoji.api.BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent;
import com.bitstrips.imoji.api.MirrorValidGeoIpResponse;
import com.bitstrips.imoji.behaviour.BehaviourHelper;
import com.bitstrips.imoji.hardware.CameraUtils;
import com.bitstrips.imoji.util.PreferenceUtils;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.json.JSONObject;
import retrofit.Callback;
import retrofit.RetrofitError;

@Singleton
public class MirrorUploadHelper
{
  private static final String a = MirrorUploadHelper.class.getSimpleName();
  private final BitmojiApi b;
  private final PreferenceUtils c;
  private final BehaviourHelper d;
  private final Experiments e;
  
  @Inject
  public MirrorUploadHelper(BitmojiApi paramBitmojiApi, PreferenceUtils paramPreferenceUtils, BehaviourHelper paramBehaviourHelper, Experiments paramExperiments)
  {
    this.b = paramBitmojiApi;
    this.c = paramPreferenceUtils;
    this.d = paramBehaviourHelper;
    this.e = paramExperiments;
  }
  
  public boolean shouldSaveMirrorImage()
  {
    float f2 = this.d.mirrorSaveRatio();
    float f1 = f2;
    if (f2 == -1.0D) {
      f1 = this.e.getFloat("settings.mirror-save-ratio-android", 0.0F);
    }
    return Math.random() < f1;
  }
  
  public boolean shouldShowMirrorImage()
  {
    float f = this.d.mirrorSaveRatio();
    if (f != -1.0D) {
      if (f <= 0.0D) {}
    }
    while ((this.e.getBoolean("settings.mirror-show-enabled", false)) && (this.e.getBoolean("experiments.mirror-show.enabled", false)))
    {
      return true;
      return false;
    }
    return false;
  }
  
  public void uploadMirrorImage(final FullCharacterDataWithOrigins paramFullCharacterDataWithOrigins, final Bitmap paramBitmap, final AvatarBuilderActivityMode paramAvatarBuilderActivityMode, final String paramString1, Context paramContext, final String paramString2, final boolean paramBoolean)
  {
    if ((paramBitmap == null) || (paramFullCharacterDataWithOrigins == null)) {}
    do
    {
      return;
      paramFullCharacterDataWithOrigins = new Runnable()
      {
        public final void run()
        {
          BitmojiMirrorImageUploadRequest localBitmojiMirrorImageUploadRequest = new BitmojiMirrorImageUploadRequest();
          Object localObject = new JSONObject(paramFullCharacterDataWithOrigins.getOptions());
          if (paramBoolean) {
            localBitmojiMirrorImageUploadRequest.setCurrOptionAvatar(((JSONObject)localObject).toString());
          }
          for (;;)
          {
            localBitmojiMirrorImageUploadRequest.getClass();
            localObject = new BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent(localBitmojiMirrorImageUploadRequest);
            localBitmojiMirrorImageUploadRequest.setUserAgentJson((BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent)localObject);
            ((BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent)localObject).setAppName(paramString1);
            ((BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent)localObject).setAppVersion("10.29.98");
            ((BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent)localObject).setOsName("android");
            ((BitmojiMirrorImageUploadRequest.BitmojiMirrorImageUploadUserAgent)localObject).setOsVersion(Build.VERSION.RELEASE);
            localBitmojiMirrorImageUploadRequest.setDeviceModel(Build.MANUFACTURER + "-" + Build.MODEL);
            localBitmojiMirrorImageUploadRequest.setRequestType(MirrorUploadHelper.a(paramAvatarBuilderActivityMode));
            localBitmojiMirrorImageUploadRequest.setMirrorImage(CameraUtils.getBase64String(paramBitmap));
            localBitmojiMirrorImageUploadRequest.setRecognitionLog(paramString2);
            localBitmojiMirrorImageUploadRequest.setCurrAvatarOrigin(new JSONObject(paramFullCharacterDataWithOrigins.getOrigins()).toString());
            localObject = new Callback()
            {
              public final void failure(RetrofitError paramAnonymous2RetrofitError)
              {
                Log.e(MirrorUploadHelper.a(), "Failed to save mirror image.");
              }
            };
            MirrorUploadHelper.a(MirrorUploadHelper.this).mirrorImageUploadUniversal(localBitmojiMirrorImageUploadRequest, (Callback)localObject);
            return;
            localBitmojiMirrorImageUploadRequest.setCurrAvatar(((JSONObject)localObject).toString());
          }
        }
      };
      if (this.d.isMirrorGeoIpValidationOverrideEnabled())
      {
        paramFullCharacterDataWithOrigins.run();
        return;
      }
    } while (!this.c.getBoolean("MirrorHasValidGeoIpSharedPreference", true));
    paramFullCharacterDataWithOrigins = new Callback()
    {
      public final void failure(RetrofitError paramAnonymousRetrofitError)
      {
        Log.e(MirrorUploadHelper.a(), "Failed to reach mirror valid geo ip.");
      }
    };
    this.b.hasValidMirrorGeoIp(paramFullCharacterDataWithOrigins);
  }
}


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