正在查看: Biko v2.0.23 应用的 ProfilePhotoPickerView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 ProfilePhotoPickerView.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.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.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.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 kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.Regex;
import timber.log.Timber;
@Metadata(d1 = {"\u0000n\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\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u001f\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010!\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u00002\u00020\u0001B\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\u001e\u0010C\u001a\u00020D2\u0016\u0010E\u001a\u0012\u0012\u0004\u0012\u00020=0Fj\b\u0012\u0004\u0012\u00020=`GJ\u000e\u0010H\u001a\u00020D2\u0006\u0010I\u001a\u00020\u0010J\b\u0010J\u001a\u00020DH\u0002J\u0010\u0010K\u001a\u00020D2\u0006\u0010L\u001a\u00020MH\u0003J\b\u0010N\u001a\u00020DH\u0002R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\r\u001a\u0004\u0018\u00010\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u000f\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0011\u0010\u0012\"\u0004\b\u0013\u0010\u0014R\u001a\u0010\u0015\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0016\u0010\u0012\"\u0004\b\u0017\u0010\u0014R$\u0010\u0018\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00198\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001b\u0010\u001c\"\u0004\b\u001d\u0010\u001eR$\u0010\u001f\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00198\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010\u001c\"\u0004\b!\u0010\u001eR\u001a\u0010\"\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b#\u0010\u0012\"\u0004\b$\u0010\u0014R\u001a\u0010%\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010\u0012\"\u0004\b'\u0010\u0014R\u001a\u0010(\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b)\u0010\u0012\"\u0004\b*\u0010\u0014R$\u0010+\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00198\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b,\u0010\u001c\"\u0004\b-\u0010\u001eR$\u0010.\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00198\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b/\u0010\u001c\"\u0004\b0\u0010\u001eR\u001a\u00101\u001a\u00020\tX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b2\u00103\"\u0004\b4\u00105R\u001a\u00106\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b7\u0010\u0012\"\u0004\b8\u0010\u0014R\u0010\u00109\u001a\u0004\u0018\u00010:X\u0082\u000e¢\u0006\u0002\n\u0000R\u0019\u0010;\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010=0<¢\u0006\b\n\u0000\u001a\u0004\b>\u0010?R\u001a\u0010@\u001a\u00020\u0010X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bA\u0010\u0012\"\u0004\bB\u0010\u0014¨\u0006O"}, d2 = {"Lapp/callpe/common/utils/custom/ProfilePhotoPickerView;", "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", "adapter", "Lapp/callpe/adapters/MyPhotoViewAdapter;", "addButton", "Landroid/widget/ImageView;", "allowDelete", "", "getAllowDelete", "()Z", "setAllowDelete", "(Z)V", "approved", "getApproved", "setApproved", "cameraLauncher", "Landroidx/activity/result/ActivityResultLauncher;", "Landroid/content/Intent;", "getCameraLauncher", "()Landroidx/activity/result/ActivityResultLauncher;", "setCameraLauncher", "(Landroidx/activity/result/ActivityResultLauncher;)V", "cropLauncher", "getCropLauncher", "setCropLauncher", "customCamera", "getCustomCamera", "setCustomCamera", "hideAdd", "getHideAdd", "setHideAdd", "hideDelete", "getHideDelete", "setHideDelete", "imageShowLauncher", "getImageShowLauncher", "setImageShowLauncher", "launcher", "getLauncher", "setLauncher", "positionToAdd", "getPositionToAdd", "()I", "setPositionToAdd", "(I)V", "profileScreen", "getProfileScreen", "setProfileScreen", "recyclerView", "Landroidx/recyclerview/widget/RecyclerView;", "selectedPictures", "", "", "getSelectedPictures", "()Ljava/util/List;", "showProfile", "getShowProfile", "setShowProfile", "addItems", "", "pictures", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "hideAddBtn", "hide", "init", "loadImage", "imageModel", "Lcom/crazylegend/imagepicker/images/ImageModel;", "openGallery", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class ProfilePhotoPickerView extends RelativeLayout {
private MyPhotoViewAdapter adapter;
private ImageView addButton;
private boolean allowDelete;
private boolean approved;
private ActivityResultLauncher<Intent> cameraLauncher;
private ActivityResultLauncher<Intent> cropLauncher;
private boolean customCamera;
private boolean hideAdd;
private boolean hideDelete;
private ActivityResultLauncher<Intent> imageShowLauncher;
private ActivityResultLauncher<Intent> launcher;
private int positionToAdd;
private boolean profileScreen;
private RecyclerView recyclerView;
private final List<String> selectedPictures;
private boolean showProfile;
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 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 boolean getHideDelete() {
return this.hideDelete;
}
public final void setHideDelete(boolean z) {
this.hideDelete = z;
}
public final boolean getHideAdd() {
return this.hideAdd;
}
public final void setHideAdd(boolean z) {
this.hideAdd = z;
}
public final boolean getApproved() {
return this.approved;
}
public final void setApproved(boolean z) {
this.approved = z;
}
public final boolean getProfileScreen() {
return this.profileScreen;
}
public final void setProfileScreen(boolean z) {
this.profileScreen = z;
}
public final List<String> getSelectedPictures() {
return this.selectedPictures;
}
public final ActivityResultLauncher<Intent> getImageShowLauncher() {
return this.imageShowLauncher;
}
public final void setImageShowLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
Intrinsics.checkNotNullParameter(activityResultLauncher, "<set-?>");
this.imageShowLauncher = activityResultLauncher;
}
public static final void imageShowLauncher$lambda$1(ProfilePhotoPickerView profilePhotoPickerView, ActivityResult activityResult) {
List emptyList;
Intrinsics.checkNotNullParameter(profilePhotoPickerView, "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<>(CollectionsKt.listOf(Arrays.copyOf(strArr, strArr.length)));
while (arrayList.size() < 6) {
arrayList.add("");
}
MyPhotoViewAdapter myPhotoViewAdapter = profilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.addItems(arrayList);
}
}
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$2(ProfilePhotoPickerView profilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(profilePhotoPickerView, "this$0");
Intrinsics.checkNotNullParameter(activityResult, "result");
if (activityResult.getResultCode() == -1) {
if (activityResult.getData() != null) {
Intent data = activityResult.getData();
Intrinsics.checkNotNull(data);
Uri data2 = data.getData();
Timber.e("selected %s", new Object[]{data2});
profilePhotoPickerView.selectedPictures.set(0, CompressFile.getCompressedImageFile(data2, profilePhotoPickerView.getContext(), 40));
MyPhotoViewAdapter myPhotoViewAdapter = profilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
return;
}
return;
}
return;
}
activityResult.getResultCode();
}
public final ActivityResultLauncher<Intent> getCropLauncher() {
return this.cropLauncher;
}
public final void setCropLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
Intrinsics.checkNotNullParameter(activityResultLauncher, "<set-?>");
this.cropLauncher = activityResultLauncher;
}
public static final void cropLauncher$lambda$3(ProfilePhotoPickerView profilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(profilePhotoPickerView, "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 = profilePhotoPickerView.getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
Timber.e("selectedImagePath " + FileUriUtils.getRealPath(context, output), new Object[0]);
profilePhotoPickerView.selectedPictures.set(profilePhotoPickerView.positionToAdd, CompressFile.getCompressedImageFile(output, profilePhotoPickerView.getContext(), 40));
MyPhotoViewAdapter myPhotoViewAdapter = profilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
}
}
}
public final ActivityResultLauncher<Intent> getCameraLauncher() {
return this.cameraLauncher;
}
public final void setCameraLauncher(ActivityResultLauncher<Intent> activityResultLauncher) {
Intrinsics.checkNotNullParameter(activityResultLauncher, "<set-?>");
this.cameraLauncher = activityResultLauncher;
}
public static final void cameraLauncher$lambda$5(ProfilePhotoPickerView profilePhotoPickerView, ActivityResult activityResult) {
Intrinsics.checkNotNullParameter(profilePhotoPickerView, "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) {
Intrinsics.checkNotNullExpressionValue(str, "path");
profilePhotoPickerView.selectedPictures.set(profilePhotoPickerView.positionToAdd, CompressFile.getCompressedImageFile(Uri.parse(str), profilePhotoPickerView.getContext(), 40));
MyPhotoViewAdapter myPhotoViewAdapter = profilePhotoPickerView.adapter;
if (myPhotoViewAdapter != null) {
myPhotoViewAdapter.notifyDataSetChanged();
}
arrayList2.add(Unit.INSTANCE);
}
}
}
public ProfilePhotoPickerView(Context context) {
super(context);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
AppCompatActivity context2 = getContext();
Intrinsics.checkNotNull(context2, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult = context2.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.imageShowLauncher$lambda$1(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "context as AppCompatActi…}\n }\n }");
this.imageShowLauncher = registerForActivityResult;
AppCompatActivity context3 = getContext();
Intrinsics.checkNotNull(context3, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult2 = context3.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.launcher$lambda$2(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "context as AppCompatActi…r\n }\n }");
this.launcher = registerForActivityResult2;
AppCompatActivity context4 = getContext();
Intrinsics.checkNotNull(context4, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult3 = context4.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cropLauncher$lambda$3(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult3, "context as AppCompatActi…)\n }\n }");
this.cropLauncher = registerForActivityResult3;
AppCompatActivity context5 = getContext();
Intrinsics.checkNotNull(context5, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult4 = context5.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cameraLauncher$lambda$5(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult4, "context as AppCompatActi…}\n }\n }");
this.cameraLauncher = registerForActivityResult4;
init();
}
public ProfilePhotoPickerView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
AppCompatActivity context2 = getContext();
Intrinsics.checkNotNull(context2, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult = context2.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.imageShowLauncher$lambda$1(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "context as AppCompatActi…}\n }\n }");
this.imageShowLauncher = registerForActivityResult;
AppCompatActivity context3 = getContext();
Intrinsics.checkNotNull(context3, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult2 = context3.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.launcher$lambda$2(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "context as AppCompatActi…r\n }\n }");
this.launcher = registerForActivityResult2;
AppCompatActivity context4 = getContext();
Intrinsics.checkNotNull(context4, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult3 = context4.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cropLauncher$lambda$3(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult3, "context as AppCompatActi…)\n }\n }");
this.cropLauncher = registerForActivityResult3;
AppCompatActivity context5 = getContext();
Intrinsics.checkNotNull(context5, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult4 = context5.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cameraLauncher$lambda$5(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult4, "context as AppCompatActi…}\n }\n }");
this.cameraLauncher = registerForActivityResult4;
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 ProfilePhotoPickerView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.allowDelete = true;
this.selectedPictures = new ArrayList();
AppCompatActivity context2 = getContext();
Intrinsics.checkNotNull(context2, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult = context2.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.imageShowLauncher$lambda$1(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult, "context as AppCompatActi…}\n }\n }");
this.imageShowLauncher = registerForActivityResult;
AppCompatActivity context3 = getContext();
Intrinsics.checkNotNull(context3, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult2 = context3.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.launcher$lambda$2(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult2, "context as AppCompatActi…r\n }\n }");
this.launcher = registerForActivityResult2;
AppCompatActivity context4 = getContext();
Intrinsics.checkNotNull(context4, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult3 = context4.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cropLauncher$lambda$3(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult3, "context as AppCompatActi…)\n }\n }");
this.cropLauncher = registerForActivityResult3;
AppCompatActivity context5 = getContext();
Intrinsics.checkNotNull(context5, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
ActivityResultLauncher<Intent> registerForActivityResult4 = context5.registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() {
public final void onActivityResult(Object obj) {
ProfilePhotoPickerView.cameraLauncher$lambda$5(ProfilePhotoPickerView.this, (ActivityResult) obj);
}
});
Intrinsics.checkNotNullExpressionValue(registerForActivityResult4, "context as AppCompatActi…}\n }\n }");
this.cameraLauncher = registerForActivityResult4;
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 = ProfilePhotoPickerView.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(String picturePath, final int position) {
Intrinsics.checkNotNullParameter(picturePath, "picturePath");
boolean hideDelete = ProfilePhotoPickerView.this.getHideDelete();
final ProfilePhotoPickerView profilePhotoPickerView = ProfilePhotoPickerView.this;
Function0<Unit> function0 = new Function0<Unit>() {
{
super(0);
}
public Object invoke() {
m230invoke();
return Unit.INSTANCE;
}
public final void m230invoke() {
String joinToString$default = CollectionsKt.joinToString$default(ProfilePhotoPickerView.this.getSelectedPictures(), ",", (CharSequence) null, (CharSequence) null, 0, (CharSequence) null, (Function1) null, 62, (Object) null);
Context context = ProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNull(context, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
Intent intent = new Intent(context, (Class<?>) ImageShowActivity.class);
int i2 = position;
ProfilePhotoPickerView profilePhotoPickerView2 = ProfilePhotoPickerView.this;
intent.putExtra("pics", joinToString$default);
intent.putExtra("position", i2);
intent.putExtra("profile", true);
intent.putExtra("approved", profilePhotoPickerView2.getApproved());
intent.putExtra("profileScreen", profilePhotoPickerView2.getProfileScreen());
profilePhotoPickerView2.getImageShowLauncher().launch(intent);
}
};
final ProfilePhotoPickerView profilePhotoPickerView2 = ProfilePhotoPickerView.this;
PickerBottomSheet pickerBottomSheet = new PickerBottomSheet(hideDelete, function0, new Function0<Unit>() {
{
super(0);
}
public Object invoke() {
m231invoke();
return Unit.INSTANCE;
}
public final void m231invoke() {
MyPhotoViewAdapter myPhotoViewAdapter2;
ProfilePhotoPickerView.this.getSelectedPictures().set(position, "");
myPhotoViewAdapter2 = ProfilePhotoPickerView.this.adapter;
if (myPhotoViewAdapter2 != null) {
myPhotoViewAdapter2.notifyDataSetChanged();
}
}
});
if (pickerBottomSheet.isAdded() || pickerBottomSheet.isVisible()) {
return;
}
AppCompatActivity context = ProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNull(context, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
pickerBottomSheet.show(context.getSupportFragmentManager(), pickerBottomSheet.getTag());
}
@Override
public void onItemAddClick(int position) {
if (ProfilePhotoPickerView.this.getHideAdd()) {
return;
}
ProfilePhotoPickerView.this.setPositionToAdd(position);
if (!ProfilePhotoPickerView.this.getCustomCamera()) {
ProfilePhotoPickerView.this.openGallery();
return;
}
DialogHelper dialogHelper = DialogHelper.INSTANCE;
Context context = ProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
final ProfilePhotoPickerView profilePhotoPickerView = ProfilePhotoPickerView.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) {
if (t != null) {
int i2 = WhenMappings.$EnumSwitchMapping$0[t.ordinal()];
if (i2 != 1) {
if (i2 != 2) {
return;
}
SingleImagePicker singleImagePicker = SingleImagePicker.INSTANCE;
Context context2 = ProfilePhotoPickerView.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 ProfilePhotoPickerView$init$2$onItemAddClick$1$onResult$2(ProfilePhotoPickerView.this));
return;
}
DazzleOptions init = DazzleOptions.INSTANCE.init();
init.setAllowFrontCamera(true);
init.setExcludeVideos(true);
init.setCropEnabled(true);
init.setCameraOnly(true);
init.setDefaultFrontCamera(true);
Dazzle.Companion companion = Dazzle.Companion;
AppCompatActivity context3 = ProfilePhotoPickerView.this.getContext();
Intrinsics.checkNotNull(context3, "null cannot be cast to non-null type androidx.appcompat.app.AppCompatActivity");
companion.startPicker((FragmentActivity) context3, init, ProfilePhotoPickerView.this.getCameraLauncher());
}
}
}, new DismissListener() {
public void onDismiss() {
}
});
}
@Override
public void onDeleteClick(String picturePath, int position) {
MyPhotoViewAdapter myPhotoViewAdapter2;
Intrinsics.checkNotNullParameter(picturePath, "picturePath");
ProfilePhotoPickerView.this.getSelectedPictures().set(position, "");
myPhotoViewAdapter2 = ProfilePhotoPickerView.this.adapter;
if (myPhotoViewAdapter2 != null) {
myPhotoViewAdapter2.notifyDataSetChanged();
}
}
});
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() {
ImagePicker.Companion companion = ImagePicker.Companion;
Context context = getContext();
Intrinsics.checkNotNull(context, "null cannot be cast to non-null type android.app.Activity");
companion.with((Activity) context).crop(3.0f, 4.0f).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");
ProfilePhotoPickerView.this.getLauncher().launch(intent);
}
});
}
public final void loadImage(ImageModel imageModel) {
File saveFileFromUri = FileHandler.saveFileFromUri(getContext(), imageModel.getContentUri(), "Pictures", "Picture_" + System.currentTimeMillis(), "jpg");
String path = saveFileFromUri != null ? saveFileFromUri.getPath() : null;
if (path == null) {
Toast.makeText(getContext(), getContext().getString(2131952060), 0).show();
return;
}
List<String> list = this.selectedPictures;
int i = this.positionToAdd;
ImageConverter imageConverter = ImageConverter.INSTANCE;
Context context = getContext();
Intrinsics.checkNotNullExpressionValue(context, "context");
list.set(i, imageConverter.convertImageToJpg(context, path));
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) {
imageView.setVisibility(hide ^ true ? 0 : 8);
}
this.hideAdd = hide;
}
}