导航菜单

页面标题

页面副标题

Rilo v2.0.21 - Dazzle.java 源代码

正在查看: Rilo v2.0.21 应用的 Dazzle.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.aemerse.dazzle;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Range;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.view.WindowInsets;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.webkit.MimeTypeMap;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AppCompatActivity;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraControl;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.ImageCapture;
import androidx.camera.core.Preview;
import androidx.camera.core.UseCase;
import androidx.camera.core.ZoomState;
import androidx.camera.lifecycle.ProcessCameraProvider;
import androidx.camera.video.FallbackStrategy;
import androidx.camera.video.FileOutputOptions;
import androidx.camera.video.PendingRecording;
import androidx.camera.video.Quality;
import androidx.camera.video.QualitySelector;
import androidx.camera.video.Recorder;
import androidx.camera.video.Recording;
import androidx.camera.video.VideoCapture;
import androidx.camera.video.VideoOutput;
import androidx.camera.video.VideoRecordEvent;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.net.UriKt;
import androidx.core.util.Consumer;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.aemerse.cropper.CropImageContract;
import com.aemerse.cropper.CropImageContractOptions;
import com.aemerse.cropper.CropImageContractOptionsKt;
import com.aemerse.cropper.CropImageView;
import com.aemerse.dazzle.databinding.ActivityDazzleBinding;
import com.aemerse.dazzle.gallery.BottomSheetMediaRecyclerAdapter;
import com.aemerse.dazzle.gallery.InstantMediaRecyclerAdapter;
import com.aemerse.dazzle.gallery.MediaModel;
import com.aemerse.dazzle.interfaces.PermissionCallback;
import com.aemerse.dazzle.utils.DazzleOptions;
import com.aemerse.dazzle.utils.GeneralUtils;
import com.aemerse.dazzle.utils.HeaderItemDecoration;
import com.aemerse.dazzle.utils.MediaConstants;
import com.aemerse.dazzle.utils.OnDelayClickListener;
import com.aemerse.dazzle.utils.PermissionUtils;
import com.facebook.internal.NativeProtocol;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.common.util.concurrent.ListenableFuture;
import com.yalantis.ucrop.UCrop;
import java.io.File;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import kotlin.Deprecated;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.io.FilesKt;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;

