导航菜单

页面标题

页面副标题

Rilo v2.0.21 - ImageVideoUploadActivity.java 源代码

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

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


package app.callpe.ui.home;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.activity.ComponentActivity;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContract;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleOwnerKt;
import androidx.lifecycle.ViewModelLazy;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelStore;
import androidx.lifecycle.viewmodel.CreationExtras;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.FileHandler;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.PermissionHelper;
import app.callpe.common.utils.ResultState;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.common.utils.file_helper.ImageConverter;
import app.callpe.common.utils.helper_functions.DialogHelper;
import app.callpe.data.repository.upload.UploadProgressHelper;
import app.callpe.databinding.ActivityImageVideoUploadBinding;
import app.callpe.ui.chat.ChatActivity;
import app.callpe.ui.misc.ImageShowActivity;
import app.callpe.ui.misc.VideoShowActivity;
import app.callpe.ui.user.UserViewModel;
import com.crazylegend.core.dto.Config;
import com.crazylegend.core.modifiers.base.BaseSinglePickerModifier;
import com.crazylegend.videopicker.pickers.SingleVideoPicker;
import com.crazylegend.videopicker.videos.VideoModel;
import com.facebook.internal.NativeProtocol;
import com.github.drjacky.imagepicker.ImagePicker;
import dagger.hilt.android.AndroidEntryPoint;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.CancellationException;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Reflection;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.SupervisorKt;
import timber.log.Timber;

