package com.discord.utilities.apng; import android.widget.ImageView; import c.l.a.a; import d0.l; import d0.w.g.c; import d0.w.h.a.e; import d0.w.h.a.k; import d0.y.b; import d0.z.d.m; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import kotlin.Unit; import kotlin.coroutines.Continuation; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.Ref$ObjectRef; import kotlinx.coroutines.CoroutineDispatcher; import kotlinx.coroutines.CoroutineScope; import s.a.a.n; import s.a.j0; import s.a.k1; /* compiled from: ApngUtils.kt */ @e(c = "com.discord.utilities.apng.ApngUtils$renderApngFromFile$3", f = "ApngUtils.kt", l = {31}, m = "invokeSuspend") public final class ApngUtils$renderApngFromFile$3 extends k implements Function2, Object> { public final /* synthetic */ boolean $autoPlay; public final /* synthetic */ File $file; public final /* synthetic */ Ref$ObjectRef $imageViewRef; public final /* synthetic */ Integer $maxHeight; public final /* synthetic */ Integer $maxWidth; public int label; /* compiled from: ApngUtils.kt */ @e(c = "com.discord.utilities.apng.ApngUtils$renderApngFromFile$3$1", f = "ApngUtils.kt", l = {}, m = "invokeSuspend") /* renamed from: com.discord.utilities.apng.ApngUtils$renderApngFromFile$3$1 reason: invalid class name */ public static final class AnonymousClass1 extends k implements Function2, Object> { public final /* synthetic */ Ref$ObjectRef $drawable; public int label; public final /* synthetic */ ApngUtils$renderApngFromFile$3 this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public AnonymousClass1(ApngUtils$renderApngFromFile$3 apngUtils$renderApngFromFile$3, Ref$ObjectRef ref$ObjectRef, Continuation continuation) { super(2, continuation); this.this$0 = apngUtils$renderApngFromFile$3; this.$drawable = ref$ObjectRef; } @Override // d0.w.h.a.a public final Continuation create(Object obj, Continuation continuation) { m.checkNotNullParameter(continuation, "completion"); return new AnonymousClass1(this.this$0, this.$drawable, 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 continuation) { return ((AnonymousClass1) create(coroutineScope, continuation)).invokeSuspend(Unit.a); } @Override // d0.w.h.a.a public final Object invokeSuspend(Object obj) { c.getCOROUTINE_SUSPENDED(); if (this.label == 0) { l.throwOnFailure(obj); ImageView imageView = (ImageView) this.this$0.$imageViewRef.element.get(); if (imageView == null) { return Unit.a; } m.checkNotNullExpressionValue(imageView, "imageViewRef.get() ?: return@withContext"); imageView.setImageDrawable(this.$drawable.element); if (this.this$0.$autoPlay) { ApngUtils.INSTANCE.playApngAnimation(this.$drawable.element); } return Unit.a; } throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public ApngUtils$renderApngFromFile$3(File file, Integer num, Integer num2, Ref$ObjectRef ref$ObjectRef, boolean z2, Continuation continuation) { super(2, continuation); this.$file = file; this.$maxHeight = num; this.$maxWidth = num2; this.$imageViewRef = ref$ObjectRef; this.$autoPlay = z2; } @Override // d0.w.h.a.a public final Continuation create(Object obj, Continuation continuation) { m.checkNotNullParameter(continuation, "completion"); return new ApngUtils$renderApngFromFile$3(this.$file, this.$maxHeight, this.$maxWidth, this.$imageViewRef, this.$autoPlay, 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 continuation) { return ((ApngUtils$renderApngFromFile$3) create(coroutineScope, continuation)).invokeSuspend(Unit.a); } /* JADX WARNING: Code restructure failed: missing block: B:19:0x005c, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:20:0x005d, code lost: d0.y.b.closeFinally(r5, r8); */ /* JADX WARNING: Code restructure failed: missing block: B:21:0x0060, code lost: throw r0; */ /* JADX WARNING: Unknown variable types count: 1 */ @Override // d0.w.h.a.a public final Object invokeSuspend(Object obj) { Object coroutine_suspended = c.getCOROUTINE_SUSPENDED(); int i = this.label; if (i == 0) { l.throwOnFailure(obj); Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef(); File file = this.$file; Integer num = this.$maxHeight; Integer num2 = this.$maxWidth; m.checkNotNullParameter(file, "file"); FileInputStream fileInputStream = new FileInputStream(file); BufferedInputStream bufferedInputStream = fileInputStream instanceof BufferedInputStream ? (BufferedInputStream) fileInputStream : new BufferedInputStream(fileInputStream, 8192); ?? a = a.a(bufferedInputStream, num2, num); b.closeFinally(bufferedInputStream, null); ref$ObjectRef.element = a; CoroutineDispatcher coroutineDispatcher = j0.a; k1 k1Var = n.b; AnonymousClass1 r4 = new AnonymousClass1(this, ref$ObjectRef, null); this.label = 1; if (c.q.a.k.a.i0(k1Var, r4, this) == coroutine_suspended) { return coroutine_suspended; } } else if (i == 1) { try { l.throwOnFailure(obj); } catch (Exception e) { e.printStackTrace(); } } else { throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine"); } return Unit.a; } }