discord-jadx/app/src/main/java/com/discord/views/calls/SpeakerPulseView.java

518 lines
22 KiB
Java

package com.discord.views.calls;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.animation.PathInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.discord.utilities.accessibility.AccessibilityUtils;
import com.discord.utilities.animations.AnimationCoroutineUtilsKt;
import com.discord.utilities.views.ViewCoroutineScopeKt;
import d0.g;
import d0.i;
import d0.l;
import d0.w.h.a.k;
import d0.z.d.m;
import d0.z.d.o;
import java.util.Objects;
import kotlin.Lazy;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.Job;
import s.a.e0;
import s.a.t;
/* compiled from: SpeakerPulseView.kt */
public final class SpeakerPulseView extends FrameLayout {
public final PathInterpolator i;
public final PathInterpolator j;
public boolean k;
public final t l = c.q.a.k.a.b(null, 1);
public Job m;
public final Lazy n;
public final Lazy o;
public boolean p;
/* compiled from: kotlin-style lambda group */
public static final class a extends o implements Function0<ImageView> {
public final /* synthetic */ int i;
public final /* synthetic */ Object j;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public a(int i, Object obj) {
super(0);
this.i = i;
this.j = obj;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public final ImageView mo1invoke() {
int i = this.i;
if (i == 0) {
return SpeakerPulseView.a((SpeakerPulseView) this.j, 0);
}
if (i == 1) {
return SpeakerPulseView.a((SpeakerPulseView) this.j, 1);
}
throw null;
}
}
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView", f = "SpeakerPulseView.kt", l = {129, 135}, m = "animatePulse")
public static final class b extends d0.w.h.a.d {
public long J$0;
public Object L$0;
public Object L$1;
public int label;
public /* synthetic */ Object result;
public final /* synthetic */ SpeakerPulseView this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public b(SpeakerPulseView speakerPulseView, Continuation continuation) {
super(continuation);
this.this$0 = speakerPulseView;
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
this.result = obj;
this.label |= Integer.MIN_VALUE;
return this.this$0.d(null, 0, 0, this);
}
}
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView", f = "SpeakerPulseView.kt", l = {117}, m = "performPulseAnimation")
public static final class c extends d0.w.h.a.d {
public Object L$0;
public Object L$1;
public int label;
public /* synthetic */ Object result;
public final /* synthetic */ SpeakerPulseView this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public c(SpeakerPulseView speakerPulseView, Continuation continuation) {
super(continuation);
this.this$0 = speakerPulseView;
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
this.result = obj;
this.label |= Integer.MIN_VALUE;
return this.this$0.e(null, this);
}
}
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView$performPulseAnimation$inner$1", f = "SpeakerPulseView.kt", l = {106}, m = "invokeSuspend")
public static final class d extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
public int label;
public final /* synthetic */ SpeakerPulseView this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public d(SpeakerPulseView speakerPulseView, Continuation continuation) {
super(2, continuation);
this.this$0 = speakerPulseView;
}
@Override // d0.w.h.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
return new d(this.this$0, 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) {
Continuation<? super Unit> continuation2 = continuation;
m.checkNotNullParameter(continuation2, "completion");
return new d(this.this$0, continuation2).invokeSuspend(Unit.a);
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
l.throwOnFailure(obj);
SpeakerPulseView speakerPulseView = this.this$0;
ImageView b = SpeakerPulseView.b(speakerPulseView);
this.label = 1;
if (speakerPulseView.d(b, 200, 500, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else if (i == 1) {
l.throwOnFailure(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return Unit.a;
}
}
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView$performPulseAnimation$outer$1", f = "SpeakerPulseView.kt", l = {113}, m = "invokeSuspend")
public static final class e extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
public int label;
public final /* synthetic */ SpeakerPulseView this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public e(SpeakerPulseView speakerPulseView, Continuation continuation) {
super(2, continuation);
this.this$0 = speakerPulseView;
}
@Override // d0.w.h.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
return new e(this.this$0, 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) {
Continuation<? super Unit> continuation2 = continuation;
m.checkNotNullParameter(continuation2, "completion");
return new e(this.this$0, continuation2).invokeSuspend(Unit.a);
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
l.throwOnFailure(obj);
SpeakerPulseView speakerPulseView = this.this$0;
ImageView c2 = SpeakerPulseView.c(speakerPulseView);
this.label = 1;
if (speakerPulseView.d(c2, 700, 0, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else if (i == 1) {
l.throwOnFailure(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return Unit.a;
}
}
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView$startAnimating$1", f = "SpeakerPulseView.kt", l = {87}, m = "invokeSuspend")
public static final class f extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
public int label;
public final /* synthetic */ SpeakerPulseView this$0;
/* compiled from: SpeakerPulseView.kt */
@d0.w.h.a.e(c = "com.discord.views.calls.SpeakerPulseView$startAnimating$1$1", f = "SpeakerPulseView.kt", l = {88}, m = "invokeSuspend")
public static final class a extends k implements Function2<CoroutineScope, Continuation<? super Unit>, Object> {
private /* synthetic */ Object L$0;
public int label;
public final /* synthetic */ f this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public a(f fVar, Continuation continuation) {
super(2, continuation);
this.this$0 = fVar;
}
@Override // d0.w.h.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
a aVar = new a(this.this$0, continuation);
aVar.L$0 = obj;
return aVar;
}
/* 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) {
Continuation<? super Unit> continuation2 = continuation;
m.checkNotNullParameter(continuation2, "completion");
a aVar = new a(this.this$0, continuation2);
aVar.L$0 = coroutineScope;
return aVar.invokeSuspend(Unit.a);
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
l.throwOnFailure(obj);
SpeakerPulseView speakerPulseView = this.this$0.this$0;
this.label = 1;
if (speakerPulseView.e((CoroutineScope) this.L$0, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else if (i == 1) {
l.throwOnFailure(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return Unit.a;
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public f(SpeakerPulseView speakerPulseView, Continuation continuation) {
super(2, continuation);
this.this$0 = speakerPulseView;
}
@Override // d0.w.h.a.a
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
m.checkNotNullParameter(continuation, "completion");
return new f(this.this$0, 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) {
Continuation<? super Unit> continuation2 = continuation;
m.checkNotNullParameter(continuation2, "completion");
return new f(this.this$0, continuation2).invokeSuspend(Unit.a);
}
@Override // d0.w.h.a.a
public final Object invokeSuspend(Object obj) {
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
l.throwOnFailure(obj);
t tVar = this.this$0.l;
a aVar = new a(this, null);
this.label = 1;
if (c.q.a.k.a.i0(tVar, aVar, this) == coroutine_suspended) {
return coroutine_suspended;
}
} else if (i == 1) {
l.throwOnFailure(obj);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return Unit.a;
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public SpeakerPulseView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
PathInterpolator pathInterpolator = new PathInterpolator(0.4f, 0.0f, 1.0f, 1.0f);
this.i = pathInterpolator;
this.j = pathInterpolator;
i iVar = i.NONE;
this.n = g.lazy(iVar, new a(0, this));
this.o = g.lazy(iVar, new a(1, this));
setClipChildren(false);
setClipToOutline(false);
setClipToPadding(false);
}
public static final ImageView a(SpeakerPulseView speakerPulseView, int i) {
Objects.requireNonNull(speakerPulseView);
ImageView imageView = new ImageView(speakerPulseView.getContext());
int i2 = -1;
View childAt = speakerPulseView.getChildAt(speakerPulseView.getChildCount() - 1);
float paddingLeft = ((float) speakerPulseView.getPaddingLeft()) / 2.0f;
int i3 = i + 1;
m.checkNotNullExpressionValue(childAt, "actualChild");
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
Integer valueOf = layoutParams != null ? Integer.valueOf(layoutParams.width + ((int) (((float) 2) * paddingLeft * ((float) i3)))) : null;
imageView.setAlpha(0.0f);
imageView.setImageResource(2131231096);
int coerceAtLeast = d0.d0.f.coerceAtLeast(speakerPulseView.getChildCount() - 1, 0);
int intValue = valueOf != null ? valueOf.intValue() : -1;
if (valueOf != null) {
i2 = valueOf.intValue();
}
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(intValue, i2);
layoutParams2.gravity = 17;
speakerPulseView.addView(imageView, coerceAtLeast, layoutParams2);
return imageView;
}
public static final /* synthetic */ ImageView b(SpeakerPulseView speakerPulseView) {
return speakerPulseView.getInnerView();
}
public static final /* synthetic */ ImageView c(SpeakerPulseView speakerPulseView) {
return speakerPulseView.getOuterView();
}
private final ImageView getInnerView() {
return (ImageView) this.n.getValue();
}
private final ImageView getOuterView() {
return (ImageView) this.o.getValue();
}
/* JADX WARNING: Removed duplicated region for block: B:14:0x0042 */
/* JADX WARNING: Removed duplicated region for block: B:20:0x00a0 A[RETURN] */
/* JADX WARNING: Removed duplicated region for block: B:8:0x0024 */
public final /* synthetic */ Object d(View view, long j, long j2, Continuation<? super Unit> continuation) {
b bVar;
Object coroutine_suspended;
int i;
SpeakerPulseView speakerPulseView;
ViewPropertyAnimator alpha;
if (continuation instanceof b) {
bVar = (b) continuation;
int i2 = bVar.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
bVar.label = i2 - Integer.MIN_VALUE;
Object obj = bVar.result;
coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
i = bVar.label;
if (i != 0) {
l.throwOnFailure(obj);
ViewPropertyAnimator alpha2 = view.animate().setInterpolator(this.i).setStartDelay(j).setDuration(500).alpha(0.16f);
m.checkNotNullExpressionValue(alpha2, "animate()\n .setIn… .alpha(PULSE_OPACITY)");
bVar.L$0 = this;
bVar.L$1 = view;
bVar.J$0 = j2;
bVar.label = 1;
if (AnimationCoroutineUtilsKt.await(alpha2, bVar) == coroutine_suspended) {
return coroutine_suspended;
}
speakerPulseView = this;
} else if (i == 1) {
j2 = bVar.J$0;
view = (View) bVar.L$1;
speakerPulseView = (SpeakerPulseView) bVar.L$0;
l.throwOnFailure(obj);
} else if (i == 2) {
l.throwOnFailure(obj);
return Unit.a;
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
alpha = view.animate().setInterpolator(speakerPulseView.j).setStartDelay(j2).setDuration(1000).alpha(0.0f);
m.checkNotNullExpressionValue(alpha, "animate()\n .setIn…ON_MS)\n .alpha(0f)");
bVar.L$0 = null;
bVar.L$1 = null;
bVar.label = 2;
if (AnimationCoroutineUtilsKt.await(alpha, bVar) == coroutine_suspended) {
return coroutine_suspended;
}
return Unit.a;
}
}
bVar = new b(this, continuation);
Object obj = bVar.result;
coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
i = bVar.label;
if (i != 0) {
}
alpha = view.animate().setInterpolator(speakerPulseView.j).setStartDelay(j2).setDuration(1000).alpha(0.0f);
m.checkNotNullExpressionValue(alpha, "animate()\n .setIn…ON_MS)\n .alpha(0f)");
bVar.L$0 = null;
bVar.L$1 = null;
bVar.label = 2;
if (AnimationCoroutineUtilsKt.await(alpha, bVar) == coroutine_suspended) {
}
return Unit.a;
}
/* JADX WARNING: Removed duplicated region for block: B:12:0x0040 */
/* JADX WARNING: Removed duplicated region for block: B:15:0x004c */
/* JADX WARNING: Removed duplicated region for block: B:8:0x0029 */
public final /* synthetic */ Object e(CoroutineScope coroutineScope, Continuation<? super Unit> continuation) {
SpeakerPulseView speakerPulseView;
c cVar;
int i;
CoroutineScope coroutineScope2;
SpeakerPulseView speakerPulseView2;
if (continuation instanceof c) {
cVar = (c) continuation;
int i2 = cVar.label;
if ((i2 & Integer.MIN_VALUE) != 0) {
cVar.label = i2 - Integer.MIN_VALUE;
speakerPulseView = this;
Object obj = cVar.result;
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
i = cVar.label;
if (i != 0) {
l.throwOnFailure(obj);
coroutineScope2 = coroutineScope;
speakerPulseView2 = speakerPulseView;
} else if (i == 1) {
coroutineScope2 = (CoroutineScope) cVar.L$1;
l.throwOnFailure(obj);
speakerPulseView2 = (SpeakerPulseView) cVar.L$0;
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
while (c.q.a.k.a.A(coroutineScope2)) {
e0[] e0VarArr = {c.q.a.k.a.f(coroutineScope2, null, null, new d(speakerPulseView2, null), 3, null), c.q.a.k.a.f(coroutineScope2, null, null, new e(speakerPulseView2, null), 3, null)};
cVar.L$0 = speakerPulseView2;
cVar.L$1 = coroutineScope2;
cVar.label = 1;
if (c.q.a.k.a.g(e0VarArr, cVar) == coroutine_suspended) {
return coroutine_suspended;
}
}
return Unit.a;
}
}
speakerPulseView = this;
cVar = new c(speakerPulseView, continuation);
Object obj = cVar.result;
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
i = cVar.label;
if (i != 0) {
}
while (c.q.a.k.a.A(coroutineScope2)) {
}
return Unit.a;
}
public final void f() {
CoroutineScope coroutineScope = ViewCoroutineScopeKt.getCoroutineScope(this);
if (coroutineScope != null && !AccessibilityUtils.INSTANCE.isReducedMotionEnabled()) {
this.k = true;
Job job = this.m;
if (job != null) {
c.q.a.k.a.k(job, null, 1, null);
}
this.m = c.q.a.k.a.G(coroutineScope, null, null, new f(this, null), 3, null);
}
}
@Override // android.view.View, android.view.ViewGroup
public void onAttachedToWindow() {
super.onAttachedToWindow();
if (this.p) {
f();
}
}
public final void setPulsing(boolean z2) {
if (this.p != z2) {
this.p = z2;
if (z2) {
f();
return;
}
for (Job job : this.l.d()) {
job.B(null);
}
if (this.k) {
getInnerView().animate().setDuration(500).alpha(0.0f);
getOuterView().animate().setDuration(500).alpha(0.0f);
}
}
}
}