@Metadata(d1 = {"\u0000»\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\r*\u0001%\u0018\u0000 V2\u00020\u0001:\u0001VB\u0005¢\u0006\u0002\u0010\u0002J\b\u00105\u001a\u00020\u001aH\u0002J\u0018\u00106\u001a\u00020\u00132\u0006\u00107\u001a\u00020\u00132\u0006\u00108\u001a\u00020\u0013H\u0002J\b\u00109\u001a\u00020:H\u0003J\b\u0010;\u001a\u00020:H\u0002J\b\u0010<\u001a\u00020-H\u0002J\b\u0010=\u001a\u00020:H\u0002J\b\u0010>\u001a\u00020\u001aH\u0002J\b\u0010?\u001a\u00020\u001aH\u0002J\b\u0010@\u001a\u00020:H\u0002J\b\u0010A\u001a\u00020:H\u0002J\"\u0010B\u001a\u00020:2\u0006\u0010C\u001a\u00020\u00132\u0006\u0010D\u001a\u00020\u00132\b\u0010E\u001a\u0004\u0018\u00010FH\u0015J\b\u0010G\u001a\u00020:H\u0016J\u0012\u0010H\u001a\u00020:2\b\u0010I\u001a\u0004\u0018\u00010JH\u0014J\b\u0010K\u001a\u00020:H\u0014J\b\u0010L\u001a\u00020:H\u0002J\b\u0010M\u001a\u00020:H\u0002J\b\u0010N\u001a\u00020:H\u0003J\b\u0010O\u001a\u00020:H\u0002J\b\u0010P\u001a\u00020:H\u0002J\b\u0010Q\u001a\u00020:H\u0002J\b\u0010R\u001a\u00020:H\u0002J\u0010\u0010S\u001a\u00020:2\u0006\u0010T\u001a\u00020\u0005H\u0003J\b\u0010U\u001a\u00020:H\u0003R\u0016\u0010\u0003\u001a\n\u0012\u0004\u0012\u00020\u0005\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\f\u001a\u0010\u0012\f\u0012\n \u000f*\u0004\u0018\u00010\u000e0\u000e0\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0010\u001a\u0004\u0018\u00010\u0011X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0012\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00160\u0015X\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0017\u001a\u0004\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u001aX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001b\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u001c\u001a\u00020\u001dX\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u001e\u001a\u0004\u0018\u00010\u001fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010 \u001a\u00020!X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\"\u001a\u0004\u0018\u00010#X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010$\u001a\u00020%X\u0082\u0004¢\u0006\u0004\n\u0002\u0010&R\u0010\u0010'\u001a\u0004\u0018\u00010(X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010)\u001a\u00020\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010*\u001a\u00020+X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010,\u001a\u00020-X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010.\u001a\u0004\u0018\u00010/X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u00100\u001a\u000201X\u0082\u0004¢\u0006\u0002\n\u0000R\u0016\u00102\u001a\n\u0012\u0004\u0012\u000204\u0018\u000103X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006W"}, d2 = {"Lcom/aemerse/dazzle/Dazzle;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "bottomSheetBehavior", "Lcom/google/android/material/bottomsheet/BottomSheetBehavior;", "Landroid/view/View;", "camera", "Landroidx/camera/core/Camera;", "cameraExecutor", "Ljava/util/concurrent/ExecutorService;", "cameraProvider", "Landroidx/camera/lifecycle/ProcessCameraProvider;", "cropImage", "Landroidx/activity/result/ActivityResultLauncher;", "Lcom/aemerse/cropper/CropImageContractOptions;", "kotlin.jvm.PlatformType", "currentRecording", "Landroidx/camera/video/Recording;", "flashMode", "", "galleryImageList", "Ljava/util/ArrayList;", "Lcom/aemerse/dazzle/gallery/MediaModel;", "imageCapture", "Landroidx/camera/core/ImageCapture;", "isTakingVideo", "", "lensFacing", "mBinding", "Lcom/aemerse/dazzle/databinding/ActivityDazzleBinding;", "mBottomMediaAdapter", "Lcom/aemerse/dazzle/gallery/BottomSheetMediaRecyclerAdapter;", "mDazzleOptions", "Lcom/aemerse/dazzle/utils/DazzleOptions;", "mInstantMediaAdapter", "Lcom/aemerse/dazzle/gallery/InstantMediaRecyclerAdapter;", "mMediaClickListener", "com/aemerse/dazzle/Dazzle$mMediaClickListener$1", "Lcom/aemerse/dazzle/Dazzle$mMediaClickListener$1;", "mVideoCounterHandler", "Landroid/os/Handler;", "mVideoCounterProgress", "mVideoCounterRunnable", "Ljava/lang/Runnable;", "outputDirectory", "Ljava/io/File;", "preview", "Landroidx/camera/core/Preview;", "qualitySelector", "Landroidx/camera/video/QualitySelector;", "videoCapture", "Landroidx/camera/video/VideoCapture;", "Landroidx/camera/video/Recorder;", "allPermissionsGranted", "aspectRatio", "width", "height", "bindCameraUseCases", "", "getMedia", "getOutputDirectory", "handleBottomSheet", "hasBackCamera", "hasFrontCamera", "hideTopViews", "initViews", "onActivityResult", "requestCode", "resultCode", "data", "Landroid/content/Intent;", "onBackPressed", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "pickImages", "removeSelection", "setUpPinchToZoom", "setupFlash", "showTopViews", "startCamera", "takePhoto", "takeVideo", "it", "videoTouchListener", "Companion", "picker_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class Dazzle extends AppCompatActivity {
    public static final long ANIMATION_FAST_MILLIS = 50;
    public static final long ANIMATION_SLOW_MILLIS = 100;
    public static final String FILENAME_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS";
    private static final String PHOTO_EXTENSION = ".jpg";
    public static final String PICKED_MEDIA_LIST = "PICKED_MEDIA_LIST";
    public static final String PICKER_OPTIONS = "PICKER_OPTIONS";
    private static final double RATIO_16_9_VALUE = 1.7777777777777777d;
    private static final double RATIO_4_3_VALUE = 1.3333333333333333d;
    public static final int REQUEST_CODE_PICKER = 10;
    private static final String TAG = "Picker";
    private static final String VIDEO_EXTENSION = ".mp4";
    private BottomSheetBehavior<View> bottomSheetBehavior;
    private Camera camera;
    private ExecutorService cameraExecutor;
    private ProcessCameraProvider cameraProvider;
    private final ActivityResultLauncher<CropImageContractOptions> cropImage;
    private Recording currentRecording;
    private final ArrayList<MediaModel> galleryImageList;
    private ImageCapture imageCapture;
    private boolean isTakingVideo;
    private ActivityDazzleBinding mBinding;
    private BottomSheetMediaRecyclerAdapter mBottomMediaAdapter;
    private DazzleOptions mDazzleOptions;
    private InstantMediaRecyclerAdapter mInstantMediaAdapter;
    private final Dazzle$mMediaClickListener$1 mMediaClickListener;
    private Handler mVideoCounterHandler;
    private int mVideoCounterProgress;
    private Runnable mVideoCounterRunnable;
    private File outputDirectory;
    private Preview preview;
    private final QualitySelector qualitySelector;
    private VideoCapture<Recorder> videoCapture;

    public static final Companion INSTANCE = new Companion(null);
    private static final ArrayList<String> mPathList = new ArrayList<>();
    private static final ArrayList<Uri> mPath = new ArrayList<>();
    private static final String[] REQUIRED_PERMISSIONS = {"android.permission.CAMERA"};
    private int lensFacing = 1;
    private int flashMode = 2;

    public static final void mVideoCounterRunnable$lambda$18() {
    }

    public static final WindowInsets onCreate$lambda$2(View view, WindowInsets windowInsets) {
        Intrinsics.checkNotNullParameter(view, "<anonymous parameter 0>");
        Intrinsics.checkNotNullParameter(windowInsets, "insets");
        return windowInsets;
    }

    @JvmStatic
    public static final void startPicker(Fragment fragment, DazzleOptions dazzleOptions) {
        INSTANCE.startPicker(fragment, dazzleOptions);
    }

    @JvmStatic
    public static final void startPicker(FragmentActivity fragmentActivity, DazzleOptions dazzleOptions) {
        INSTANCE.startPicker(fragmentActivity, dazzleOptions);
    }

    @JvmStatic
    public static final void startPicker(FragmentActivity fragmentActivity, DazzleOptions dazzleOptions, ActivityResultLauncher<Intent> activityResultLauncher) {
        INSTANCE.startPicker(fragmentActivity, dazzleOptions, activityResultLauncher);
    }

    public Dazzle() {
        QualitySelector fromOrderedList = QualitySelector.fromOrderedList(CollectionsKt.listOf(new Quality[]{Quality.UHD, Quality.FHD, Quality.HD, Quality.SD}), FallbackStrategy.lowerQualityOrHigherThan(Quality.SD));
        Intrinsics.checkNotNullExpressionValue(fromOrderedList, "fromOrderedList(\n       …herThan(Quality.SD)\n    )");
        this.qualitySelector = fromOrderedList;
        ActivityResultLauncher<CropImageContractOptions> registerForActivityResult = registerForActivityResult(new CropImageContract(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                Dazzle.cropImage$lambda$16(Dazzle.this, (CropImageView.CropResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul…        }\n        }\n    }");
        this.cropImage = registerForActivityResult;
        this.mVideoCounterHandler = new Handler(Looper.getMainLooper());
        this.mVideoCounterRunnable = new Runnable() {
            @Override
            public final void run() {
                Dazzle.mVideoCounterRunnable$lambda$18();
            }
        };
        this.galleryImageList = new ArrayList<>();
        this.mMediaClickListener = new Dazzle$mMediaClickListener$1(this);
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityDazzleBinding inflate = ActivityDazzleBinding.inflate(getLayoutInflater());
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        this.mBinding = inflate;
        ActivityDazzleBinding activityDazzleBinding = null;
        if (inflate == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            inflate = null;
        }
        setContentView((View) inflate.getRoot());
        Intent intent = getIntent();
        Serializable serializableExtra = intent != null ? intent.getSerializableExtra("PICKER_OPTIONS") : null;
        Intrinsics.checkNotNull(serializableExtra, "null cannot be cast to non-null type com.aemerse.dazzle.utils.DazzleOptions");
        this.mDazzleOptions = (DazzleOptions) serializableExtra;
        ActivityDazzleBinding activityDazzleBinding2 = this.mBinding;
        if (activityDazzleBinding2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding2 = null;
        }
        activityDazzleBinding2.viewFinder.post(new Runnable() {
            @Override
            public final void run() {
                Dazzle.onCreate$lambda$1(Dazzle.this);
            }
        });
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding = activityDazzleBinding3;
        }
        activityDazzleBinding.imageViewClick.setOnClickListener(new OnDelayClickListener() {
            @Override
            public void onSingleClick(View v) {
                DazzleOptions dazzleOptions;
                boolean z;
                Recording recording;
                ActivityDazzleBinding activityDazzleBinding4;
                dazzleOptions = Dazzle.this.mDazzleOptions;
                ActivityDazzleBinding activityDazzleBinding5 = null;
                if (dazzleOptions == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                    dazzleOptions = null;
                }
                if (!dazzleOptions.getExcludeVideos()) {
                    try {
                        z = Dazzle.this.isTakingVideo;
                        if (!z) {
                            Dazzle.this.isTakingVideo = true;
                            Dazzle dazzle = Dazzle.this;
                            activityDazzleBinding4 = dazzle.mBinding;
                            if (activityDazzleBinding4 == null) {
                                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                            } else {
                                activityDazzleBinding5 = activityDazzleBinding4;
                            }
                            ImageButton imageButton = activityDazzleBinding5.imageViewClick;
                            Intrinsics.checkNotNullExpressionValue(imageButton, "mBinding.imageViewClick");
                            dazzle.takeVideo(imageButton);
                            return;
                        }
                        Dazzle.this.isTakingVideo = false;
                        recording = Dazzle.this.currentRecording;
                        if (recording != null) {
                            recording.stop();
                            return;
                        }
                        return;
                    } catch (Exception e) {
                        e.printStackTrace();
                        return;
                    }
                }
                Dazzle.this.takePhoto();
            }
        });
        this.outputDirectory = getOutputDirectory();
        ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
        Intrinsics.checkNotNullExpressionValue(newSingleThreadExecutor, "newSingleThreadExecutor()");
        this.cameraExecutor = newSingleThreadExecutor;
        getWindow().getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public final WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
                WindowInsets onCreate$lambda$2;
                onCreate$lambda$2 = Dazzle.onCreate$lambda$2(view, windowInsets);
                return onCreate$lambda$2;
            }
        });
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public final void run() {
                Dazzle.onCreate$lambda$3(Dazzle.this);
            }
        }, 500L);
        initViews();
    }

    public static final void onCreate$lambda$1(final Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        if (dazzle.allPermissionsGranted()) {
            new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                @Override
                public final void run() {
                    Dazzle.onCreate$lambda$1$lambda$0(Dazzle.this);
                }
            }, 100L);
        }
    }

    public static final void onCreate$lambda$1$lambda$0(Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.startCamera();
    }

    public static final void onCreate$lambda$3(Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.getMedia();
    }

    private final void startCamera() {
        Context context = (Context) this;
        final ListenableFuture processCameraProvider = ProcessCameraProvider.getInstance(context);
        Intrinsics.checkNotNullExpressionValue(processCameraProvider, "getInstance(this)");
        processCameraProvider.addListener(new Runnable() {
            @Override
            public final void run() {
                Dazzle.startCamera$lambda$4(Dazzle.this, processCameraProvider);
            }
        }, ContextCompat.getMainExecutor(context));
    }

    public static final void startCamera$lambda$4(Dazzle dazzle, ListenableFuture listenableFuture) {
        int i;
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        Intrinsics.checkNotNullParameter(listenableFuture, "$cameraProviderFuture");
        dazzle.cameraProvider = (ProcessCameraProvider) listenableFuture.get();
        if (dazzle.hasBackCamera()) {
            i = 1;
        } else {
            if (!dazzle.hasFrontCamera()) {
                Toast.makeText((Context) dazzle, "Back and front camera are unavailable. Try again later!", 0).show();
                dazzle.finish();
                return;
            }
            i = 0;
        }
        dazzle.lensFacing = i;
        DazzleOptions dazzleOptions = dazzle.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (dazzleOptions.getDefaultFrontCamera() && dazzle.hasFrontCamera()) {
            dazzle.lensFacing = 0;
        }
        dazzle.bindCameraUseCases();
        dazzle.setUpPinchToZoom();
        dazzle.setupFlash();
    }

    private final void initViews() {
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.imageViewChangeCamera.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.initViews$lambda$6$lambda$5(Dazzle.this, view);
            }
        });
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (!dazzleOptions.getAllowFrontCamera()) {
            ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
            if (activityDazzleBinding3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding3 = null;
            }
            activityDazzleBinding3.imageViewChangeCamera.setVisibility(8);
        }
        DazzleOptions dazzleOptions2 = this.mDazzleOptions;
        if (dazzleOptions2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions2 = null;
        }
        if (dazzleOptions2.getHideFlipCamera()) {
            ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
            if (activityDazzleBinding4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding4 = null;
            }
            activityDazzleBinding4.imageViewChangeCamera.setVisibility(8);
        }
        DazzleOptions dazzleOptions3 = this.mDazzleOptions;
        if (dazzleOptions3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions3 = null;
        }
        if (dazzleOptions3.getExcludeVideos()) {
            ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.textViewMessageBottom.setVisibility(4);
        }
        DazzleOptions dazzleOptions4 = this.mDazzleOptions;
        if (dazzleOptions4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions4 = null;
        }
        if (dazzleOptions4.getCameraOnly()) {
            ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            activityDazzleBinding6.constraintBottomSheetTop.setVisibility(8);
            ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
            if (activityDazzleBinding7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding7 = null;
            }
            activityDazzleBinding7.imageViewArrowUp.setVisibility(8);
        }
        DazzleOptions dazzleOptions5 = this.mDazzleOptions;
        if (dazzleOptions5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions5 = null;
        }
        if (dazzleOptions5.getExcludeVideos()) {
            return;
        }
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding8;
        }
        activityDazzleBinding2.textViewMessageBottom.setText(getString(R.string.tap_to_record));
    }

    public static final void initViews$lambda$6$lambda$5(Dazzle dazzle, View view) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.lensFacing = dazzle.lensFacing == 0 ? 1 : 0;
        dazzle.bindCameraUseCases();
        dazzle.setUpPinchToZoom();
        dazzle.setupFlash();
    }

    private final void setUpPinchToZoom() {
        final ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector((Context) this, new ScaleGestureDetector.SimpleOnScaleGestureListener() {
            @Override
            public boolean onScale(ScaleGestureDetector detector) {
                Camera camera;
                Camera camera2;
                CameraControl cameraControl;
                CameraInfo cameraInfo;
                LiveData zoomState;
                ZoomState zoomState2;
                Intrinsics.checkNotNullParameter(detector, "detector");
                camera = Dazzle.this.camera;
                float zoomRatio = (camera == null || (cameraInfo = camera.getCameraInfo()) == null || (zoomState = cameraInfo.getZoomState()) == null || (zoomState2 = (ZoomState) zoomState.getValue()) == null) ? 1.0f : zoomState2.getZoomRatio();
                float scaleFactor = detector.getScaleFactor();
                camera2 = Dazzle.this.camera;
                if (camera2 == null || (cameraControl = camera2.getCameraControl()) == null) {
                    return true;
                }
                cameraControl.setZoomRatio(zoomRatio * scaleFactor);
                return true;
            }
        });
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.viewFinder.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                boolean upPinchToZoom$lambda$8;
                upPinchToZoom$lambda$8 = Dazzle.setUpPinchToZoom$lambda$8(Dazzle.this, scaleGestureDetector, view, motionEvent);
                return upPinchToZoom$lambda$8;
            }
        });
    }

    public static final boolean setUpPinchToZoom$lambda$8(Dazzle dazzle, final ScaleGestureDetector scaleGestureDetector, View view, final MotionEvent motionEvent) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        Intrinsics.checkNotNullParameter(scaleGestureDetector, "$scaleGestureDetector");
        ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.viewFinder.post(new Runnable() {
            @Override
            public final void run() {
                Dazzle.setUpPinchToZoom$lambda$8$lambda$7(scaleGestureDetector, motionEvent);
            }
        });
        return true;
    }

    public static final void setUpPinchToZoom$lambda$8$lambda$7(ScaleGestureDetector scaleGestureDetector, MotionEvent motionEvent) {
        Intrinsics.checkNotNullParameter(scaleGestureDetector, "$scaleGestureDetector");
        scaleGestureDetector.onTouchEvent(motionEvent);
    }

    private final void setupFlash() {
        CameraInfo cameraInfo;
        this.flashMode = 2;
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.imageViewFlash.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_baseline_flash_off_36, (Resources.Theme) null));
        Camera camera = this.camera;
        Boolean valueOf = (camera == null || (cameraInfo = camera.getCameraInfo()) == null) ? null : Boolean.valueOf(cameraInfo.hasFlashUnit());
        if (valueOf == null || !valueOf.booleanValue()) {
            ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
            if (activityDazzleBinding3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding3 = null;
            }
            activityDazzleBinding3.imageViewFlash.setVisibility(8);
        } else {
            ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
            if (activityDazzleBinding4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding4 = null;
            }
            activityDazzleBinding4.imageViewFlash.setVisibility(0);
        }
        ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
        if (activityDazzleBinding5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding5;
        }
        activityDazzleBinding2.imageViewFlash.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.setupFlash$lambda$9(Dazzle.this, view);
            }
        });
    }

    public static final void setupFlash$lambda$9(Dazzle dazzle, View view) {
        CameraControl cameraControl;
        CameraControl cameraControl2;
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        int i = dazzle.flashMode;
        if (i == 1) {
            ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
            if (activityDazzleBinding == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding = null;
            }
            activityDazzleBinding.imageViewFlash.setImageDrawable(ResourcesCompat.getDrawable(dazzle.getResources(), R.drawable.ic_baseline_flash_off_36, (Resources.Theme) null));
            Camera camera = dazzle.camera;
            if (camera != null && (cameraControl = camera.getCameraControl()) != null) {
                cameraControl.enableTorch(false);
            }
            dazzle.flashMode = 2;
            return;
        }
        if (i != 2) {
            return;
        }
        ActivityDazzleBinding activityDazzleBinding2 = dazzle.mBinding;
        if (activityDazzleBinding2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding2 = null;
        }
        activityDazzleBinding2.imageViewFlash.setImageDrawable(ResourcesCompat.getDrawable(dazzle.getResources(), R.drawable.ic_baseline_flash_on_36, (Resources.Theme) null));
        Camera camera2 = dazzle.camera;
        if (camera2 != null && (cameraControl2 = camera2.getCameraControl()) != null) {
            cameraControl2.enableTorch(true);
        }
        dazzle.flashMode = 1;
    }

    private final void bindCameraUseCases() {
        Camera bindToLifecycle;
        DisplayMetrics displayMetrics = new DisplayMetrics();
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.viewFinder.getDisplay().getRealMetrics(displayMetrics);
        Log.d(TAG, "Screen metrics: " + displayMetrics.widthPixels + " x " + displayMetrics.heightPixels);
        int aspectRatio = aspectRatio(displayMetrics.widthPixels, displayMetrics.heightPixels);
        StringBuilder sb = new StringBuilder();
        sb.append("Preview aspect ratio: ");
        sb.append(aspectRatio);
        Log.d(TAG, sb.toString());
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        int rotation = activityDazzleBinding3.viewFinder.getDisplay().getRotation();
        ProcessCameraProvider processCameraProvider = this.cameraProvider;
        if (processCameraProvider == null) {
            throw new IllegalStateException("Camera initialization failed.");
        }
        CameraSelector build = new CameraSelector.Builder().requireLensFacing(this.lensFacing).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder().requireLensFacing(lensFacing).build()");
        this.preview = new Preview.Builder().setTargetAspectRatio(aspectRatio).setTargetRotation(rotation).build();
        this.imageCapture = new ImageCapture.Builder().setCaptureMode(1).setTargetAspectRatio(aspectRatio).setTargetRotation(rotation).build();
        VideoOutput build2 = new Recorder.Builder().setQualitySelector(this.qualitySelector).build();
        Intrinsics.checkNotNullExpressionValue(build2, "Builder().setQualitySele…(qualitySelector).build()");
        VideoCapture.Builder mirrorMode = new VideoCapture.Builder(build2).setMirrorMode(2);
        Intrinsics.checkNotNullExpressionValue(mirrorMode, "Builder<Recorder>(record…IRROR_MODE_ON_FRONT_ONLY)");
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (dazzleOptions.getChangeFrameRate()) {
            mirrorMode.setTargetFrameRate(new Range((Comparable) 10, (Comparable) 15));
        }
        this.videoCapture = mirrorMode.build();
        processCameraProvider.unbindAll();
        try {
            DazzleOptions dazzleOptions2 = this.mDazzleOptions;
            if (dazzleOptions2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                dazzleOptions2 = null;
            }
            if (dazzleOptions2.getExcludeVideos()) {
                bindToLifecycle = processCameraProvider.bindToLifecycle((LifecycleOwner) this, build, new UseCase[]{(UseCase) this.preview, (UseCase) this.imageCapture});
            } else {
                DazzleOptions dazzleOptions3 = this.mDazzleOptions;
                if (dazzleOptions3 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                    dazzleOptions3 = null;
                }
                if (dazzleOptions3.getHideFlipCamera()) {
                    bindToLifecycle = processCameraProvider.bindToLifecycle((LifecycleOwner) this, build, new UseCase[]{(UseCase) this.preview, (UseCase) this.videoCapture});
                } else {
                    DazzleOptions dazzleOptions4 = this.mDazzleOptions;
                    if (dazzleOptions4 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                        dazzleOptions4 = null;
                    }
                    if (dazzleOptions4.getFrontCameraOnly()) {
                        bindToLifecycle = processCameraProvider.bindToLifecycle((LifecycleOwner) this, build, new UseCase[]{(UseCase) this.preview, (UseCase) this.videoCapture});
                    } else {
                        bindToLifecycle = processCameraProvider.bindToLifecycle((LifecycleOwner) this, build, new UseCase[]{(UseCase) this.preview, (UseCase) this.imageCapture, (UseCase) this.videoCapture});
                    }
                }
            }
            this.camera = bindToLifecycle;
            Preview preview = this.preview;
            if (preview != null) {
                ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
                if (activityDazzleBinding4 == null) {
                    Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                } else {
                    activityDazzleBinding2 = activityDazzleBinding4;
                }
                preview.setSurfaceProvider(activityDazzleBinding2.viewFinder.getSurfaceProvider());
            }
        } catch (Exception e) {
            Log.e(TAG, "Use case binding failed", e);
            Toast.makeText((Context) this, "Camera failure " + e.getMessage(), 1).show();
        }
        videoTouchListener();
    }

    public final void takePhoto() {
        ImageCapture imageCapture;
        if (this.isTakingVideo || (imageCapture = this.imageCapture) == null) {
            return;
        }
        mPathList.clear();
        File file = this.outputDirectory;
        ActivityDazzleBinding activityDazzleBinding = null;
        if (file == null) {
            Intrinsics.throwUninitializedPropertyAccessException("outputDirectory");
            file = null;
        }
        File file2 = new File(file, new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.ENGLISH).format(Long.valueOf(System.currentTimeMillis())) + PHOTO_EXTENSION);
        ImageCapture.Metadata metadata = new ImageCapture.Metadata();
        metadata.setReversedHorizontal(this.lensFacing == 0);
        ImageCapture.OutputFileOptions build = new ImageCapture.OutputFileOptions.Builder(file2).setMetadata(metadata).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder(photoFile).setMetadata(metadata).build()");
        ExecutorService executorService = this.cameraExecutor;
        if (executorService == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cameraExecutor");
            executorService = null;
        }
        imageCapture.takePicture(build, executorService, new Dazzle$takePhoto$1$1(file2, this));
        if (Build.VERSION.SDK_INT >= 23) {
            ActivityDazzleBinding activityDazzleBinding2 = this.mBinding;
            if (activityDazzleBinding2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            } else {
                activityDazzleBinding = activityDazzleBinding2;
            }
            activityDazzleBinding.coordinatorLayout.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    Dazzle.takePhoto$lambda$14$lambda$13(Dazzle.this);
                }
            }, 100L);
        }
    }

    public static final void takePhoto$lambda$14$lambda$13(final Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.coordinatorLayout.setForeground(new ColorDrawable(-1));
        ActivityDazzleBinding activityDazzleBinding3 = dazzle.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding3;
        }
        activityDazzleBinding2.coordinatorLayout.postDelayed(new Runnable() {
            @Override
            public final void run() {
                Dazzle.takePhoto$lambda$14$lambda$13$lambda$12(Dazzle.this);
            }
        }, 50L);
    }

    public static final void takePhoto$lambda$14$lambda$13$lambda$12(Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.coordinatorLayout.setForeground((Drawable) null);
    }

    public static final void cropImage$lambda$16(Dazzle dazzle, CropImageView.CropResult cropResult) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        if (cropResult.isSuccessful()) {
            Intrinsics.checkNotNullExpressionValue(cropResult, "result");
            Context context = (Context) dazzle;
            String uriFilePath$default = CropImageView.CropResult.getUriFilePath$default(cropResult, context, false, 2, null);
            MimeTypeMap singleton = MimeTypeMap.getSingleton();
            Intrinsics.checkNotNull(uriFilePath$default);
            MediaScannerConnection.scanFile(context, new String[]{uriFilePath$default}, new String[]{singleton.getMimeTypeFromExtension(FilesKt.getExtension(new File(uriFilePath$default)))}, new MediaScannerConnection.OnScanCompletedListener() {
                @Override
                public final void onScanCompleted(String str, Uri uri) {
                    Dazzle.cropImage$lambda$16$lambda$15(str, uri);
                }
            });
            ArrayList<String> arrayList = mPathList;
            arrayList.add(uriFilePath$default.toString());
            Intent intent = new Intent();
            intent.putExtra("PICKED_MEDIA_LIST", arrayList);
            dazzle.setResult(-1, intent);
            dazzle.finish();
            return;
        }
        dazzle.setResult(0, dazzle.getIntent());
        dazzle.finish();
    }

    public static final void cropImage$lambda$16$lambda$15(String str, Uri uri) {
        Log.d(TAG, "Image capture scanned into media store: " + uri);
    }

    private final void videoTouchListener() {
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.imageViewClick.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                boolean videoTouchListener$lambda$17;
                videoTouchListener$lambda$17 = Dazzle.videoTouchListener$lambda$17(Dazzle.this, view, motionEvent);
                return videoTouchListener$lambda$17;
            }
        });
    }

    public static final boolean videoTouchListener$lambda$17(Dazzle dazzle, View view, MotionEvent motionEvent) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        ActivityDazzleBinding activityDazzleBinding = null;
        if (motionEvent.getAction() == 1) {
            ActivityDazzleBinding activityDazzleBinding2 = dazzle.mBinding;
            if (activityDazzleBinding2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding2 = null;
            }
            activityDazzleBinding2.imageViewVideoRedBg.setVisibility(8);
            ActivityDazzleBinding activityDazzleBinding3 = dazzle.mBinding;
            if (activityDazzleBinding3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding3 = null;
            }
            activityDazzleBinding3.imageViewVideoRedBg.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300L).setInterpolator(new AccelerateDecelerateInterpolator()).start();
            ActivityDazzleBinding activityDazzleBinding4 = dazzle.mBinding;
            if (activityDazzleBinding4 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            } else {
                activityDazzleBinding = activityDazzleBinding4;
            }
            activityDazzleBinding.imageViewClick.animate().scaleX(1.0f).scaleY(1.0f).setDuration(300L).setInterpolator(new AccelerateDecelerateInterpolator()).start();
        } else if (motionEvent.getAction() == 0) {
            ActivityDazzleBinding activityDazzleBinding5 = dazzle.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.imageViewVideoRedBg.setVisibility(0);
            ActivityDazzleBinding activityDazzleBinding6 = dazzle.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            activityDazzleBinding6.imageViewVideoRedBg.animate().scaleX(1.2f).scaleY(1.2f).setDuration(300L).setInterpolator(new AccelerateDecelerateInterpolator()).start();
            ActivityDazzleBinding activityDazzleBinding7 = dazzle.mBinding;
            if (activityDazzleBinding7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            } else {
                activityDazzleBinding = activityDazzleBinding7;
            }
            activityDazzleBinding.imageViewClick.animate().scaleX(1.2f).scaleY(1.2f).setDuration(300L).setInterpolator(new AccelerateDecelerateInterpolator()).start();
        }
        return false;
    }

    public final void takeVideo(View it) {
        PendingRecording withAudioEnabled;
        Recorder output;
        mPathList.clear();
        File file = this.outputDirectory;
        Recording recording = null;
        if (file == null) {
            Intrinsics.throwUninitializedPropertyAccessException("outputDirectory");
            file = null;
        }
        final File file2 = new File(file, new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.ENGLISH).format(Long.valueOf(System.currentTimeMillis())) + VIDEO_EXTENSION);
        FileOutputOptions build = new FileOutputOptions.Builder(file2).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder(videoFile).build()");
        this.isTakingVideo = true;
        it.performHapticFeedback(1);
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.constraintTimer.setVisibility(0);
        ActivityDazzleBinding activityDazzleBinding2 = this.mBinding;
        if (activityDazzleBinding2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding2 = null;
        }
        activityDazzleBinding2.progressbarVideoCounter.setProgress(0);
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        ProgressBar progressBar = activityDazzleBinding3.progressbarVideoCounter;
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        progressBar.setMax(dazzleOptions.getMaxVideoDuration());
        ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        activityDazzleBinding4.progressbarVideoCounter.invalidate();
        DazzleOptions dazzleOptions2 = this.mDazzleOptions;
        if (dazzleOptions2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions2 = null;
        }
        if (dazzleOptions2.getReverseCount()) {
            StringBuilder sb = new StringBuilder();
            sb.append("00:");
            DazzleOptions dazzleOptions3 = this.mDazzleOptions;
            if (dazzleOptions3 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                dazzleOptions3 = null;
            }
            sb.append(dazzleOptions3.getMaxVideoDuration());
            String sb2 = sb.toString();
            ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.textViewVideoTimer.setText(sb2);
        }
        Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                Dazzle.takeVideo$lambda$19(Dazzle.this);
            }
        };
        this.mVideoCounterRunnable = runnable;
        Handler handler = this.mVideoCounterHandler;
        if (handler != null) {
            handler.postDelayed(runnable, 1000L);
        }
        ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
        if (activityDazzleBinding6 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding6 = null;
        }
        activityDazzleBinding6.imageViewClick.animate().scaleX(1.2f).scaleY(1.2f).setDuration(300L).setInterpolator(new AccelerateDecelerateInterpolator()).start();
        ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
        if (activityDazzleBinding7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding7 = null;
        }
        activityDazzleBinding7.imageViewFlash.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding8 = null;
        }
        activityDazzleBinding8.imageViewChangeCamera.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding9 = this.mBinding;
        if (activityDazzleBinding9 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding9 = null;
        }
        activityDazzleBinding9.textViewMessageBottom.setVisibility(8);
        Context context = (Context) this;
        if (ActivityCompat.checkSelfPermission(context, "android.permission.RECORD_AUDIO") != 0) {
            return;
        }
        VideoCapture<Recorder> videoCapture = this.videoCapture;
        PendingRecording prepareRecording = (videoCapture == null || (output = videoCapture.getOutput()) == null) ? null : output.prepareRecording(context, build);
        if (prepareRecording != null && (withAudioEnabled = prepareRecording.withAudioEnabled()) != null) {
            Recording recording2 = this.cameraExecutor;
            if (recording2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("cameraExecutor");
            } else {
                recording = recording2;
            }
            recording = withAudioEnabled.start((Executor) recording, new Consumer() {
                public final void accept(Object obj) {
                    Dazzle.takeVideo$lambda$22(file2, this, (VideoRecordEvent) obj);
                }
            });
        }
        this.currentRecording = recording;
    }

    public static final void takeVideo$lambda$19(Dazzle dazzle) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.mVideoCounterProgress++;
        ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.progressbarVideoCounter.setProgress(dazzle.mVideoCounterProgress);
        int i = 0;
        String valueOf = String.valueOf(dazzle.mVideoCounterProgress);
        int i2 = dazzle.mVideoCounterProgress;
        if (i2 > 59) {
            i = i2 / 60;
            valueOf = String.valueOf(i2 - (i * 60));
        }
        if (valueOf.length() == 1) {
            StringBuilder sb = new StringBuilder();
            sb.append('0');
            sb.append(dazzle.mVideoCounterProgress);
            valueOf = sb.toString();
        }
        String str = '0' + i + ':' + valueOf;
        DazzleOptions dazzleOptions = dazzle.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (dazzleOptions.getReverseCount()) {
            Log.e(TAG, "takeVideo: mVideoCounterProgress " + dazzle.mVideoCounterProgress);
            DazzleOptions dazzleOptions2 = dazzle.mDazzleOptions;
            if (dazzleOptions2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
                dazzleOptions2 = null;
            }
            int maxVideoDuration = dazzleOptions2.getMaxVideoDuration() - dazzle.mVideoCounterProgress;
            Log.e(TAG, "takeVideo: seconds " + maxVideoDuration);
            StringBuilder sb2 = new StringBuilder();
            sb2.append('0');
            sb2.append(i);
            sb2.append(':');
            sb2.append(maxVideoDuration);
            str = sb2.toString();
            ActivityDazzleBinding activityDazzleBinding2 = dazzle.mBinding;
            if (activityDazzleBinding2 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding2 = null;
            }
            ImageButton imageButton = activityDazzleBinding2.imageViewClick;
            Intrinsics.checkNotNullExpressionValue(imageButton, "mBinding.imageViewClick");
            imageButton.setVisibility(8);
        }
        ActivityDazzleBinding activityDazzleBinding3 = dazzle.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.textViewVideoTimer.setText(str);
        int i3 = dazzle.mVideoCounterProgress;
        DazzleOptions dazzleOptions3 = dazzle.mDazzleOptions;
        if (dazzleOptions3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions3 = null;
        }
        if (i3 == dazzleOptions3.getMaxVideoDuration()) {
            Handler handler = dazzle.mVideoCounterHandler;
            if (handler != null) {
                handler.removeCallbacks(dazzle.mVideoCounterRunnable);
            }
            Recording recording = dazzle.currentRecording;
            if (recording != null) {
                recording.stop();
            }
            dazzle.mVideoCounterHandler = null;
        }
        Handler handler2 = dazzle.mVideoCounterHandler;
        if (handler2 != null) {
            handler2.postDelayed(dazzle.mVideoCounterRunnable, 1000L);
        }
    }

    public static final void takeVideo$lambda$22(File file, Dazzle dazzle, VideoRecordEvent videoRecordEvent) {
        Intrinsics.checkNotNullParameter(file, "$videoFile");
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        boolean z = videoRecordEvent instanceof VideoRecordEvent.Status;
        if (videoRecordEvent instanceof VideoRecordEvent.Finalize) {
            VideoRecordEvent.Finalize finalize = (VideoRecordEvent.Finalize) videoRecordEvent;
            finalize.getOutputResults().getOutputUri();
            Uri outputUri = finalize.getOutputResults().getOutputUri();
            if (outputUri == null) {
                outputUri = Uri.fromFile(file);
            }
            Handler handler = dazzle.mVideoCounterHandler;
            if (handler != null && handler != null) {
                handler.removeCallbacks(dazzle.mVideoCounterRunnable);
            }
            Log.d(TAG, "Video capture succeeded: " + outputUri);
            try {
                MimeTypeMap singleton = MimeTypeMap.getSingleton();
                Intrinsics.checkNotNullExpressionValue(outputUri, "savedUri");
                MediaScannerConnection.scanFile((Context) dazzle, new String[]{UriKt.toFile(outputUri).getAbsolutePath()}, new String[]{singleton.getMimeTypeFromExtension(FilesKt.getExtension(UriKt.toFile(outputUri)))}, new MediaScannerConnection.OnScanCompletedListener() {
                    @Override
                    public final void onScanCompleted(String str, Uri uri) {
                        Dazzle.takeVideo$lambda$22$lambda$21(str, uri);
                    }
                });
            } catch (Exception e) {
                Log.e(TAG, "takeVideo: ", e);
            }
            ArrayList<String> arrayList = mPathList;
            arrayList.add(outputUri.toString());
            Intent intent = new Intent();
            intent.putExtra("PICKED_MEDIA_LIST", arrayList);
            dazzle.setResult(-1, intent);
            dazzle.finish();
            dazzle.isTakingVideo = false;
        }
    }

    public static final void takeVideo$lambda$22$lambda$21(String str, Uri uri) {
        Log.d(TAG, "Image capture scanned into media store: " + uri);
    }

    protected void onDestroy() {
        super.onDestroy();
        ExecutorService executorService = this.cameraExecutor;
        if (executorService == null) {
            Intrinsics.throwUninitializedPropertyAccessException("cameraExecutor");
            executorService = null;
        }
        executorService.shutdown();
    }

    @Deprecated(message = "Deprecated in Java")
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != -1 || requestCode != 69) {
            if (resultCode == 96) {
                Intrinsics.checkNotNull(data);
                UCrop.getError(data);
                finish();
                return;
            }
            return;
        }
        Intrinsics.checkNotNull(data);
        Uri output = UCrop.getOutput(data);
        Log.e(TAG, "onActivityResult: " + output);
        ArrayList<String> arrayList = mPathList;
        arrayList.clear();
        arrayList.add(String.valueOf(output));
        getIntent().putExtra("PICKED_MEDIA_LIST", arrayList);
        setResult(-1, getIntent());
        finish();
    }

    private final void getMedia() {
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (dazzleOptions.getCameraOnly()) {
            return;
        }
        BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getMain()), (CoroutineContext) null, (CoroutineStart) null, new Dazzle$getMedia$1(this, null), 3, (Object) null);
    }

    public final void showTopViews() {
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.constraintCheck.setVisibility(0);
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.textViewOk.setVisibility(0);
        ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        activityDazzleBinding4.imageViewCheck.setVisibility(8);
        if (Build.VERSION.SDK_INT >= 23) {
            ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.constraintBottomSheetTop.setBackgroundColor(getResources().getColor(R.color.colorPrimary, null));
            ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            DrawableCompat.setTint(activityDazzleBinding6.imageViewBack.getDrawable(), getResources().getColor(R.color.colorWhite, null));
            return;
        }
        ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
        if (activityDazzleBinding7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding7 = null;
        }
        activityDazzleBinding7.constraintBottomSheetTop.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary));
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding8;
        }
        DrawableCompat.setTint(activityDazzleBinding2.imageViewBack.getDrawable(), ContextCompat.getColor(getApplicationContext(), R.color.colorWhite));
    }

    public final void hideTopViews() {
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.constraintCheck.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.textViewOk.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        activityDazzleBinding4.imageViewCheck.setVisibility(0);
        if (Build.VERSION.SDK_INT >= 23) {
            ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.constraintBottomSheetTop.setBackgroundColor(getResources().getColor(R.color.colorWhite, null));
            ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            DrawableCompat.setTint(activityDazzleBinding6.imageViewBack.getDrawable(), getResources().getColor(R.color.colorBlack, null));
            return;
        }
        ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
        if (activityDazzleBinding7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding7 = null;
        }
        activityDazzleBinding7.constraintBottomSheetTop.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorWhite));
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding8;
        }
        DrawableCompat.setTint(activityDazzleBinding2.imageViewBack.getDrawable(), ContextCompat.getColor(getApplicationContext(), R.color.colorBlack));
    }

    public final void handleBottomSheet() {
        Context context = (Context) this;
        BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter = new BottomSheetMediaRecyclerAdapter(this.galleryImageList, this.mMediaClickListener, context);
        this.mBottomMediaAdapter = bottomSheetMediaRecyclerAdapter;
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        ActivityDazzleBinding activityDazzleBinding = null;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        bottomSheetMediaRecyclerAdapter.setMaxCount(dazzleOptions.getMaxCount());
        RecyclerView.LayoutManager gridLayoutManager = new GridLayoutManager(context, 4);
        ActivityDazzleBinding activityDazzleBinding2 = this.mBinding;
        if (activityDazzleBinding2 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding2 = null;
        }
        activityDazzleBinding2.recyclerViewBottomSheetMedia.setLayoutManager(gridLayoutManager);
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            public int getSpanSize(int position) {
                BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter2;
                bottomSheetMediaRecyclerAdapter2 = Dazzle.this.mBottomMediaAdapter;
                boolean z = false;
                if (bottomSheetMediaRecyclerAdapter2 != null && bottomSheetMediaRecyclerAdapter2.getItemViewType(position) == 1) {
                    z = true;
                }
                return z ? 4 : 1;
            }
        });
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.recyclerViewBottomSheetMedia.setAdapter(this.mBottomMediaAdapter);
        ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        RecyclerView recyclerView = activityDazzleBinding4.recyclerViewBottomSheetMedia;
        BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter2 = this.mBottomMediaAdapter;
        Intrinsics.checkNotNull(bottomSheetMediaRecyclerAdapter2);
        recyclerView.addItemDecoration(new HeaderItemDecoration(bottomSheetMediaRecyclerAdapter2, context));
        ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
        if (activityDazzleBinding5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding5 = null;
        }
        this.bottomSheetBehavior = BottomSheetBehavior.from(activityDazzleBinding5.bottomSheet);
        final Ref.BooleanRef booleanRef = new Ref.BooleanRef();
        final Ref.BooleanRef booleanRef2 = new Ref.BooleanRef();
        BottomSheetBehavior<View> bottomSheetBehavior = this.bottomSheetBehavior;
        if (bottomSheetBehavior != null) {
            bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
                private float oldOffSet;

                public void onStateChanged(View bottomSheet, int newState) {
                    Intrinsics.checkNotNullParameter(bottomSheet, "bottomSheet");
                }

                public final float getOldOffSet() {
                    return this.oldOffSet;
                }

                public final void setOldOffSet(float f) {
                    this.oldOffSet = f;
                }

                public void onSlide(View bottomSheet, float slideOffset) {
                    ActivityDazzleBinding activityDazzleBinding6;
                    InstantMediaRecyclerAdapter instantMediaRecyclerAdapter;
                    ArrayList arrayList;
                    InstantMediaRecyclerAdapter instantMediaRecyclerAdapter2;
                    ActivityDazzleBinding activityDazzleBinding7;
                    InstantMediaRecyclerAdapter instantMediaRecyclerAdapter3;
                    BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter3;
                    int intValue;
                    ActivityDazzleBinding activityDazzleBinding8;
                    InstantMediaRecyclerAdapter instantMediaRecyclerAdapter4;
                    BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter4;
                    ArrayList arrayList2;
                    BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter5;
                    ActivityDazzleBinding activityDazzleBinding9;
                    Intrinsics.checkNotNullParameter(bottomSheet, "bottomSheet");
                    float f = this.oldOffSet;
                    int i = 0;
                    boolean z = f < slideOffset;
                    boolean z2 = f > slideOffset;
                    this.oldOffSet = slideOffset;
                    ActivityDazzleBinding activityDazzleBinding10 = null;
                    if (slideOffset == 1.0f) {
                        booleanRef.element = false;
                        booleanRef2.element = false;
                        activityDazzleBinding9 = this.mBinding;
                        if (activityDazzleBinding9 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                            activityDazzleBinding9 = null;
                        }
                        activityDazzleBinding9.imageViewArrowUp.setVisibility(4);
                    } else {
                        if (slideOffset == 0.0f) {
                            booleanRef.element = false;
                            booleanRef2.element = false;
                            activityDazzleBinding6 = this.mBinding;
                            if (activityDazzleBinding6 == null) {
                                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                                activityDazzleBinding6 = null;
                            }
                            activityDazzleBinding6.imageViewArrowUp.setVisibility(0);
                        }
                    }
                    if (slideOffset > 0.6f && slideOffset < 0.8f) {
                        if (!booleanRef.element && z) {
                            Log.e("Picker", "onSlide 1: " + slideOffset);
                            bottomSheetMediaRecyclerAdapter4 = this.mBottomMediaAdapter;
                            if (bottomSheetMediaRecyclerAdapter4 != null) {
                                bottomSheetMediaRecyclerAdapter4.notifyDataSetChanged();
                            }
                            booleanRef.element = true;
                            arrayList2 = this.galleryImageList;
                            ArrayList arrayList3 = arrayList2;
                            ArrayList arrayList4 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList3, 10));
                            Iterator it = arrayList3.iterator();
                            while (it.hasNext()) {
                                if (((MediaModel) it.next()).getIsSelected()) {
                                    i++;
                                }
                                arrayList4.add(Unit.INSTANCE);
                            }
                            bottomSheetMediaRecyclerAdapter5 = this.mBottomMediaAdapter;
                            if (bottomSheetMediaRecyclerAdapter5 != null) {
                                bottomSheetMediaRecyclerAdapter5.setImageCount(i);
                            }
                        }
                    } else if (slideOffset > 0.1f && slideOffset < 0.3f && !booleanRef2.element && z2) {
                        Log.e("Picker", "onSlide 2: " + slideOffset);
                        instantMediaRecyclerAdapter = this.mInstantMediaAdapter;
                        if (instantMediaRecyclerAdapter != null) {
                            instantMediaRecyclerAdapter.notifyDataSetChanged();
                        }
                        booleanRef2.element = true;
                        arrayList = this.galleryImageList;
                        ArrayList arrayList5 = arrayList;
                        ArrayList arrayList6 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList5, 10));
                        Iterator it2 = arrayList5.iterator();
                        while (it2.hasNext()) {
                            if (((MediaModel) it2.next()).getIsSelected()) {
                                i++;
                            }
                            arrayList6.add(Unit.INSTANCE);
                        }
                        instantMediaRecyclerAdapter2 = this.mInstantMediaAdapter;
                        if (instantMediaRecyclerAdapter2 != null) {
                            instantMediaRecyclerAdapter2.setImageCount(i);
                        }
                        activityDazzleBinding7 = this.mBinding;
                        if (activityDazzleBinding7 == null) {
                            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                            activityDazzleBinding7 = null;
                        }
                        activityDazzleBinding7.textViewImageCount.setText(String.valueOf(i));
                    }
                    instantMediaRecyclerAdapter3 = this.mInstantMediaAdapter;
                    Integer valueOf = instantMediaRecyclerAdapter3 != null ? Integer.valueOf(instantMediaRecyclerAdapter3.getImageCount()) : null;
                    Intrinsics.checkNotNull(valueOf);
                    if (valueOf.intValue() > 0) {
                        instantMediaRecyclerAdapter4 = this.mInstantMediaAdapter;
                        Integer valueOf2 = instantMediaRecyclerAdapter4 != null ? Integer.valueOf(instantMediaRecyclerAdapter4.getImageCount()) : null;
                        Intrinsics.checkNotNull(valueOf2);
                        intValue = valueOf2.intValue();
                    } else {
                        bottomSheetMediaRecyclerAdapter3 = this.mBottomMediaAdapter;
                        Integer valueOf3 = bottomSheetMediaRecyclerAdapter3 != null ? Integer.valueOf(bottomSheetMediaRecyclerAdapter3.getImageCount()) : null;
                        Intrinsics.checkNotNull(valueOf3);
                        intValue = valueOf3.intValue();
                    }
                    GeneralUtils generalUtils = GeneralUtils.INSTANCE;
                    activityDazzleBinding8 = this.mBinding;
                    if (activityDazzleBinding8 == null) {
                        Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                    } else {
                        activityDazzleBinding10 = activityDazzleBinding8;
                    }
                    generalUtils.manipulateBottomSheetVisibility(slideOffset, activityDazzleBinding10, intValue);
                }
            });
        }
        ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
        if (activityDazzleBinding6 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding6 = null;
        }
        activityDazzleBinding6.imageViewBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.handleBottomSheet$lambda$23(Dazzle.this, view);
            }
        });
        ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
        if (activityDazzleBinding7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding7 = null;
        }
        activityDazzleBinding7.constraintCheck.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.handleBottomSheet$lambda$24(Dazzle.this, view);
            }
        });
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding8 = null;
        }
        activityDazzleBinding8.textViewOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.handleBottomSheet$lambda$25(Dazzle.this, view);
            }
        });
        ActivityDazzleBinding activityDazzleBinding9 = this.mBinding;
        if (activityDazzleBinding9 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding = activityDazzleBinding9;
        }
        activityDazzleBinding.imageViewCheck.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                Dazzle.handleBottomSheet$lambda$26(Dazzle.this, view);
            }
        });
    }

    public static final void handleBottomSheet$lambda$23(Dazzle dazzle, View view) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        BottomSheetBehavior<View> bottomSheetBehavior = dazzle.bottomSheetBehavior;
        if (bottomSheetBehavior != null) {
            bottomSheetBehavior.setState(4);
        }
    }

    public static final void handleBottomSheet$lambda$24(Dazzle dazzle, View view) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.pickImages();
    }

    public static final void handleBottomSheet$lambda$25(Dazzle dazzle, View view) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        dazzle.pickImages();
    }

    public static final void handleBottomSheet$lambda$26(Dazzle dazzle, View view) {
        Intrinsics.checkNotNullParameter(dazzle, "this$0");
        ActivityDazzleBinding activityDazzleBinding = dazzle.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.constraintCheck.setVisibility(0);
        ActivityDazzleBinding activityDazzleBinding3 = dazzle.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.textViewOk.setVisibility(0);
        ActivityDazzleBinding activityDazzleBinding4 = dazzle.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        activityDazzleBinding4.textViewTopSelect.setText(dazzle.getResources().getString(R.string.tap_to_select));
        BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter = dazzle.mBottomMediaAdapter;
        if (bottomSheetMediaRecyclerAdapter != null) {
            bottomSheetMediaRecyclerAdapter.setMTapToSelect(true);
        }
        ActivityDazzleBinding activityDazzleBinding5 = dazzle.mBinding;
        if (activityDazzleBinding5 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding5 = null;
        }
        activityDazzleBinding5.imageViewCheck.setVisibility(8);
        if (Build.VERSION.SDK_INT >= 23) {
            ActivityDazzleBinding activityDazzleBinding6 = dazzle.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            activityDazzleBinding6.constraintBottomSheetTop.setBackgroundColor(dazzle.getResources().getColor(R.color.colorPrimary, null));
            ActivityDazzleBinding activityDazzleBinding7 = dazzle.mBinding;
            if (activityDazzleBinding7 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding7 = null;
            }
            DrawableCompat.setTint(activityDazzleBinding7.imageViewBack.getDrawable(), dazzle.getResources().getColor(R.color.colorWhite, null));
            return;
        }
        ActivityDazzleBinding activityDazzleBinding8 = dazzle.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding8 = null;
        }
        activityDazzleBinding8.constraintBottomSheetTop.setBackgroundColor(ContextCompat.getColor(dazzle.getApplicationContext(), R.color.colorPrimary));
        ActivityDazzleBinding activityDazzleBinding9 = dazzle.mBinding;
        if (activityDazzleBinding9 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding9;
        }
        DrawableCompat.setTint(activityDazzleBinding2.imageViewBack.getDrawable(), ContextCompat.getColor(dazzle.getApplicationContext(), R.color.colorWhite));
    }

    public final void pickImages() {
        ArrayList<MediaModel> arrayList = this.galleryImageList;
        ArrayList arrayList2 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList, 10));
        for (MediaModel mediaModel : arrayList) {
            if (mediaModel.getIsSelected()) {
                ArrayList<String> arrayList3 = mPathList;
                MediaConstants mediaConstants = MediaConstants.INSTANCE;
                ContentResolver contentResolver = getContentResolver();
                Intrinsics.checkNotNullExpressionValue(contentResolver, "contentResolver");
                Uri mMediaUri = mediaModel.getMMediaUri();
                Intrinsics.checkNotNull(mMediaUri);
                File cacheDir = getCacheDir();
                Intrinsics.checkNotNullExpressionValue(cacheDir, "cacheDir");
                arrayList3.add(mediaConstants.getFileFromUri(contentResolver, mMediaUri, cacheDir).getPath());
                if (mediaModel.getMMediaType() == 1) {
                    ArrayList<Uri> arrayList4 = mPath;
                    Uri mMediaUri2 = mediaModel.getMMediaUri();
                    Intrinsics.checkNotNull(mMediaUri2);
                    arrayList4.add(mMediaUri2);
                }
            }
            arrayList2.add(Unit.INSTANCE);
        }
        DazzleOptions dazzleOptions = this.mDazzleOptions;
        if (dazzleOptions == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mDazzleOptions");
            dazzleOptions = null;
        }
        if (dazzleOptions.getCropEnabled()) {
            ArrayList<Uri> arrayList5 = mPath;
            if (arrayList5.size() == 1) {
                this.cropImage.launch(CropImageContractOptionsKt.options(arrayList5.get(0), new Function1<CropImageContractOptions, Unit>() {
                    public Object invoke(Object obj) {
                        invoke((CropImageContractOptions) obj);
                        return Unit.INSTANCE;
                    }

                    public final void invoke(CropImageContractOptions cropImageContractOptions) {
                        Intrinsics.checkNotNullParameter(cropImageContractOptions, "$this$options");
                        cropImageContractOptions.setGuidelines(CropImageView.Guidelines.ON);
                        cropImageContractOptions.setOutputCompressFormat(Bitmap.CompressFormat.PNG);
                    }
                }));
                return;
            }
        }
        Intent intent = new Intent();
        intent.putExtra("PICKED_MEDIA_LIST", mPathList);
        setResult(-1, intent);
        finish();
    }

    public void onBackPressed() {
        BottomSheetBehavior<View> bottomSheetBehavior = this.bottomSheetBehavior;
        boolean z = false;
        if (bottomSheetBehavior != null && bottomSheetBehavior.getState() == 3) {
            z = true;
        }
        if (z) {
            BottomSheetBehavior<View> bottomSheetBehavior2 = this.bottomSheetBehavior;
            if (bottomSheetBehavior2 == null) {
                return;
            }
            bottomSheetBehavior2.setState(4);
            return;
        }
        InstantMediaRecyclerAdapter instantMediaRecyclerAdapter = this.mInstantMediaAdapter;
        if ((instantMediaRecyclerAdapter != null ? Integer.valueOf(instantMediaRecyclerAdapter.getImageCount()) : null) != null) {
            InstantMediaRecyclerAdapter instantMediaRecyclerAdapter2 = this.mInstantMediaAdapter;
            Integer valueOf = instantMediaRecyclerAdapter2 != null ? Integer.valueOf(instantMediaRecyclerAdapter2.getImageCount()) : null;
            Intrinsics.checkNotNull(valueOf);
            if (valueOf.intValue() > 0) {
                removeSelection();
                return;
            }
        }
        super.onBackPressed();
    }

    private final void removeSelection() {
        InstantMediaRecyclerAdapter instantMediaRecyclerAdapter = this.mInstantMediaAdapter;
        if (instantMediaRecyclerAdapter != null) {
            instantMediaRecyclerAdapter.setImageCount(0);
        }
        BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter = this.mBottomMediaAdapter;
        if (bottomSheetMediaRecyclerAdapter != null) {
            bottomSheetMediaRecyclerAdapter.setImageCount(0);
        }
        int size = this.galleryImageList.size();
        for (int i = 0; i < size; i++) {
            this.galleryImageList.get(i).setSelected(false);
        }
        InstantMediaRecyclerAdapter instantMediaRecyclerAdapter2 = this.mInstantMediaAdapter;
        if (instantMediaRecyclerAdapter2 != null) {
            instantMediaRecyclerAdapter2.notifyDataSetChanged();
        }
        BottomSheetMediaRecyclerAdapter bottomSheetMediaRecyclerAdapter2 = this.mBottomMediaAdapter;
        if (bottomSheetMediaRecyclerAdapter2 != null) {
            bottomSheetMediaRecyclerAdapter2.notifyDataSetChanged();
        }
        ActivityDazzleBinding activityDazzleBinding = this.mBinding;
        ActivityDazzleBinding activityDazzleBinding2 = null;
        if (activityDazzleBinding == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding = null;
        }
        activityDazzleBinding.constraintCheck.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding3 = this.mBinding;
        if (activityDazzleBinding3 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding3 = null;
        }
        activityDazzleBinding3.textViewOk.setVisibility(8);
        ActivityDazzleBinding activityDazzleBinding4 = this.mBinding;
        if (activityDazzleBinding4 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding4 = null;
        }
        activityDazzleBinding4.imageViewCheck.setVisibility(0);
        if (Build.VERSION.SDK_INT >= 23) {
            ActivityDazzleBinding activityDazzleBinding5 = this.mBinding;
            if (activityDazzleBinding5 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding5 = null;
            }
            activityDazzleBinding5.constraintBottomSheetTop.setBackgroundColor(getResources().getColor(R.color.colorWhite, null));
            ActivityDazzleBinding activityDazzleBinding6 = this.mBinding;
            if (activityDazzleBinding6 == null) {
                Intrinsics.throwUninitializedPropertyAccessException("mBinding");
                activityDazzleBinding6 = null;
            }
            DrawableCompat.setTint(activityDazzleBinding6.imageViewBack.getDrawable(), getResources().getColor(R.color.colorBlack, null));
            return;
        }
        ActivityDazzleBinding activityDazzleBinding7 = this.mBinding;
        if (activityDazzleBinding7 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
            activityDazzleBinding7 = null;
        }
        activityDazzleBinding7.constraintBottomSheetTop.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorWhite));
        ActivityDazzleBinding activityDazzleBinding8 = this.mBinding;
        if (activityDazzleBinding8 == null) {
            Intrinsics.throwUninitializedPropertyAccessException("mBinding");
        } else {
            activityDazzleBinding2 = activityDazzleBinding8;
        }
        DrawableCompat.setTint(activityDazzleBinding2.imageViewBack.getDrawable(), ContextCompat.getColor(getApplicationContext(), R.color.colorBlack));
    }

    private final boolean allPermissionsGranted() {
        String[] strArr = REQUIRED_PERMISSIONS;
        int length = strArr.length;
        int i = 0;
        while (true) {
            if (i >= length) {
                return true;
            }
            if (!(ContextCompat.checkSelfPermission(getBaseContext(), strArr[i]) == 0)) {
                return false;
            }
            i++;
        }
    }

    private final File getOutputDirectory() {
        File[] externalMediaDirs = getExternalMediaDirs();
        Intrinsics.checkNotNullExpressionValue(externalMediaDirs, "externalMediaDirs");
        File file = (File) ArraysKt.firstOrNull(externalMediaDirs);
        if (file != null) {
            new File(file, getResources().getString(R.string.app_name)).mkdirs();
        }
        new File(getCacheDir(), getResources().getString(R.string.app_name)).mkdir();
        File file2 = new File(getExternalFilesDir(null), "Camera");
        if (!file2.exists()) {
            if (!file2.mkdir()) {
                Log.e("ERROR", "Cannot create a directory!");
            } else {
                file2.mkdirs();
            }
        }
        return file2;
    }

    private final int aspectRatio(int width, int height) {
        double max = Math.max(width, height) / Math.min(width, height);
        return Math.abs(max - RATIO_4_3_VALUE) <= Math.abs(max - RATIO_16_9_VALUE) ? 0 : 1;
    }

    private final boolean hasBackCamera() {
        ProcessCameraProvider processCameraProvider = this.cameraProvider;
        if (processCameraProvider != null) {
            return processCameraProvider.hasCamera(CameraSelector.DEFAULT_BACK_CAMERA);
        }
        return false;
    }

    private final boolean hasFrontCamera() {
        ProcessCameraProvider processCameraProvider = this.cameraProvider;
        if (processCameraProvider != null) {
            return processCameraProvider.hasCamera(CameraSelector.DEFAULT_FRONT_CAMERA);
        }
        return false;
    }

    @Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u0006\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0011\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0018\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\u001eH\u0007J\u0018\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001f\u001a\u00020 2\u0006\u0010\u001d\u001a\u00020\u001eH\u0007J&\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001f\u001a\u00020 2\u0006\u0010\u001d\u001a\u00020\u001e2\f\u0010!\u001a\b\u0012\u0004\u0012\u00020#0\"H\u0007R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0007X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0007X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\fX\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\u000fX\u0086T¢\u0006\u0002\n\u0000R\u0016\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00070\u0011X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0012R\u000e\u0010\u0013\u001a\u00020\u0007X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0007X\u0082T¢\u0006\u0002\n\u0000R\u0014\u0010\u0015\u001a\b\u0012\u0004\u0012\u00020\u00170\u0016X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u00070\u0016X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006$"}, d2 = {"Lcom/aemerse/dazzle/Dazzle$Companion;", "", "()V", "ANIMATION_FAST_MILLIS", "", "ANIMATION_SLOW_MILLIS", "FILENAME_FORMAT", "", "PHOTO_EXTENSION", "PICKED_MEDIA_LIST", "PICKER_OPTIONS", "RATIO_16_9_VALUE", "", "RATIO_4_3_VALUE", "REQUEST_CODE_PICKER", "", "REQUIRED_PERMISSIONS", "", "[Ljava/lang/String;", "TAG", "VIDEO_EXTENSION", "mPath", "Ljava/util/ArrayList;", "Landroid/net/Uri;", "mPathList", "startPicker", "", "fragment", "Landroidx/fragment/app/Fragment;", "mDazzleOptions", "Lcom/aemerse/dazzle/utils/DazzleOptions;", "activity", "Landroidx/fragment/app/FragmentActivity;", "listener", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "picker_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        @JvmStatic
        public final void startPicker(final Fragment fragment, final DazzleOptions mDazzleOptions) {
            Intrinsics.checkNotNullParameter(fragment, "fragment");
            Intrinsics.checkNotNullParameter(mDazzleOptions, "mDazzleOptions");
            PermissionUtils.INSTANCE.checkForCameraWritePermissions(fragment, new PermissionCallback() {
                @Override
                public void onPermission(boolean approved) {
                    Intent intent = new Intent(fragment.getActivity(), (Class<?>) Dazzle.class);
                    intent.putExtra("PICKER_OPTIONS", mDazzleOptions);
                    intent.addFlags(NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST);
                    fragment.startActivityForResult(intent, 10);
                }
            });
        }

        @JvmStatic
        public final void startPicker(final FragmentActivity activity, final DazzleOptions mDazzleOptions) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(mDazzleOptions, "mDazzleOptions");
            PermissionUtils.INSTANCE.checkForCameraWritePermissions(activity, new PermissionCallback() {
                @Override
                public void onPermission(boolean approved) {
                    Intent intent = new Intent(activity, (Class<?>) Dazzle.class);
                    intent.putExtra("PICKER_OPTIONS", mDazzleOptions);
                    intent.addFlags(NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST);
                    activity.startActivityForResult(intent, 10);
                }
            });
        }

        @JvmStatic
        public final void startPicker(final FragmentActivity activity, final DazzleOptions mDazzleOptions, final ActivityResultLauncher<Intent> listener) {
            Intrinsics.checkNotNullParameter(activity, "activity");
            Intrinsics.checkNotNullParameter(mDazzleOptions, "mDazzleOptions");
            Intrinsics.checkNotNullParameter(listener, "listener");
            PermissionUtils.INSTANCE.checkForCameraWritePermissions(activity, new PermissionCallback() {
                @Override
                public void onPermission(boolean approved) {
                    Intent intent = new Intent(activity, (Class<?>) Dazzle.class);
                    intent.putExtra("PICKER_OPTIONS", mDazzleOptions);
                    intent.addFlags(NativeProtocol.MESSAGE_GET_ACCESS_TOKEN_REQUEST);
                    listener.launch(intent);
                }
            });
        }
    }
}