discord-jadx/app/src/main/java/com/discord/utilities/rest/SendUtils$compressImageAtta...

231 lines
10 KiB
Java

package com.discord.utilities.rest;
import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import b.i.a.f.e.o.f;
import b0.a.a.a;
import b0.a.a.b;
import com.discord.utilities.attachments.AttachmentUtilsKt;
import com.lytefast.flexinput.model.Attachment;
import d0.l;
import d0.t.o;
import d0.w.h.c;
import d0.w.i.a.e;
import d0.w.i.a.k;
import d0.z.d.m;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import s.a.k0;
/* compiled from: SendUtils.kt */
@e(c = "com.discord.utilities.rest.SendUtils$compressImageAttachments$1", f = "SendUtils.kt", l = {321}, m = "invokeSuspend")
public final class SendUtils$compressImageAttachments$1 extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
public final /* synthetic */ List $attachments;
public final /* synthetic */ Context $context;
public final /* synthetic */ Function1 $onCompressed;
public Object L$0;
public Object L$1;
public Object L$2;
public Object L$3;
public int label;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public SendUtils$compressImageAttachments$1(List list, Context context, Function1 function1, Continuation continuation) {
super(2, continuation);
this.$attachments = list;
this.$context = context;
this.$onCompressed = function1;
}
@Override // d0.w.i.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
return new SendUtils$compressImageAttachments$1(this.$attachments, this.$context, this.$onCompressed, 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) {
return ((SendUtils$compressImageAttachments$1) create(coroutineScope, continuation)).invokeSuspend(Unit.a);
}
/* JADX WARNING: Removed duplicated region for block: B:14:0x004d */
@Override // d0.w.i.a.a
public final Object invokeSuspend(Object obj) {
SendUtils$compressImageAttachments$1 sendUtils$compressImageAttachments$1;
Iterator it;
Attachment<Uri> attachment;
Collection collection;
Collection collection2;
Iterator it2;
Collection collection3;
Collection collection4;
Collection collection5;
Attachment<Uri> attachment2;
Collection collection6;
Attachment<Uri> attachment3;
Object obj2;
SendUtils$compressImageAttachments$1 sendUtils$compressImageAttachments$12;
Object C1;
Object coroutine_suspended = c.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
l.throwOnFailure(obj);
List list = this.$attachments;
collection2 = new ArrayList(o.collectionSizeOrDefault(list, 10));
it2 = list.iterator();
sendUtils$compressImageAttachments$1 = this;
} else if (i == 1) {
collection2 = (Collection) this.L$3;
attachment2 = (Attachment) this.L$2;
it2 = (Iterator) this.L$1;
collection5 = (Collection) this.L$0;
try {
l.throwOnFailure(obj);
collection6 = collection5;
it = it2;
attachment3 = attachment2;
collection3 = collection2;
obj2 = coroutine_suspended;
sendUtils$compressImageAttachments$12 = this;
} catch (Exception unused) {
sendUtils$compressImageAttachments$1 = this;
collection3 = collection2;
collection4 = collection5;
it = it2;
attachment = attachment2;
collection = collection4;
collection2 = collection3;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
return Unit.a;
}
try {
Uri fromFile = Uri.fromFile((File) obj);
Attachment.Companion companion = Attachment.Companion;
m.checkNotNullExpressionValue(fromFile, "resultUri");
ContentResolver contentResolver = sendUtils$compressImageAttachments$12.$context.getContentResolver();
m.checkNotNullExpressionValue(contentResolver, "context.contentResolver");
} catch (Exception unused2) {
sendUtils$compressImageAttachments$1 = sendUtils$compressImageAttachments$12;
coroutine_suspended = obj2;
collection2 = collection3;
attachment2 = attachment3;
it2 = it;
collection5 = collection6;
collection3 = collection2;
collection4 = collection5;
it = it2;
attachment = attachment2;
collection = collection4;
collection2 = collection3;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
return Unit.a;
}
attachment = companion.b(fromFile, contentResolver);
sendUtils$compressImageAttachments$1 = sendUtils$compressImageAttachments$12;
coroutine_suspended = obj2;
collection4 = collection6;
collection = collection4;
collection2 = collection3;
collection2.add(attachment);
collection2 = collection;
it2 = it;
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
if (it2.hasNext()) {
attachment2 = (Attachment) it2.next();
if (!AttachmentUtilsKt.isImage(attachment2, sendUtils$compressImageAttachments$1.$context.getContentResolver()) || AttachmentUtilsKt.isGif(attachment2, sendUtils$compressImageAttachments$1.$context.getContentResolver())) {
it = it2;
attachment = attachment2;
collection = collection2;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
} else {
try {
Context context = sendUtils$compressImageAttachments$1.$context;
Uri uri = attachment2.getUri();
sendUtils$compressImageAttachments$1.L$0 = collection2;
sendUtils$compressImageAttachments$1.L$1 = it2;
sendUtils$compressImageAttachments$1.L$2 = attachment2;
sendUtils$compressImageAttachments$1.L$3 = collection2;
sendUtils$compressImageAttachments$1.label = 1;
C1 = f.C1(k0.f3814b, new b(a.j, context, uri, null), sendUtils$compressImageAttachments$1);
} catch (Exception unused3) {
collection5 = collection2;
collection3 = collection2;
collection4 = collection5;
it = it2;
attachment = attachment2;
collection = collection4;
collection2 = collection3;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
return Unit.a;
}
if (C1 != coroutine_suspended) {
collection6 = collection2;
obj2 = coroutine_suspended;
sendUtils$compressImageAttachments$12 = sendUtils$compressImageAttachments$1;
obj = C1;
it = it2;
attachment3 = attachment2;
collection3 = collection6;
Uri fromFile = Uri.fromFile((File) obj);
Attachment.Companion companion = Attachment.Companion;
m.checkNotNullExpressionValue(fromFile, "resultUri");
ContentResolver contentResolver = sendUtils$compressImageAttachments$12.$context.getContentResolver();
m.checkNotNullExpressionValue(contentResolver, "context.contentResolver");
attachment = companion.b(fromFile, contentResolver);
sendUtils$compressImageAttachments$1 = sendUtils$compressImageAttachments$12;
coroutine_suspended = obj2;
collection4 = collection6;
collection = collection4;
collection2 = collection3;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
}
return coroutine_suspended;
}
it = it2;
attachment = attachment2;
collection = collection2;
collection2.add(attachment);
collection2 = collection;
it2 = it;
if (it2.hasNext()) {
}
}
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
return Unit.a;
}
}