得物.apk(点击下载) / CalendarBatchInsertHandler$doPerform$2.java


package com.shizhuang.duapp.modules.web.handlers.defaults;

import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CalendarContract;
import androidx.activity.result.ActivityResultCaller;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.shizhuang.duapp.modules.growth_common.util.ActivityResultDeferred;
import com.shizhuang.duapp.modules.growth_common.util.DuPermissionResultLauncher;
import ed0.e;
import ed0.l;
import gy.a;
import ik1.f;
import ik1.h0;
import java.util.List;
import java.util.TimeZone;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt;
import kotlin.coroutines.jvm.internal.Boxing;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.io.CloseableKt;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.b;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002HŠ@¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;", "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"}, k = 3, mv = {1, 4, 2})
@DebugMetadata(c = "com.shizhuang.duapp.modules.web.handlers.defaults.CalendarBatchInsertHandler$doPerform$2", f = "CalendarBatchInsertHandler.kt", i = {0, 1, 1, 1}, l = {149, 163, 170}, m = "invokeSuspend", n = {"list", "list", "autoReject", "permissionResult"}, s = {"L$0", "L$0", "L$1", "L$2"})
/* compiled from: CalendarBatchInsertHandler.kt */
public final class CalendarBatchInsertHandler$doPerform$2 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
    public static ChangeQuickRedirect changeQuickRedirect;
    public final /* synthetic */ Context $context;
    public final /* synthetic */ Ref.ObjectRef $listPayload;
    public Object L$0;
    public Object L$1;
    public Object L$2;
    public Object L$3;
    public int label;
    public final /* synthetic */ CalendarBatchInsertHandler this$0;

    @Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002HŠ@¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;", "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"}, k = 3, mv = {1, 4, 2})
    @DebugMetadata(c = "com.shizhuang.duapp.modules.web.handlers.defaults.CalendarBatchInsertHandler$doPerform$2$1", f = "CalendarBatchInsertHandler.kt", i = {}, l = {177}, m = "invokeSuspend", n = {}, s = {})
    /* renamed from: com.shizhuang.duapp.modules.web.handlers.defaults.CalendarBatchInsertHandler$doPerform$2$1  reason: invalid class name */
    /* compiled from: CalendarBatchInsertHandler.kt */
    public static final class AnonymousClass1 extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
        public static ChangeQuickRedirect changeQuickRedirect;
        public int label;
        public final /* synthetic */ CalendarBatchInsertHandler$doPerform$2 this$0;

        {
            this.this$0 = r1;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @NotNull
        public final Continuation<Unit> create(@Nullable Object obj, @NotNull Continuation<?> continuation) {
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{obj, continuation}, this, changeQuickRedirect, false, 332553, new Class[]{Object.class, Continuation.class}, Continuation.class);
            return proxy.isSupported ? (Continuation) proxy.result : new AnonymousClass1(this.this$0, booleanRef2, objectRef, objectRef3, continuation);
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
        @Override // kotlin.jvm.functions.Function2
        public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{coroutineScope, continuation}, this, changeQuickRedirect, false, 332554, new Class[]{Object.class, Object.class}, Object.class);
            return proxy.isSupported ? proxy.result : ((AnonymousClass1) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
        }

        /* JADX WARNING: Code restructure failed: missing block: B:29:0x00ac, code lost:
            r0 = move-exception;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:30:0x00ad, code lost:
            kotlin.io.CloseableKt.closeFinally(r12, r0);
         */
        /* JADX WARNING: Code restructure failed: missing block: B:31:0x00b1, code lost:
            throw r0;
         */
        /* JADX WARNING: Removed duplicated region for block: B:35:0x00b5  */
        /* JADX WARNING: Removed duplicated region for block: B:45:0x014c  */
        /* JADX WARNING: Removed duplicated region for block: B:49:0x0157  */
        /* JADX WARNING: Removed duplicated region for block: B:52:0x016f  */
        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        @Nullable
        public final Object invokeSuspend(@NotNull Object obj) {
            long j;
            Long l;
            Uri insert;
            PatchProxyResult proxy = PatchProxy.proxy(new Object[]{obj}, this, changeQuickRedirect, false, 332552, new Class[]{Object.class}, Object.class);
            if (proxy.isSupported) {
                return proxy.result;
            }
            Object coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
            int i = this.label;
            if (i == 0) {
                ResultKt.throwOnFailure(obj);
                if (booleanRef2.element) {
                    CalendarBatchInsertHandler$doPerform$2 calendarBatchInsertHandler$doPerform$2 = this.this$0;
                    CalendarBatchInsertHandler calendarBatchInsertHandler = calendarBatchInsertHandler$doPerform$2.this$0;
                    Context context = calendarBatchInsertHandler$doPerform$2.$context;
                    PatchProxyResult proxy2 = PatchProxy.proxy(new Object[]{context}, calendarBatchInsertHandler, CalendarBatchInsertHandler.changeQuickRedirect, false, 332500, new Class[]{Context.class}, Long.TYPE);
                    if (proxy2.isSupported) {
                        j = ((Long) proxy2.result).longValue();
                    } else {
                        Long l12 = null;
                        try {
                            Cursor query = context.getContentResolver().query(CalendarContract.Calendars.CONTENT_URI, new String[]{"_id"}, null, null, null);
                            if (query != null) {
                                l = query.moveToFirst() ? Long.valueOf(query.getLong(query.getColumnIndexOrThrow("_id"))) : null;
                                CloseableKt.closeFinally(query, null);
                                if (l != null) {
                                    if (l.longValue() >= 0) {
                                        l12 = l;
                                    }
                                    if (l12 != null) {
                                        j = l12.longValue();
                                    }
                                }
                                ContentValues contentValues = new ContentValues();
                                contentValues.put("name", "得物");
                                contentValues.put("account_name", "dewu@shizhuang-inc.com");
                                contentValues.put("account_type", "LOCAL");
                                contentValues.put("calendar_displayName", "得物App");
                                contentValues.put("visible", (Integer) 1);
                                contentValues.put("calendar_color", (Integer) -16776961);
                                contentValues.put("calendar_access_level", (Integer) 700);
                                contentValues.put("sync_events", (Integer) 1);
                                contentValues.put("calendar_timezone", TimeZone.getDefault().getID());
                                contentValues.put("ownerAccount", "dewu@shizhuang-inc.com");
                                contentValues.put("canOrganizerRespond", (Integer) 0);
                                insert = context.getContentResolver().insert(CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter("caller_is_syncadapter", "true").appendQueryParameter("account_name", "dewu@shizhuang-inc.com").appendQueryParameter("account_type", "LOCAL").build(), contentValues);
                                if (insert != null) {
                                    j = ContentUris.parseId(insert);
                                }
                            }
                        } catch (Exception unused) {
                        }
                        l = null;
                        if (l != null) {
                        }
                        ContentValues contentValues2 = new ContentValues();
                        contentValues2.put("name", "得物");
                        contentValues2.put("account_name", "dewu@shizhuang-inc.com");
                        contentValues2.put("account_type", "LOCAL");
                        contentValues2.put("calendar_displayName", "得物App");
                        contentValues2.put("visible", (Integer) 1);
                        contentValues2.put("calendar_color", (Integer) -16776961);
                        contentValues2.put("calendar_access_level", (Integer) 700);
                        contentValues2.put("sync_events", (Integer) 1);
                        contentValues2.put("calendar_timezone", TimeZone.getDefault().getID());
                        contentValues2.put("ownerAccount", "dewu@shizhuang-inc.com");
                        contentValues2.put("canOrganizerRespond", (Integer) 0);
                        insert = context.getContentResolver().insert(CalendarContract.Calendars.CONTENT_URI.buildUpon().appendQueryParameter("caller_is_syncadapter", "true").appendQueryParameter("account_name", "dewu@shizhuang-inc.com").appendQueryParameter("account_type", "LOCAL").build(), contentValues2);
                        if (insert != null) {
                        }
                    }
                    if (j < 0) {
                        CalendarBatchInsertHandler$doPerform$2 calendarBatchInsertHandler$doPerform$22 = this.this$0;
                        this.label = 1;
                        if (calendarBatchInsertHandler$doPerform$22.this$0.b(calendarBatchInsertHandler$doPerform$22.$context, j, objectRef.element, this) == coroutine_suspended) {
                            return coroutine_suspended;
                        }
                    } else {
                        T t = objectRef3.element;
                        if (Intrinsics.areEqual(t, Boxing.boxBoolean(true))) {
                            this.this$0.this$0.h(1003);
                        } else if (Intrinsics.areEqual(t, Boxing.boxBoolean(false))) {
                            this.this$0.this$0.h(1004);
                        } else {
                            this.this$0.this$0.h(1000);
                        }
                    }
                }
                j = -1;
                if (j < 0) {
                }
            } else if (i == 1) {
                ResultKt.throwOnFailure(obj);
            } else {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            return Unit.INSTANCE;
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public CalendarBatchInsertHandler$doPerform$2(CalendarBatchInsertHandler calendarBatchInsertHandler, Ref.ObjectRef objectRef, Context context, Continuation continuation) {
        super(2, continuation);
        this.this$0 = calendarBatchInsertHandler;
        this.$listPayload = objectRef;
        this.$context = context;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    @NotNull
    public final Continuation<Unit> create(@Nullable Object obj, @NotNull Continuation<?> continuation) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{obj, continuation}, this, changeQuickRedirect, false, 332550, new Class[]{Object.class, Continuation.class}, Continuation.class);
        return proxy.isSupported ? (Continuation) proxy.result : new CalendarBatchInsertHandler$doPerform$2(this.this$0, this.$listPayload, this.$context, continuation);
    }

    /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
    @Override // kotlin.jvm.functions.Function2
    public final Object invoke(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{coroutineScope, continuation}, this, changeQuickRedirect, false, 332551, new Class[]{Object.class, Object.class}, Object.class);
        return proxy.isSupported ? proxy.result : ((CalendarBatchInsertHandler$doPerform$2) create(coroutineScope, continuation)).invokeSuspend(Unit.INSTANCE);
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x008c  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0096  */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    @Nullable
    public final Object invokeSuspend(@NotNull Object obj) {
        final Ref.ObjectRef objectRef;
        Ref.ObjectRef objectRef2;
        final Ref.ObjectRef objectRef3;
        Ref.BooleanRef booleanRef;
        final Ref.BooleanRef booleanRef2;
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{obj}, this, changeQuickRedirect, false, 332549, new Class[]{Object.class}, Object.class);
        if (proxy.isSupported) {
            return proxy.result;
        }
        Object coroutine_suspended = IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED();
        int i = this.label;
        if (i == 0) {
            objectRef2 = a.o(obj);
            b b = h0.b();
            CalendarBatchInsertHandler$doPerform$2$list$1 calendarBatchInsertHandler$doPerform$2$list$1 = new CalendarBatchInsertHandler$doPerform$2$list$1(this, null);
            this.L$0 = objectRef2;
            this.L$1 = objectRef2;
            this.label = 1;
            obj = f.l(b, calendarBatchInsertHandler$doPerform$2$list$1, this);
            if (obj == coroutine_suspended) {
                return coroutine_suspended;
            }
            objectRef = objectRef2;
            objectRef2.element = (T) ((List) obj);
            if (!objectRef.element.isEmpty()) {
            }
        } else if (i == 1) {
            objectRef2 = (Ref.ObjectRef) this.L$1;
            ResultKt.throwOnFailure(obj);
            objectRef = (Ref.ObjectRef) this.L$0;
            objectRef2.element = (T) ((List) obj);
            if (!objectRef.element.isEmpty()) {
                this.this$0.h(PushConstants.PUSHSERVICE_INFO_SEND_MESSAGE_BY_NOTIFICATION_SERVICE_ERROR);
                return Unit.INSTANCE;
            }
            objectRef3 = new Ref.ObjectRef();
            objectRef3.element = null;
            booleanRef = new Ref.BooleanRef();
            ActivityResultDeferred d = e.d(new DuPermissionResultLauncher((ActivityResultCaller) this.$context, new CalendarBatchInsertHandler$doPerform$2$permissionResult$1(objectRef3)), new l(new String[]{"android.permission.WRITE_CALENDAR", "android.permission.READ_CALENDAR"}, "日历权限", "申请开启读取/写入日历权限,用于提醒您次日参与活动赢取大额补贴", false), null, 2, null);
            this.L$0 = objectRef;
            this.L$1 = objectRef3;
            this.L$2 = booleanRef;
            this.L$3 = booleanRef;
            this.label = 2;
            obj = d.await(this);
            if (obj == coroutine_suspended) {
                return coroutine_suspended;
            }
            booleanRef2 = booleanRef;
        } else if (i == 2) {
            booleanRef = (Ref.BooleanRef) this.L$3;
            objectRef3 = (Ref.ObjectRef) this.L$1;
            objectRef = (Ref.ObjectRef) this.L$0;
            ResultKt.throwOnFailure(obj);
            booleanRef2 = (Ref.BooleanRef) this.L$2;
        } else if (i == 3) {
            ResultKt.throwOnFailure(obj);
            return Unit.INSTANCE;
        } else {
            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
        booleanRef.element = Intrinsics.areEqual((Boolean) obj, Boxing.boxBoolean(true));
        b b2 = h0.b();
        AnonymousClass1 r0 = new AnonymousClass1(this, null);
        this.L$0 = null;
        this.L$1 = null;
        this.L$2 = null;
        this.L$3 = null;
        this.label = 3;
        if (f.l(b2, r0, this) == coroutine_suspended) {
            return coroutine_suspended;
        }
        return Unit.INSTANCE;
    }
}