2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.utilities.rest;
|
|
|
|
|
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
2021-11-05 21:05:33 +00:00
|
|
|
import b0.a.a.a;
|
2021-11-01 07:19:03 +00:00
|
|
|
import b0.a.a.b;
|
2021-11-05 21:05:33 +00:00
|
|
|
import c.i.a.f.e.o.f;
|
2021-08-09 22:50:52 +00:00
|
|
|
import com.discord.utilities.attachments.AttachmentUtilsKt;
|
|
|
|
import com.lytefast.flexinput.model.Attachment;
|
2021-11-01 07:19:03 +00:00
|
|
|
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;
|
2021-08-09 22:50:52 +00:00
|
|
|
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;
|
2021-11-01 07:19:03 +00:00
|
|
|
import s.a.j0;
|
2021-08-09 22:50:52 +00:00
|
|
|
/* compiled from: SendUtils.kt */
|
2021-11-15 08:33:29 +00:00
|
|
|
@e(c = "com.discord.utilities.rest.SendUtils$compressImageAttachments$1", f = "SendUtils.kt", l = {300}, m = "invokeSuspend")
|
2021-08-09 22:50:52 +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;
|
|
|
|
}
|
|
|
|
|
2021-11-01 07:19:03 +00:00
|
|
|
@Override // d0.w.i.a.a
|
2021-08-09 22:50:52 +00:00
|
|
|
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 */
|
2021-11-01 07:19:03 +00:00
|
|
|
@Override // d0.w.i.a.a
|
2021-08-09 22:50:52 +00:00
|
|
|
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-11-05 21:05:33 +00:00
|
|
|
Object k1;
|
2021-08-09 22:50:52 +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;
|
|
|
|
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;
|
|
|
|
}
|
2021-11-01 07:19:03 +00:00
|
|
|
attachment = companion.b(fromFile, contentResolver);
|
2021-08-09 22:50:52 +00:00
|
|
|
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;
|
2021-11-05 21:05:33 +00:00
|
|
|
k1 = f.k1(j0.b, new b(a.i, context, uri, null), sendUtils$compressImageAttachments$1);
|
2021-08-09 22:50:52 +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;
|
|
|
|
if (it2.hasNext()) {
|
|
|
|
}
|
|
|
|
sendUtils$compressImageAttachments$1.$onCompressed.invoke((List) collection2);
|
|
|
|
return Unit.a;
|
|
|
|
}
|
2021-11-05 21:05:33 +00:00
|
|
|
if (k1 != coroutine_suspended) {
|
2021-08-09 22:50:52 +00:00
|
|
|
collection6 = collection2;
|
|
|
|
obj2 = coroutine_suspended;
|
|
|
|
sendUtils$compressImageAttachments$12 = sendUtils$compressImageAttachments$1;
|
2021-11-05 21:05:33 +00:00
|
|
|
obj = k1;
|
2021-08-09 22:50:52 +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");
|
2021-11-01 07:19:03 +00:00
|
|
|
attachment = companion.b(fromFile, contentResolver);
|
2021-08-09 22:50:52 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|