正在查看: Rilo v2.0.21 应用的 FragmentProfilePhotoPickerView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 FragmentProfilePhotoPickerView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.common.utils.custom;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import app.callpe.R;
import app.callpe.adapters.MyPhotoViewAdapter;
import app.callpe.common.utils.FileHandler;
import app.callpe.common.utils.FileUriUtils;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.custom.SpannedGridLayoutManager;
import app.callpe.common.utils.dialog.DialogHelper;
import app.callpe.common.utils.dialog.ImageProvider;
import app.callpe.common.utils.dialog.ResultListener;
import app.callpe.common.utils.file_helper.CompressFile;
import app.callpe.common.utils.file_helper.ImageConverter;
import app.callpe.data.model.MediaFile;
import app.callpe.ui.bottomsheet.PickerBottomSheet;
import app.callpe.ui.misc.ImageShowActivity;
import com.aemerse.dazzle.Dazzle;
import com.aemerse.dazzle.utils.DazzleOptions;
import com.crazylegend.core.dto.Config;
import com.crazylegend.core.modifiers.base.BaseSinglePickerModifier;
import com.crazylegend.imagepicker.images.ImageModel;
import com.crazylegend.imagepicker.pickers.SingleImagePicker;
import com.github.drjacky.imagepicker.ImagePicker;
import com.github.drjacky.imagepicker.listener.DismissListener;
import com.yalantis.ucrop.UCrop;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.CancellationException;
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.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Regex;
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\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0002\u0010\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\r\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004*\u0001#\u0018\u0000 l2\u00020\u0001:\u0001lB\u0011\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003¢\u0006\u0002\u0010\u0004B\u001b\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006¢\u0006\u0002\u0010\u0007B#\b\u0016\u0012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006\u0012\u0006\u0010\b\u001a\u00020\t¢\u0006\u0002\u0010\nJ\u0010\u0010R\u001a\u0002012\u0006\u0010S\u001a\u00020TH\u0003J\u001e\u0010U\u001a\u0002012\u0016\u0010V\u001a\u0012\u0012\u0004\u0012\u0002000Wj\b\u0012\u0004\u0012\u000200`XJ\u000e\u0010Y\u001a\u0002012\u0006\u0010Z\u001a\u00020[J\b\u0010\\\u001a\u000201H\u0014J\u000e\u0010]\u001a\u0002012\u0006\u0010^\u001a\u00020\u0016J\b\u0010_\u001a\u000201H\u0002J\u0010\u0010`\u001a\u0002012\u0006\u0010a\u001a\u00020bH\u0003J\b\u0010c\u001a\u000201H\u0014J\b\u0010d\u001a\u000201H\u0002J\u000e\u0010e\u001a\u0002012\u0006\u0010f\u001a\u000200J\u0010\u0010g\u001a\u0002012\u0006\u0010h\u001a\u00020iH\u0007J\u0016\u0010j\u001a\u0002012\u0006\u0010k\u001a\u0002002\u0006\u0010Z\u001a\u00020[R\u001c\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\r\u0010\u000e\"\u0004\b\u000f\u0010\u0010R\u0010\u0010\u0011\u001a\u0004\u0018\u00010\u0012X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0013\u001a\u0004\u0018\u00010\u0014X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u0015\u001a\u00020\u0016X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0017\u0010\u0018\"\u0004\b\u0019\u0010\u001aR&\u0010\u001b\u001a\n\u0012\u0004\u0012\u00020\u001d\u0018\u00010\u001c8\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001e\u0010\u001f\"\u0004\b \u0010!R\u0010\u0010\"\u001a\u00020#X\u0082\u0004¢\u0006\u0004\n\u0002\u0010$R&\u0010%\u001a\n\u0012\u0004\u0012\u00020\u001d\u0018\u00010\u001c8\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010\u001f\"\u0004\b'\u0010!R\u001a\u0010(\u001a\u00020\u0016X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b)\u0010\u0018\"\u0004\b*\u0010\u001aR\u001a\u0010+\u001a\u00020\u0016X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b,\u0010\u0018\"\u0004\b-\u0010\u001aR&\u0010.\u001a\u000e\u0012\u0004\u0012\u000200\u0012\u0004\u0012\u0002010/X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b2\u00103\"\u0004\b4\u00105R&\u00106\u001a\n\u0012\u0004\u0012\u00020\u001d\u0018\u00010\u001c8\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b7\u0010\u001f\"\u0004\b8\u0010!R,\u00109\u001a\u0014\u0012\u0004\u0012\u000200\u0012\u0004\u0012\u000200\u0012\u0004\u0012\u0002010:X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b;\u0010<\"\u0004\b=\u0010>R&\u0010?\u001a\n\u0012\u0004\u0012\u00020\u001d\u0018\u00010\u001c8\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b@\u0010\u001f\"\u0004\bA\u0010!R\u001a\u0010B\u001a\u00020\tX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bC\u0010D\"\u0004\bE\u0010FR\u0010\u0010G\u001a\u0004\u0018\u00010HX\u0082\u000e¢\u0006\u0002\n\u0000R\"\u0010I\u001a\n\u0012\u0006\u0012\u0004\u0018\u0001000JX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bK\u0010L\"\u0004\bM\u0010NR\u001a\u0010O\u001a\u00020\u0016X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bP\u0010\u0018\"\u0004\bQ\u0010\u001a¨\u0006m"}, d2 = {"Lapp/callpe/common/utils/custom/FragmentProfilePhotoPickerView;", "Landroid/widget/RelativeLayout;", "context", "Landroid/content/Context;", "(Landroid/content/Context;)V", "attrs", "Landroid/util/AttributeSet;", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "defStyleAttr", "", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "activity", "Landroidx/appcompat/app/AppCompatActivity;", "getActivity", "()Landroidx/appcompat/app/AppCompatActivity;", "setActivity", "(Landroidx/appcompat/app/AppCompatActivity;)V", "adapter", "Lapp/callpe/adapters/MyPhotoViewAdapter;", "addButton", "Landroid/widget/ImageView;", "allowDelete", "", "getAllowDelete", "()Z", "setAllowDelete", "(Z)V", "cameraLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "getCameraLauncher", "()Landroidx/activity/result/ActivityResultLauncher;", "setCameraLauncher", "(Landroidx/activity/result/ActivityResultLauncher;)V", "coroutineScope", "app/callpe/common/utils/custom/FragmentProfilePhotoPickerView$coroutineScope$1", "Lapp/callpe/common/utils/custom/FragmentProfilePhotoPickerView$coroutineScope$1;", "cropLauncher", "getCropLauncher", "setCropLauncher", "customCamera", "getCustomCamera", "setCustomCamera", "deleteListenerEnabled", "getDeleteListenerEnabled", "setDeleteListenerEnabled", "imageDeleteCallback", "Lkotlin/Function1;", "", "", "getImageDeleteCallback", "()Lkotlin/jvm/functions/Function1;", "setImageDeleteCallback", "(Lkotlin/jvm/functions/Function1;)V", "imageShowLauncher", "getImageShowLauncher", "setImageShowLauncher", "imageUploadCallback", "Lkotlin/Function2;", "getImageUploadCallback", "()Lkotlin/jvm/functions/Function2;", "setImageUploadCallback", "(Lkotlin/jvm/functions/Function2;)V", "launcher", "getLauncher", "setLauncher", "positionToAdd", "getPositionToAdd", "()I", "setPositionToAdd", "(I)V", "recyclerView", "Landroidx/recyclerview/widget/RecyclerView;", "selectedPictures", "", "getSelectedPictures", "()Ljava/util/List;", "setSelectedPictures", "(Ljava/util/List;)V", "showProfile", "getShowProfile", "setShowProfile", "addFile", "file", "Ljava/io/File;", "addItems", "pictures", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "deleteImage", "mediaFile", "Lapp/callpe/data/model/MediaFile;", "detachAllViewsFromParent", "hideAddBtn", "hide", "init", "loadImage", "imageModel", "Lcom/crazylegend/imagepicker/images/ImageModel;", "onDetachedFromWindow", "openGallery", "resetImage", "path", "setUpLaunchers", "fragment", "Landroidx/fragment/app/Fragment;", "updateImage", "localFile", "Companion", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class FragmentProfilePhotoPickerView extends RelativeLayout {
public static final Companion INSTANCE = new Companion(null);
private static final float MAX_PHOTO_SIZE = 1280.0f;
private static final int MIN_PHOTO_SIZE = 101;
private AppCompatActivity activity;
private MyPhotoViewAdapter adapter;
private ImageView addButton;
private boolean allowDelete;
private ActivityResultLauncher<Intent> cameraLauncher;
private final FragmentProfilePhotoPickerView$coroutineScope$1 coroutineScope;
private ActivityResultLauncher<Intent> cropLauncher;
private boolean customCamera;
private boolean deleteListenerEnabled;
private Function1<? super String, Unit> imageDeleteCallback;
private ActivityResultLauncher<Intent> imageShowLauncher;
private Function2<? super String, ? super String, Unit> imageUploadCallback;
private ActivityResultLauncher<Intent> launcher;
private int positionToAdd;
private RecyclerView recyclerView;
private List<String> selectedPictures;
private boolean showProfile;
@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0007\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u0014\u0010\u0003\u001a\u00020\u0004X\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006R\u0014\u0010\u0007\u001a\u00020\bX\u0086D¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\n¨\u0006\u000b"}, d2 = {"Lapp/callpe/common/utils/custom/FragmentProfilePhotoPickerView$Companion;", "", "()V", "MAX_PHOTO_SIZE", "", "getMAX_PHOTO_SIZE", "()F", "MIN_PHOTO_SIZE", "", "getMIN_PHOTO_SIZE", "()I", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final float getMAX_PHOTO_SIZE() {
return FragmentProfilePhotoPickerView.MAX_PHOTO_SIZE;
}
public final int getMIN_PHOTO_SIZE() {
return FragmentProfilePhotoPickerView.MIN_PHOTO_SIZE;
}
}
public final boolean getAllowDelete() {
return this.allowDelete;
}
public final void setAllowDelete(boolean z) {
this.allowDelete = z;
}
public final boolean getShowProfile() {
return this.showProfile;
}
public final void setShowProfile(boolean z) {
this.showProfile = z;
}
public final boolean getDeleteListenerEnabled() {
return this.deleteListenerEnabled;
}
public final void setDeleteListenerEnabled(boolean z) {
this.deleteListenerEnabled = z;
}
public final List<String> getSelectedPictures() {
return this.selectedPictures;
}
public final void setSelectedPictures(List<String> list) {
Intrinsics.checkNotNullParameter(list, "<set-?>");
this.selectedPictures = list;
}
public final boolean getCustomCamera() {
return this.customCamera;
}
public final void setCustomCamera(boolean z) {
this.customCamera = z;
}
public final int getPositionToAdd() {
return this.positionToAdd;
}
public final void setPositionToAdd(int i) {
this.positionToAdd = i;
}
public final AppCompatActivity getActivity() {
return this.activity;
}
public final void setActivity(AppCompatActivity appCompatActivity) {
this.activity = appCompatActivity;
}
public final ActivityResultLauncher<Intent> getImageShowLauncher() {
return this.imageShowLauncher;
}
public final void setImageShowLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
this.imageShowLauncher = activityResultLauncher;
}
public final ActivityResultLauncher<Intent> getLauncher() {
return this.launcher;
}
public final void setLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
this.launcher = activityResultLauncher;
}
public final ActivityResultLauncher<Intent> getCropLauncher() {
return this.cropLauncher;
}
public final void setCropLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
this.cropLauncher = activityResultLauncher;
}
public final ActivityResultLauncher<Intent> getCameraLauncher() {
return this.cameraLauncher;
}
public final void setCameraLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
this.cameraLauncher = activityResultLauncher;
}
public final Function2<String, String, Unit> getImageUploadCallback() {
return this.imageUploadCallback;
}
public final void setImageUploadCallback(Function2<? super String, ? super String, Unit> function2) {
Intrinsics.checkNotNullParameter(function2, "<set-?>");
this.imageUploadCallback = function2;
}
public final Function1<String, Unit> getImageDeleteCallback() {
return this.imageDeleteCallback;
}
public final void setImageDeleteCallback(Function1<? super String, Unit> function1) {
Intrinsics.checkNotNullParameter(function1, "<set-?>");
this.imageDeleteCallback = function1;
}
public final void setUpLaunchers(Fragment fragment) {
Intrinsics.checkNotNullParameter(fragment, "fragment");
this.cameraLauncher = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
FragmentProfilePhotoPickerView.setUpLaunchers$lambda$1(FragmentProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
this.cropLauncher = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
FragmentProfilePhotoPickerView.setUpLaunchers$lambda$2(FragmentProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
this.launcher = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
FragmentProfilePhotoPickerView.setUpLaunchers$lambda$3(FragmentProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
this.imageShowLauncher = fragment.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
FragmentProfilePhotoPickerView.setUpLaunchers$lambda$5(FragmentProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
}
public static final void setUpLaunchers$lambda$1(FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(fragmentProfilePhotoPickerView, "this$0");
Intrinsics.checkNotNullParameter(activityResult, "result");
if (activityResult.getResultCode() == -1) {
Intent data = activityResult.getData();
ArrayList<String> stringArrayListExtra = data != null ? data.getStringArrayListExtra("PICKED_MEDIA_LIST") : null;
Intrinsics.checkNotNull(stringArrayListExtra, "null cannot be cast to non-null type java.util.ArrayList<@[FlexibleNullability] kotlin.String?>");
ArrayList<String> arrayList = stringArrayListExtra;
ArrayList arrayList2 = new ArrayList(CollectionsKt.collectionSizeOrDefault(arrayList, 10));
for (String str : arrayList) {
Context context = fragmentProfilePhotoPickerView.getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
Intrinsics.checkNotNullExpressionValue(str, "path");
String realPath = FileUriUtils.getRealPath(context, Uri.parse(str));
fragmentProfilePhotoPickerView.selectedPictures.set(fragmentProfilePhotoPickerView.positionToAdd, realPath);
if (realPath != null) {
fragmentProfilePhotoPickerView.imageUploadCallback.invoke(realPath, "");
}
MyPhotoViewAdapter myPhotoViewAdapter = fragmentProfilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
}
arrayList2.add(Unit.INSTANCE);
}
}
}
public static final void setUpLaunchers$lambda$2(FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(fragmentProfilePhotoPickerView, "this$0");
Intrinsics.checkNotNullParameter(activityResult, "result");
if (activityResult.getResultCode() == -1) {
Intent data = activityResult.getData();
Intrinsics.checkNotNull(data);
Uri output = UCrop.getOutput(data);
if (output == null) {
return;
}
Context context = fragmentProfilePhotoPickerView.getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
String realPath = FileUriUtils.getRealPath(context, output);
Timber.e("selectedImagePath " + realPath, new Object[0]);
fragmentProfilePhotoPickerView.selectedPictures.set(fragmentProfilePhotoPickerView.positionToAdd, realPath);
if (realPath != null) {
fragmentProfilePhotoPickerView.imageUploadCallback.invoke(realPath, "");
}
MyPhotoViewAdapter myPhotoViewAdapter = fragmentProfilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
}
}
}
public static final void setUpLaunchers$lambda$3(FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(fragmentProfilePhotoPickerView, "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 = fragmentProfilePhotoPickerView.getContext();
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(fragmentProfilePhotoPickerView.getContext(), fragmentProfilePhotoPickerView.getContext().getString(2131952060), 0).show();
return;
}
ImageConverter imageConverter = ImageConverter.INSTANCE;
Context context2 = fragmentProfilePhotoPickerView.getContext();
Intrinsics.checkNotNullExpressionValue(context2, "context");
File file = new File(imageConverter.convertImageToJpg(context2, path));
if (Helper.isFileGreaterThan(file, 3)) {
Toast.makeText(fragmentProfilePhotoPickerView.getContext(), fragmentProfilePhotoPickerView.getContext().getString(2131952255), 0).show();
return;
} else {
fragmentProfilePhotoPickerView.addFile(file);
return;
}
}
return;
}
activityResult.getResultCode();
}
public static final void setUpLaunchers$lambda$5(FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView, ActivityResult activityResult) {
List emptyList;
Intrinsics.checkNotNullParameter(fragmentProfilePhotoPickerView, "this$0");
Intrinsics.checkNotNullParameter(activityResult, "result");
if (activityResult.getResultCode() != -1 || activityResult.getData() == null) {
return;
}
Intent data = activityResult.getData();
String stringExtra = data != null ? data.getStringExtra("pics") : null;
if (stringExtra == null || stringExtra.length() == 0) {
return;
}
List split = new Regex("\\s*,\\s*").split(stringExtra, 0);
if (!split.isEmpty()) {
ListIterator listIterator = split.listIterator(split.size());
while (listIterator.hasPrevious()) {
if (!(((String) listIterator.previous()).length() == 0)) {
emptyList = CollectionsKt.take(split, listIterator.nextIndex() + 1);
break;
}
}
}
emptyList = CollectionsKt.emptyList();
String[] strArr = (String[]) emptyList.toArray(new String[0]);
ArrayList<String> arrayList = new ArrayList<>(Arrays.asList(Arrays.copyOf(strArr, strArr.length)));
while (arrayList.size() < 6) {
arrayList.add("");
}
MyPhotoViewAdapter myPhotoViewAdapter = fragmentProfilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.addItems(arrayList);
}
}
private final void addFile(File file) {
BuildersKt.launch$default(this.coroutineScope, (CoroutineContext) null, (CoroutineStart) null, new FragmentProfilePhotoPickerView$addFile$1(this, file, null), 3, (Object) null);
}
public FragmentProfilePhotoPickerView(Context context) {
super(context);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
this.imageUploadCallback = FragmentProfilePhotoPickerView$imageUploadCallback$1.INSTANCE;
this.imageDeleteCallback = FragmentProfilePhotoPickerView$imageDeleteCallback$1.INSTANCE;
this.coroutineScope = new CoroutineScope() {
public CoroutineContext getCoroutineContext() {
return SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null).plus(Dispatchers.getIO());
}
};
init();
}
public FragmentProfilePhotoPickerView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
this.imageUploadCallback = FragmentProfilePhotoPickerView$imageUploadCallback$1.INSTANCE;
this.imageDeleteCallback = FragmentProfilePhotoPickerView$imageDeleteCallback$1.INSTANCE;
this.coroutineScope = new CoroutineScope() {
public CoroutineContext getCoroutineContext() {
return SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null).plus(Dispatchers.getIO());
}
};
TypedArray obtainStyledAttributes = context != null ? context.obtainStyledAttributes(attributeSet, R.styleable.Picker) : null;
this.allowDelete = obtainStyledAttributes != null ? obtainStyledAttributes.getBoolean(0, true) : true;
if (obtainStyledAttributes != null) {
obtainStyledAttributes.recycle();
}
TypedArray obtainStyledAttributes2 = context != null ? context.obtainStyledAttributes(attributeSet, R.styleable.Picker) : null;
this.showProfile = obtainStyledAttributes2 != null ? obtainStyledAttributes2.getBoolean(1, false) : false;
if (obtainStyledAttributes2 != null) {
obtainStyledAttributes2.recycle();
}
init();
}
public FragmentProfilePhotoPickerView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
this.imageUploadCallback = FragmentProfilePhotoPickerView$imageUploadCallback$1.INSTANCE;
this.imageDeleteCallback = FragmentProfilePhotoPickerView$imageDeleteCallback$1.INSTANCE;
this.coroutineScope = new CoroutineScope() {
public CoroutineContext getCoroutineContext() {
return SupervisorKt.SupervisorJob$default((Job) null, 1, (Object) null).plus(Dispatchers.getIO());
}
};
TypedArray obtainStyledAttributes = context != null ? context.obtainStyledAttributes(attributeSet, R.styleable.Picker) : null;
this.allowDelete = obtainStyledAttributes != null ? obtainStyledAttributes.getBoolean(0, true) : true;
if (obtainStyledAttributes != null) {
obtainStyledAttributes.recycle();
}
TypedArray obtainStyledAttributes2 = context != null ? context.obtainStyledAttributes(attributeSet, R.styleable.Picker) : null;
this.showProfile = obtainStyledAttributes2 != null ? obtainStyledAttributes2.getBoolean(1, false) : false;
if (obtainStyledAttributes2 != null) {
obtainStyledAttributes2.recycle();
}
init();
}
private final void init() {
RelativeLayout.inflate(getContext(), 2131558953, this);
ImageView imageView = (ImageView) findViewById(2131361957);
this.addButton = imageView;
if (imageView != null) {
imageView.setVisibility(8);
}
this.recyclerView = findViewById(2131364314);
SpannedGridLayoutManager spannedGridLayoutManager = new SpannedGridLayoutManager(new SpannedGridLayoutManager.GridSpanLookup() {
@Override
public final SpannedGridLayoutManager.SpanInfo getSpanInfo(int i) {
SpannedGridLayoutManager.SpanInfo init$lambda$6;
init$lambda$6 = FragmentProfilePhotoPickerView.init$lambda$6(i);
return init$lambda$6;
}
}, 3, 1.0f);
RecyclerView recyclerView = this.recyclerView;
if (recyclerView != null) {
recyclerView.setHasFixedSize(false);
}
RecyclerView recyclerView2 = this.recyclerView;
if (recyclerView2 != null) {
recyclerView2.setLayoutManager(spannedGridLayoutManager);
}
int size = 6 - this.selectedPictures.size();
if (size > 0) {
List<String> list = this.selectedPictures;
ArrayList arrayList = new ArrayList(size);
for (int i = 0; i < size; i++) {
arrayList.add("");
}
list.addAll(arrayList);
}
MyPhotoViewAdapter myPhotoViewAdapter = new MyPhotoViewAdapter(getContext(), this.selectedPictures, new MyPhotoViewAdapter.onItemClickListener() {
@Override
public void onItemClick(String picturePath) {
}
@Override
public void onItemClick(final String picturePath, final int position) {
AppCompatActivity activity;
Intrinsics.checkNotNullParameter(picturePath, "picturePath");
final FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView = FragmentProfilePhotoPickerView.this;
Function0<Unit> function0 = new Function0<Unit>() {
{
super(0);
}
public Object invoke() {
m219invoke();
return Unit.INSTANCE;
}
public final void m219invoke() {
String joinToString$default = CollectionsKt.joinToString$default(FragmentProfilePhotoPickerView.this.getSelectedPictures(), ",", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, (Function1) null, 62, (Object) null);
if (FragmentProfilePhotoPickerView.this.getActivity() == null) {
return;
}
Intent intent = new Intent(FragmentProfilePhotoPickerView.this.getActivity(), (Class<?>) ImageShowActivity.class);
int i2 = position;
FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView2 = FragmentProfilePhotoPickerView.this;
intent.putExtra("pics", joinToString$default);
intent.putExtra("position", i2);
intent.putExtra("profileScreen", false);
ActivityResultLauncher<Intent> imageShowLauncher = fragmentProfilePhotoPickerView2.getImageShowLauncher();
if (imageShowLauncher != null) {
imageShowLauncher.launch(intent);
}
}
};
final FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView2 = FragmentProfilePhotoPickerView.this;
PickerBottomSheet pickerBottomSheet = new PickerBottomSheet(false, function0, new Function0<Unit>() {
{
super(0);
}
public Object invoke() {
m220invoke();
return Unit.INSTANCE;
}
public final void m220invoke() {
MyPhotoViewAdapter myPhotoViewAdapter2;
if (!FragmentProfilePhotoPickerView.this.getDeleteListenerEnabled()) {
FragmentProfilePhotoPickerView.this.getSelectedPictures().set(position, "");
myPhotoViewAdapter2 = FragmentProfilePhotoPickerView.this.adapter;
if (myPhotoViewAdapter2 != null) {
myPhotoViewAdapter2.notifyDataSetChanged();
}
}
FragmentProfilePhotoPickerView.this.getImageDeleteCallback().invoke(picturePath);
}
});
if (pickerBottomSheet.isAdded() || pickerBottomSheet.isVisible() || (activity = FragmentProfilePhotoPickerView.this.getActivity()) == null) {
return;
}
pickerBottomSheet.show(activity.getSupportFragmentManager(), pickerBottomSheet.getTag());
}
@Override
public void onItemAddClick(int position) {
FragmentProfilePhotoPickerView.this.setPositionToAdd(position);
if (!FragmentProfilePhotoPickerView.this.getCustomCamera()) {
FragmentProfilePhotoPickerView.this.openGallery();
return;
}
DialogHelper dialogHelper = DialogHelper.INSTANCE;
Context context = FragmentProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
final FragmentProfilePhotoPickerView fragmentProfilePhotoPickerView = FragmentProfilePhotoPickerView.this;
dialogHelper.showChooseAppDialog(context, false, new ResultListener<ImageProvider>() {
@Metadata(k = 3, mv = {1, 8, 0}, xi = 48)
public class WhenMappings {
public static final int[] $EnumSwitchMapping$0;
static {
int[] iArr = new int[ImageProvider.values().length];
try {
iArr[ImageProvider.CAMERA.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[ImageProvider.GALLERY.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
$EnumSwitchMapping$0 = iArr;
}
}
@Override
public void onResult(ImageProvider t) {
ActivityResultLauncher<Intent> cameraLauncher;
if (t != null) {
int i2 = WhenMappings.$EnumSwitchMapping$0[t.ordinal()];
if (i2 != 1) {
if (i2 != 2) {
return;
}
SingleImagePicker singleImagePicker = SingleImagePicker.INSTANCE;
Context context2 = FragmentProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNullExpressionValue(context2, "context");
singleImagePicker.showPicker(context2, new String[0], new Config(false), 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 FragmentProfilePhotoPickerView$init$2$onItemAddClick$1$onResult$3(FragmentProfilePhotoPickerView.this));
return;
}
DazzleOptions init = DazzleOptions.INSTANCE.init();
init.setAllowFrontCamera(true);
init.setExcludeVideos(true);
init.setCropEnabled(true);
init.setCameraOnly(true);
init.setDefaultFrontCamera(true);
FragmentActivity activity = FragmentProfilePhotoPickerView.this.getActivity();
if (activity == null || (cameraLauncher = FragmentProfilePhotoPickerView.this.getCameraLauncher()) == null) {
return;
}
Dazzle.INSTANCE.startPicker(activity, init, cameraLauncher);
}
}
}, new DismissListener() {
public void onDismiss() {
}
});
}
@Override
public void onDeleteClick(String picturePath, int position) {
MyPhotoViewAdapter myPhotoViewAdapter2;
Intrinsics.checkNotNullParameter(picturePath, "picturePath");
if (!FragmentProfilePhotoPickerView.this.getDeleteListenerEnabled()) {
FragmentProfilePhotoPickerView.this.getSelectedPictures().set(position, "");
myPhotoViewAdapter2 = FragmentProfilePhotoPickerView.this.adapter;
if (myPhotoViewAdapter2 != null) {
myPhotoViewAdapter2.notifyDataSetChanged();
}
}
FragmentProfilePhotoPickerView.this.getImageDeleteCallback().invoke(picturePath);
}
});
this.adapter = myPhotoViewAdapter;
myPhotoViewAdapter.allowDelete = this.allowDelete;
MyPhotoViewAdapter myPhotoViewAdapter2 = this.adapter;
if (myPhotoViewAdapter2 != null) {
myPhotoViewAdapter2.profileView = this.showProfile;
}
RecyclerView recyclerView3 = this.recyclerView;
if (recyclerView3 != null) {
recyclerView3.setNestedScrollingEnabled(false);
}
RecyclerView recyclerView4 = this.recyclerView;
if (recyclerView4 == null) {
return;
}
recyclerView4.setAdapter(this.adapter);
}
public static final SpannedGridLayoutManager.SpanInfo init$lambda$6(int i) {
if (i == 0) {
return new SpannedGridLayoutManager.SpanInfo(2, 2);
}
return new SpannedGridLayoutManager.SpanInfo(1, 1);
}
public final void openGallery() {
Activity activity = this.activity;
if (activity != null) {
ImagePicker.Companion.with(activity).provider(com.github.drjacky.imagepicker.constant.ImageProvider.BOTH).createIntentFromDialog(new Function1<Intent, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((Intent) obj);
return Unit.INSTANCE;
}
public final void invoke(Intent intent) {
Intrinsics.checkNotNullParameter(intent, "intent");
ActivityResultLauncher<Intent> launcher = FragmentProfilePhotoPickerView.this.getLauncher();
if (launcher != null) {
launcher.launch(intent);
}
}
});
}
}
public final void loadImage(ImageModel imageModel) {
String compressedImageFile = CompressFile.getCompressedImageFile(imageModel.getContentUri(), getContext(), 40);
this.selectedPictures.set(this.positionToAdd, compressedImageFile);
Function2<? super String, ? super String, Unit> function2 = this.imageUploadCallback;
Intrinsics.checkNotNullExpressionValue(compressedImageFile, "compressedPath");
function2.invoke(compressedImageFile, "");
MyPhotoViewAdapter myPhotoViewAdapter = this.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
}
}
public final void addItems(ArrayList<String> pictures) {
Intrinsics.checkNotNullParameter(pictures, "pictures");
while (pictures.size() < 6) {
pictures.add("");
}
Timber.e("selectedPictures " + pictures, new Object[0]);
MyPhotoViewAdapter myPhotoViewAdapter = this.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.addItems(pictures);
}
}
public final void hideAddBtn(boolean hide) {
ImageView imageView = this.addButton;
if (imageView == null) {
return;
}
imageView.setVisibility(hide ^ true ? 0 : 8);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.activity = null;
}
public final void updateImage(String localFile, MediaFile mediaFile) {
Intrinsics.checkNotNullParameter(localFile, "localFile");
Intrinsics.checkNotNullParameter(mediaFile, "mediaFile");
int indexOf = this.selectedPictures.indexOf(localFile);
if (indexOf != -1) {
Timber.e("position found " + indexOf, new Object[0]);
this.selectedPictures.set(indexOf, mediaFile.getUrl());
MyPhotoViewAdapter myPhotoViewAdapter = this.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyItemChanged(indexOf);
}
Timber.e("Image uploaded " + this.selectedPictures.get(indexOf), new Object[0]);
}
}
public final void deleteImage(MediaFile mediaFile) {
Intrinsics.checkNotNullParameter(mediaFile, "mediaFile");
int indexOf = this.selectedPictures.indexOf(mediaFile.getUrl());
if (indexOf != -1) {
Timber.e("position found " + indexOf, new Object[0]);
this.selectedPictures.set(indexOf, "");
MyPhotoViewAdapter myPhotoViewAdapter = this.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyItemChanged(indexOf);
}
Timber.e("Image deleted " + this.selectedPictures.get(indexOf), new Object[0]);
}
}
public final void resetImage(String path) {
Intrinsics.checkNotNullParameter(path, "path");
int indexOf = this.selectedPictures.indexOf(path);
if (indexOf != -1) {
Timber.e("position found " + indexOf, new Object[0]);
this.selectedPictures.set(indexOf, "");
MyPhotoViewAdapter myPhotoViewAdapter = this.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyItemChanged(indexOf);
}
Timber.e("Image uploaded " + this.selectedPictures.get(indexOf), new Object[0]);
}
}
@Override
protected void detachAllViewsFromParent() {
super.detachAllViewsFromParent();
CoroutineScopeKt.cancel$default(this.coroutineScope, (CancellationException) null, 1, (Object) null);
}
}