2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.utilities.rest;
|
|
|
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
|
|
|
import b0.a.a.b;
|
|
|
|
import c.q.a.k.a;
|
|
|
|
import com.discord.utilities.attachments.AttachmentUtilsKt;
|
|
|
|
import com.lytefast.flexinput.model.Attachment;
|
|
|
|
import d0.l;
|
|
|
|
import d0.t.o;
|
|
|
|
import d0.w.g.c;
|
|
|
|
import d0.w.h.a.e;
|
|
|
|
import d0.w.h.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.j0;
|
|
|
|
/* compiled from: SendUtils.kt */
|
2021-06-27 20:53:42 +00:00
|
|
|
@e(c = "com.discord.utilities.rest.SendUtils$compressImageAttachments$1", f = "SendUtils.kt", l = {207}, m = "invokeSuspend")
|
2021-06-27 20:44:35 +00:00
|
|
|
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.h.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);
|
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:14:0x004d */
|
2021-06-27 20:44:35 +00:00
|
|
|
@Override // d0.w.h.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;
|
2021-06-27 20:53:42 +00:00
|
|
|
Object i02;
|
2021-06-27 20:44:35 +00:00
|
|
|
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;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
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;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
|
|
|
|
return Unit.a;
|
|
|
|
}
|
|
|
|
attachment = companion.a(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");
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
attachment2 = (Attachment) it2.next();
|
2021-06-27 20:53:42 +00:00
|
|
|
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 {
|
2021-06-27 20:44:35 +00:00
|
|
|
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;
|
2021-06-27 20:53:42 +00:00
|
|
|
i02 = a.i0(j0.b, new b(b0.a.a.a.i, context, uri, null), sendUtils$compressImageAttachments$1);
|
2021-06-27 20:44:35 +00:00
|
|
|
} catch (Exception unused3) {
|
|
|
|
collection5 = collection2;
|
|
|
|
collection3 = collection2;
|
|
|
|
collection4 = collection5;
|
|
|
|
it = it2;
|
|
|
|
attachment = attachment2;
|
|
|
|
collection = collection4;
|
|
|
|
collection2 = collection3;
|
|
|
|
collection2.add(attachment);
|
|
|
|
collection2 = collection;
|
|
|
|
it2 = it;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
|
|
|
|
return Unit.a;
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
if (i02 != coroutine_suspended) {
|
2021-06-27 20:44:35 +00:00
|
|
|
collection6 = collection2;
|
|
|
|
obj2 = coroutine_suspended;
|
|
|
|
sendUtils$compressImageAttachments$12 = sendUtils$compressImageAttachments$1;
|
2021-06-27 20:53:42 +00:00
|
|
|
obj = i02;
|
2021-06-27 20:44:35 +00:00
|
|
|
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.a(fromFile, contentResolver);
|
|
|
|
sendUtils$compressImageAttachments$1 = sendUtils$compressImageAttachments$12;
|
|
|
|
coroutine_suspended = obj2;
|
|
|
|
collection4 = collection6;
|
|
|
|
collection = collection4;
|
|
|
|
collection2 = collection3;
|
|
|
|
collection2.add(attachment);
|
|
|
|
collection2 = collection;
|
|
|
|
it2 = it;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return coroutine_suspended;
|
|
|
|
}
|
|
|
|
it = it2;
|
|
|
|
attachment = attachment2;
|
|
|
|
collection = collection2;
|
|
|
|
collection2.add(attachment);
|
|
|
|
collection2 = collection;
|
|
|
|
it2 = it;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (it2.hasNext()) {
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
|
|
|
|
return Unit.a;
|
|
|
|
}
|
|
|
|
}
|