AvatarBuilderCameraFragment.java 4.24 KB
package com.bitstrips.imoji.abv3.camera;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.bitstrips.imoji.InjectorApplication;
import com.bitstrips.imoji.hardware.CameraUtils;
import com.bitstrips.imoji.hardware.CameraUtils.BitmapCallback;
import com.bitstrips.imoji.hardware.CameraUtils.CameraDetails;
import com.bitstrips.imoji.ui.views.CameraPreview;
import javax.inject.Inject;

public class AvatarBuilderCameraFragment
  extends Fragment
{
  private static final String b = AvatarBuilderCameraFragment.class.getSimpleName();
  @Inject
  CameraUtils a;
  private CameraUtils.CameraDetails c;
  private CameraPreview d;
  private View e;
  private int f;
  private boolean g;
  private boolean h;
  
  private void b()
  {
    if (!this.h)
    {
      getListener().onCameraStarted();
      this.h = true;
    }
    this.c = this.a.openFrontFacingCamera();
    if (this.c == null)
    {
      c();
      return;
    }
    this.d.attachCamera(this.c.camera);
    this.e.setEnabled(true);
  }
  
  private void c()
  {
    getListener().onCameraFailed();
  }
  
  public static AvatarBuilderCameraFragment createFragment(int paramInt, boolean paramBoolean)
  {
    AvatarBuilderCameraFragment localAvatarBuilderCameraFragment = new AvatarBuilderCameraFragment();
    Bundle localBundle = new Bundle();
    localBundle.putInt("ARGUMENT_MAX_IMAGE_SIZE", paramInt);
    localBundle.putBoolean("ARGUMENT_USE_BIGGER_SELFIE", paramBoolean);
    localAvatarBuilderCameraFragment.setArguments(localBundle);
    return localAvatarBuilderCameraFragment;
  }
  
  public AvatarBuilderCameraFragmentListener getListener()
  {
    return (AvatarBuilderCameraFragmentListener)getActivity();
  }
  
  public void onCreate(@Nullable Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    ((InjectorApplication)getContext().getApplicationContext()).inject(this);
  }
  
  @Nullable
  public View onCreateView(LayoutInflater paramLayoutInflater, @Nullable ViewGroup paramViewGroup, @Nullable Bundle paramBundle)
  {
    paramViewGroup = paramLayoutInflater.inflate(2130903105, paramViewGroup, false);
    this.e = paramViewGroup.findViewById(2131689702);
    this.e.setClickable(true);
    this.e.setEnabled(false);
    this.e.setOnClickListener(new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        AvatarBuilderCameraFragment.a(AvatarBuilderCameraFragment.this);
      }
    });
    this.h = false;
    if (getArguments() != null) {}
    for (paramLayoutInflater = getArguments();; paramLayoutInflater = new Bundle())
    {
      this.f = paramLayoutInflater.getInt("ARGUMENT_MAX_IMAGE_SIZE", 768);
      this.g = paramLayoutInflater.getBoolean("ARGUMENT_USE_BIGGER_SELFIE", true);
      this.d = ((CameraPreview)paramViewGroup.findViewById(2131689622));
      paramViewGroup.findViewById(2131689703).setOnClickListener(new View.OnClickListener()
      {
        public final void onClick(View paramAnonymousView)
        {
          AvatarBuilderCameraFragment.this.getListener().onCameraCancel();
        }
      });
      return paramViewGroup;
    }
  }
  
  public void onPause()
  {
    super.onPause();
    if (this.c != null)
    {
      this.a.releaseCamera(this.c);
      this.c = null;
      this.d.releaseCamera();
      this.e.setEnabled(false);
    }
  }
  
  public void onRequestPermissionsResult(int paramInt, @NonNull String[] paramArrayOfString, @NonNull int[] paramArrayOfInt)
  {
    if (paramInt == 1)
    {
      if (this.a.hasPermissions()) {
        b();
      }
    }
    else {
      return;
    }
    getListener().onCameraPermissionDenied();
  }
  
  public void onResume()
  {
    super.onResume();
    if (this.a.hasPermissions())
    {
      b();
      return;
    }
    this.a.requestPermissions(getActivity(), 1);
  }
}


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