@Metadata(d1 = {"\u0000¡\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u0011\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\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0015\n\u0002\b\u0006\n\u0002\u0010\u0007\n\u0002\b\u0005*\u0001\u0005\b\u0007\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0003J\u0010\u0010 \u001a\u00020!2\u0006\u0010\"\u001a\u00020#H\u0002J\u0018\u0010$\u001a\u00020!2\u0006\u0010\"\u001a\u00020#2\u0006\u0010%\u001a\u00020\u000fH\u0002J\u0010\u0010&\u001a\u00020!2\u0006\u0010\"\u001a\u00020#H\u0002J\u0010\u0010'\u001a\u00020!2\u0006\u0010\"\u001a\u00020#H\u0002J\u0010\u0010(\u001a\u00020)2\u0006\u0010*\u001a\u00020\u000fH\u0002J\b\u0010+\u001a\u00020,H\u0002J\b\u0010-\u001a\u00020!H\u0002J\u0010\u0010.\u001a\u00020\u00022\u0006\u0010/\u001a\u000200H\u0016J\b\u00101\u001a\u00020!H\u0002J\u0010\u00102\u001a\u00020!2\u0006\u00103\u001a\u000204H\u0002J\b\u00105\u001a\u00020!H\u0002J\b\u00106\u001a\u00020!H\u0002J\b\u00107\u001a\u00020!H\u0002J\u0012\u00108\u001a\u00020!2\b\u00109\u001a\u0004\u0018\u00010:H\u0014J\b\u0010;\u001a\u00020!H\u0014J\u0010\u0010<\u001a\u00020)2\u0006\u0010=\u001a\u00020>H\u0016J-\u0010?\u001a\u00020!2\u0006\u0010@\u001a\u00020A2\u000e\u0010\u0011\u001a\n\u0012\u0006\b\u0001\u0012\u00020\u000f0\u00122\u0006\u0010B\u001a\u00020CH\u0016¢\u0006\u0002\u0010DJ\u0018\u0010E\u001a\u00020!2\u0006\u0010F\u001a\u00020,2\u0006\u0010G\u001a\u00020\u000fH\u0002J\u0010\u0010H\u001a\u00020!2\u0006\u0010I\u001a\u00020JH\u0002J\b\u0010K\u001a\u00020!H\u0002J\b\u0010L\u001a\u00020!H\u0002J\b\u0010M\u001a\u00020!H\u0002J\b\u0010N\u001a\u00020!H\u0002R\u0010\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\u0006R \u0010\u0007\u001a\b\u0012\u0004\u0012\u00020\t0\bX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u000b\"\u0004\b\f\u0010\rR\u000e\u0010\u000e\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0010\u001a\u00020\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0016\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0012X\u0082\u000e¢\u0006\u0004\n\u0002\u0010\u0013R\u0010\u0010\u0014\u001a\u0004\u0018\u00010\u0015X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0017X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u0018\u001a\u0004\u0018\u00010\u0019X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u001a\u001a\u00020\u001b8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u001e\u0010\u001f\u001a\u0004\b\u001c\u0010\u001d¨\u0006O"}, d2 = {"Lapp/callpe/ui/home/ImageVideoUploadActivity;", "Lapp/callpe/ui/home/BaseActivity;", "Lapp/callpe/databinding/ActivityImageVideoUploadBinding;", "()V", "coroutineScope", "app/callpe/ui/home/ImageVideoUploadActivity$coroutineScope$1", "Lapp/callpe/ui/home/ImageVideoUploadActivity$coroutineScope$1;", "launcher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "getLauncher", "()Landroidx/activity/result/ActivityResultLauncher;", "setLauncher", "(Landroidx/activity/result/ActivityResultLauncher;)V", "localFilePath", "", "localThumbnailPath", NativeProtocol.RESULT_ARGS_PERMISSIONS, "", "[Ljava/lang/String;", "progressDialog", "Landroid/app/ProgressDialog;", "toolbar", "Landroidx/appcompat/widget/Toolbar;", "uploadProgressHelper", "Lapp/callpe/data/repository/upload/UploadProgressHelper;", "viewModel", "Lapp/callpe/ui/user/UserViewModel;", "getViewModel", "()Lapp/callpe/ui/user/UserViewModel;", "viewModel$delegate", "Lkotlin/Lazy;", "addImage", "", "file", "Ljava/io/File;", "addVideo", "compressedPath", "canCompress", "compression", "deleteLocalFile", "", "filePath", "getContext", "Landroid/content/Context;", "hideProgressDialog", "inflateLayout", "layoutInflater", "Landroid/view/LayoutInflater;", "initViews", "loadVideo", "videoModel", "Lcom/crazylegend/videopicker/videos/VideoModel;", "observeEvent", "observeUploadProgress", "onClicks", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onOptionsItemSelected", "item", "Landroid/view/MenuItem;", "onRequestPermissionsResult", "requestCode", "", "grantResults", "", "(I[Ljava/lang/String;[I)V", "openGallery", "context", "type", "progressDialogPercent", "progress", "", "resetValues", "setUpToolbar", "showIntentValues", "showProgressDialog", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class ImageVideoUploadActivity extends BaseActivity<ActivityImageVideoUploadBinding> {
    private final ImageVideoUploadActivity$coroutineScope$1 coroutineScope;
    private ActivityResultLauncher<Intent> launcher;
    private String localFilePath;
    private String localThumbnailPath;
    private String[] permissions;
    private ProgressDialog progressDialog;
    private Toolbar toolbar;
    private UploadProgressHelper uploadProgressHelper;

    private final Lazy viewModel;

    public ImageVideoUploadActivity() {
        ActivityResultLauncher<Intent> registerForActivityResult = registerForActivityResult((ActivityResultContract) new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
            public final void onActivityResult(Object obj) {
                ImageVideoUploadActivity.launcher$lambda$0(ImageVideoUploadActivity.this, (ActivityResult) obj);
            }
        });
        Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "registerForActivityResul… an error\n        }\n    }");
        this.launcher = registerForActivityResult;
        final ComponentActivity componentActivity = (ComponentActivity) this;
        final Function0 function0 = null;
        this.viewModel = new ViewModelLazy(Reflection.getOrCreateKotlinClass(UserViewModel.class), new Function0<ViewModelStore>() {
            {
                super(0);
            }

            public final ViewModelStore m1377invoke() {
                return componentActivity.getViewModelStore();
            }
        }, new Function0<ViewModelProvider.Factory>() {
            {
                super(0);
            }

            public final ViewModelProvider.Factory m1376invoke() {
                return componentActivity.getDefaultViewModelProviderFactory();
            }
        }, new Function0<CreationExtras>() {
            {
                super(0);
            }

            public final CreationExtras m1378invoke() {
                CreationExtras creationExtras;
                Function0 function02 = function0;
                return (function02 == null || (creationExtras = (CreationExtras) function02.invoke()) == null) ? componentActivity.getDefaultViewModelCreationExtras() : creationExtras;
            }
        });
        this.coroutineScope = new CoroutineScope() {
            public CoroutineContext getCoroutineContext() {
                return SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null).plus(Dispatchers.getIO());
            }
        };
        this.localFilePath = "";
        this.localThumbnailPath = "";
        this.permissions = new String[]{"android.permission.RECORD_AUDIO", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"};
    }

    public final ActivityResultLauncher<Intent> getLauncher() {
        return this.launcher;
    }

    public final void setLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
        Intrinsics.checkNotNullParameter(activityResultLauncher, "<set-?>");
        this.launcher = activityResultLauncher;
    }

    public static final void launcher$lambda$0(ImageVideoUploadActivity imageVideoUploadActivity, ActivityResult activityResult) {
        Intrinsics.checkNotNullParameter(imageVideoUploadActivity, "this$0");
        Intrinsics.checkNotNullParameter(activityResult, "result");
        if (activityResult.getResultCode() == -1) {
            if (activityResult.getData() != null) {
                Intent data = activityResult.getData();
                Intrinsics.checkNotNull(data);
                Timber.e("selected %s", new Object[]{data.getData()});
                Context context = (Context) imageVideoUploadActivity;
                Intent data2 = activityResult.getData();
                Intrinsics.checkNotNull(data2);
                File saveFileFromUri = FileHandler.saveFileFromUri(context, data2.getData(), "Pictures", "Picture_" + System.currentTimeMillis(), "jpg");
                String path = saveFileFromUri != null ? saveFileFromUri.getPath() : null;
                if (path == null) {
                    Toast.makeText(context, imageVideoUploadActivity.getString(2131952060), 0).show();
                    return;
                }
                String convertImageToJpg = ImageConverter.INSTANCE.convertImageToJpg(context, path);
                File file = new File(convertImageToJpg);
                if (Helper.isFileGreaterThan(file, 1)) {
                    Toast.makeText(context, imageVideoUploadActivity.getString(2131952255), 0).show();
                    imageVideoUploadActivity.deleteLocalFile(convertImageToJpg);
                    return;
                } else {
                    imageVideoUploadActivity.addImage(file);
                    return;
                }
            }
            return;
        }
        activityResult.getResultCode();
    }

    public final UserViewModel getViewModel() {
        return (UserViewModel) this.viewModel.getValue();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        String[] strArr;
        super.onCreate(savedInstanceState);
        Activity activity = (Activity) this;
        setWindowFlag(activity, 67108864, false);
        if (Build.VERSION.SDK_INT >= 33) {
            strArr = new String[]{"android.permission.READ_MEDIA_IMAGES"};
        } else if (Build.VERSION.SDK_INT >= 30) {
            strArr = new String[]{"android.permission.READ_EXTERNAL_STORAGE"};
        } else if (Build.VERSION.SDK_INT == 29) {
            strArr = new String[]{"android.permission.READ_EXTERNAL_STORAGE"};
        } else {
            strArr = new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"};
        }
        this.permissions = strArr;
        Context context = (Context) this;
        getWindow().setStatusBarColor(ContextCompat.getColor(context, 2131100053));
        this.uploadProgressHelper = new UploadProgressHelper(context, activity);
        initViews();
        showIntentValues();
        setUpToolbar();
        observeEvent();
        observeUploadProgress();
        onClicks();
    }

    private final void showIntentValues() {
        Context context = (Context) this;
        if (!PermissionHelper.permissionArrayGranted(context, this.permissions)) {
            ActivityCompat.requestPermissions((Activity) this, this.permissions, 200);
            return;
        }
        String stringExtra = getIntent().getStringExtra("type");
        if (stringExtra == null) {
            finish();
        }
        if (Intrinsics.areEqual(stringExtra, Constants.IMAGE)) {
            openGallery(context, Constants.IMAGE);
            ((ActivityImageVideoUploadBinding) getBinding()).maxFileText.setText("(Max file size: 1 MB)");
            ((ActivityImageVideoUploadBinding) getBinding()).photoTitle.setText(getString(2131952969));
        } else if (Intrinsics.areEqual(stringExtra, Constants.VIDEO)) {
            ((ActivityImageVideoUploadBinding) getBinding()).maxFileText.setText("(Max file size: 10 MB)");
            ((ActivityImageVideoUploadBinding) getBinding()).photoTitle.setText(getString(2131952979));
            openGallery(context, Constants.VIDEO);
        }
    }

    private final void openGallery(Context context, String type) {
        if (Intrinsics.areEqual(type, Constants.IMAGE)) {
            this.launcher.launch(ImagePicker.Companion.with((Activity) this).galleryOnly().createIntent());
        } else if (Intrinsics.areEqual(type, Constants.VIDEO)) {
            SingleVideoPicker.INSTANCE.showPicker(context, new String[]{"mp4"}, new Config(true), new Function1<BaseSinglePickerModifier, Unit>() {
                public final void invoke(BaseSinglePickerModifier baseSinglePickerModifier) {
                    Intrinsics.checkNotNullParameter(baseSinglePickerModifier, "$this$showPicker");
                }

                public Object invoke(Object obj) {
                    invoke((BaseSinglePickerModifier) obj);
                    return Unit.INSTANCE;
                }
            }, new ImageVideoUploadActivity$openGallery$2(this));
        }
    }

    public final void loadVideo(VideoModel videoModel) {
        BuildersKt.launch$default(this.coroutineScope, (CoroutineContext) null, (CoroutineStart) null, new ImageVideoUploadActivity$loadVideo$1(this, videoModel.getContentUri(), this, null), 3, (Object) null);
    }

    private final void addImage(File file) {
        BuildersKt.launch$default(this.coroutineScope, (CoroutineContext) null, (CoroutineStart) null, new ImageVideoUploadActivity$addImage$1(this, file, null), 3, (Object) null);
    }

    private final void setUpToolbar() {
        try {
            Toolbar toolbar = this.toolbar;
            if (toolbar == null) {
                Intrinsics.throwUninitializedPropertyAccessException("toolbar");
                toolbar = null;
            }
            setSupportActionBar(toolbar);
            ActionBar supportActionBar = getSupportActionBar();
            if (supportActionBar != null) {
                supportActionBar.setDisplayHomeAsUpEnabled(true);
            }
        } catch (Exception e) {
            Timber.e(e, "setUpToolbar: Error ", new Object[0]);
        }
    }

    private final void onClicks() {
        getBinding().addImageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ImageVideoUploadActivity.onClicks$lambda$1(ImageVideoUploadActivity.this, view);
            }
        });
        getBinding().removeImageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ImageVideoUploadActivity.onClicks$lambda$2(ImageVideoUploadActivity.this, view);
            }
        });
        getBinding().saveBth.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ImageVideoUploadActivity.onClicks$lambda$3(ImageVideoUploadActivity.this, view);
            }
        });
        getBinding().picker.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ImageVideoUploadActivity.onClicks$lambda$6(ImageVideoUploadActivity.this, view);
            }
        });
    }

    public static final void onClicks$lambda$1(ImageVideoUploadActivity imageVideoUploadActivity, View view) {
        Intrinsics.checkNotNullParameter(imageVideoUploadActivity, "this$0");
        imageVideoUploadActivity.showIntentValues();
    }

    public static final void onClicks$lambda$2(ImageVideoUploadActivity imageVideoUploadActivity, View view) {
        Intrinsics.checkNotNullParameter(imageVideoUploadActivity, "this$0");
        imageVideoUploadActivity.resetValues();
    }

    public static final void onClicks$lambda$3(final ImageVideoUploadActivity imageVideoUploadActivity, View view) {
        Intrinsics.checkNotNullParameter(imageVideoUploadActivity, "this$0");
        boolean z = true;
        if (imageVideoUploadActivity.localFilePath.length() > 0) {
            if (imageVideoUploadActivity.localThumbnailPath.length() > 0) {
                String stringExtra = imageVideoUploadActivity.getIntent().getStringExtra("type");
                String str = stringExtra;
                if (str != null && str.length() != 0) {
                    z = false;
                }
                if (z) {
                    imageVideoUploadActivity.finish();
                }
                ArrayList arrayList = new ArrayList();
                arrayList.add(imageVideoUploadActivity.localFilePath);
                arrayList.add(imageVideoUploadActivity.localThumbnailPath);
                UserViewModel viewModel = imageVideoUploadActivity.getViewModel();
                Intrinsics.checkNotNull(stringExtra);
                UserViewModel.uploadImage$default(viewModel, arrayList, null, null, stringExtra, new Function0<Unit>() {
                    {
                        super(0);
                    }

                    public Object invoke() {
                        m1380invoke();
                        return Unit.INSTANCE;
                    }

                    public final void m1380invoke() {
                        UploadProgressHelper uploadProgressHelper;
                        uploadProgressHelper = ImageVideoUploadActivity.this.uploadProgressHelper;
                        if (uploadProgressHelper != null) {
                            uploadProgressHelper.setProgressDialog();
                        }
                    }
                }, 6, null);
            }
        }
    }

    public static final void onClicks$lambda$6(ImageVideoUploadActivity imageVideoUploadActivity, View view) {
        Intrinsics.checkNotNullParameter(imageVideoUploadActivity, "this$0");
        if (imageVideoUploadActivity.localFilePath.length() == 0) {
            if (imageVideoUploadActivity.localThumbnailPath.length() == 0) {
                return;
            }
        }
        String stringExtra = imageVideoUploadActivity.getIntent().getStringExtra("type");
        if (stringExtra == null) {
            imageVideoUploadActivity.finish();
        }
        if (Intrinsics.areEqual(stringExtra, Constants.IMAGE)) {
            Intent intent = new Intent((Context) imageVideoUploadActivity, (Class<?>) ImageShowActivity.class);
            intent.putExtra("pics", imageVideoUploadActivity.localThumbnailPath);
            imageVideoUploadActivity.startActivity(intent);
        } else if (Intrinsics.areEqual(stringExtra, Constants.VIDEO)) {
            Intent intent2 = new Intent(imageVideoUploadActivity.getContext(), (Class<?>) VideoShowActivity.class);
            intent2.putExtra("url", imageVideoUploadActivity.localFilePath);
            intent2.putExtra("audio", true);
            imageVideoUploadActivity.startActivity(intent2);
        }
    }

    public final void resetValues() {
        getBinding().picker.setImageDrawable(null);
        View view = getBinding().removeImageBtn;
        Intrinsics.checkNotNullExpressionValue(view, "binding.removeImageBtn");
        view.setVisibility(8);
        View view2 = getBinding().addImageBtn;
        Intrinsics.checkNotNullExpressionValue(view2, "binding.addImageBtn");
        view2.setVisibility(0);
        ImageView imageView = getBinding().play;
        Intrinsics.checkNotNullExpressionValue(imageView, "binding.play");
        imageView.setVisibility(8);
        deleteLocalFile(this.localFilePath);
        deleteLocalFile(this.localThumbnailPath);
        this.localFilePath = "";
        this.localThumbnailPath = "";
    }

    private final void initViews() {
        Toolbar toolbar = getBinding().toolbar;
        Intrinsics.checkNotNullExpressionValue(toolbar, "binding.toolbar");
        this.toolbar = toolbar;
    }

    private final void observeUploadProgress() {
        getViewModel().getResult().observe((LifecycleOwner) this, new ImageVideoUploadActivity$sam$androidx_lifecycle_Observer$0(new Function1<ResultState<? extends Double>, Unit>() {

            @Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
            public class WhenMappings {
                public static final int[] $EnumSwitchMapping$0;

                static {
                    int[] iArr = new int[ResultState.Status.values().length];
                    try {
                        iArr[ResultState.Status.LOADING.ordinal()] = 1;
                    } catch (NoSuchFieldError unused) {
                    }
                    try {
                        iArr[ResultState.Status.ERROR.ordinal()] = 2;
                    } catch (NoSuchFieldError unused2) {
                    }
                    try {
                        iArr[ResultState.Status.SUCCESS.ordinal()] = 3;
                    } catch (NoSuchFieldError unused3) {
                    }
                    try {
                        iArr[ResultState.Status.RESET.ordinal()] = 4;
                    } catch (NoSuchFieldError unused4) {
                    }
                    $EnumSwitchMapping$0 = iArr;
                }
            }

            {
                super(1);
            }

            public Object invoke(Object obj) {
                invoke((ResultState<Double>) obj);
                return Unit.INSTANCE;
            }

            public final void invoke(app.callpe.common.utils.ResultState<java.lang.Double> r4) {
                throw new UnsupportedOperationException("Method not decompiled: app.callpe.ui.home.ImageVideoUploadActivity$observeUploadProgress$1.invoke(app.callpe.common.utils.ResultState):void");
            }
        }));
    }

    private final void observeEvent() {
        BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ImageVideoUploadActivity$observeEvent$1(this, null), 3, (Object) null);
    }

    public final Context getContext() {
        return (Context) this;
    }

    protected void onDestroy() {
        super.onDestroy();
        UploadProgressHelper uploadProgressHelper = this.uploadProgressHelper;
        if (uploadProgressHelper != null) {
            uploadProgressHelper.dismiss();
        }
        ProgressDialog progressDialog = this.progressDialog;
        if (progressDialog != null) {
            progressDialog.dismiss();
        }
        CoroutineScopeKt.cancel$default(this.coroutineScope, (CancellationException) null, 1, (Object) null);
        deleteLocalFile(this.localFilePath);
        deleteLocalFile(this.localThumbnailPath);
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        Intrinsics.checkNotNullParameter(item, "item");
        if (item.getItemId() != 16908332) {
            return true;
        }
        finish();
        return true;
    }

    @Override
    public ActivityImageVideoUploadBinding inflateLayout(LayoutInflater layoutInflater) {
        Intrinsics.checkNotNullParameter(layoutInflater, "layoutInflater");
        ActivityImageVideoUploadBinding inflate = ActivityImageVideoUploadBinding.inflate(layoutInflater);
        Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
        return inflate;
    }

    public final void canCompress(File file) throws IOException {
        if (Helper.isFileGreaterThan(file, 10)) {
            ActivityExtKt.toast((Activity) this, "File size is larger then 10 MB limit. Files with less then 10 MB is allowed.");
            String absolutePath = file.getAbsolutePath();
            Intrinsics.checkNotNullExpressionValue(absolutePath, "file.absolutePath");
            deleteLocalFile(absolutePath);
            return;
        }
        compression(file);
    }

    private final void compression(File file) {
        try {
            showProgressDialog();
            BuildersKt.launch$default(LifecycleOwnerKt.getLifecycleScope((LifecycleOwner) this), (CoroutineContext) null, (CoroutineStart) null, new ImageVideoUploadActivity$compression$1(this, CollectionsKt.listOf(Uri.fromFile(file)), this, file, null), 3, (Object) null);
        } catch (Exception unused) {
            ActivityExtKt.toast((Activity) this, "Something went wrong try again later.");
        }
    }

    public final void addVideo(File file, String compressedPath) {
        BuildersKt.launch$default(this.coroutineScope, (CoroutineContext) null, (CoroutineStart) null, new ImageVideoUploadActivity$addVideo$1(file, this, compressedPath, null), 3, (Object) null);
    }

    public final boolean deleteLocalFile(String filePath) {
        if (filePath.length() == 0) {
            return false;
        }
        File file = new File(filePath);
        try {
            if (!file.exists()) {
                return false;
            }
            Timber.i("file deleted", new Object[0]);
            return file.delete();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    private final void showProgressDialog() {
        ProgressDialog progressDialog = new ProgressDialog((Context) this);
        this.progressDialog = progressDialog;
        progressDialog.setTitle(getString(2131951907));
        ProgressDialog progressDialog2 = this.progressDialog;
        if (progressDialog2 != null) {
            progressDialog2.setProgressStyle(1);
        }
        ProgressDialog progressDialog3 = this.progressDialog;
        if (progressDialog3 != null) {
            progressDialog3.setCancelable(false);
        }
        ProgressDialog progressDialog4 = this.progressDialog;
        if (progressDialog4 != null) {
            progressDialog4.setIndeterminate(false);
        }
        ProgressDialog progressDialog5 = this.progressDialog;
        if (progressDialog5 != null) {
            progressDialog5.setMax(100);
        }
        ProgressDialog progressDialog6 = this.progressDialog;
        if (progressDialog6 != null) {
            progressDialog6.setProgress(0);
        }
        ProgressDialog progressDialog7 = this.progressDialog;
        if (progressDialog7 != null) {
            progressDialog7.show();
        }
    }

    public final void progressDialogPercent(float progress) {
        ProgressDialog progressDialog;
        ProgressDialog progressDialog2 = this.progressDialog;
        if (progressDialog2 != null) {
            if (!(progressDialog2 != null && progressDialog2.isShowing()) || (progressDialog = this.progressDialog) == null) {
                return;
            }
            progressDialog.setProgress((int) progress);
        }
    }

    public final void hideProgressDialog() {
        ProgressDialog progressDialog;
        ProgressDialog progressDialog2 = this.progressDialog;
        if (progressDialog2 != null) {
            if (!(progressDialog2 != null && progressDialog2.isShowing()) || (progressDialog = this.progressDialog) == null) {
                return;
            }
            progressDialog.dismiss();
        }
    }

    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        Intrinsics.checkNotNullParameter(permissions, NativeProtocol.RESULT_ARGS_PERMISSIONS);
        Intrinsics.checkNotNullParameter(grantResults, "grantResults");
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode != 200) {
            if (requestCode != 8002) {
                return;
            }
            if (grantResults.length == 0) {
                return;
            }
            if (grantResults[0] == 0 && grantResults[1] == 0) {
                return;
            }
            DialogHelper.showPermissionDialog((Context) this, (Activity) this, getString(2131952428), "Camera Permission required", ChatActivity.CAMERA_PERMISSION);
            return;
        }
        if (grantResults.length == 0) {
            return;
        }
        if (Build.VERSION.SDK_INT < 30 ? Build.VERSION.SDK_INT != 29 ? grantResults[0] != 0 || grantResults[1] != 0 : grantResults[0] != 0 : grantResults[0] != 0) {
            r1 = false;
        }
        if (r1) {
            return;
        }
        DialogHelper.showPermissionDialog((Context) this, (Activity) this, getString(2131952428), getString(2131952439), ChatActivity.MEDIA_PERMISSION);
    }
}