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

1080 lines
57 KiB
Java

package com.discord.views.calls;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.Space;
import android.widget.TextView;
import androidx.annotation.MainThread;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
import androidx.core.view.DisplayCutoutCompat;
import androidx.core.view.ViewGroupKt;
import c.a.i.x3;
import c.a.k.b;
import c.a.y.i0.j;
import c.a.y.i0.k;
import c.a.y.i0.l;
import c.a.y.i0.n;
import c.a.y.i0.o;
import com.discord.R;
import com.discord.api.voice.state.VoiceState;
import com.discord.stores.StoreApplicationStreamPreviews;
import com.discord.stores.StoreVoiceParticipants;
import com.discord.utilities.colors.RepresentativeColorsKt;
import com.discord.utilities.dimen.DimenUtils;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
import com.discord.utilities.streams.StreamContext;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.utilities.view.grid.FrameGridLayout;
import com.discord.views.VoiceUserView;
import com.discord.widgets.voice.fullscreen.grid.VideoCallGridAdapter;
import com.facebook.drawee.view.SimpleDraweeView;
import d0.g0.w;
import d0.z.d.m;
import java.util.Iterator;
import java.util.Objects;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import org.webrtc.RendererCommon;
import rx.Observable;
import rx.Subscription;
import rx.subjects.BehaviorSubject;
/* compiled from: VideoCallParticipantView.kt */
public final class VideoCallParticipantView extends ConstraintLayout implements FrameGridLayout.DataView {
public final x3 i;
public final boolean j;
public ParticipantData k;
public String l;
public Function1<? super String, Unit> m;
public Subscription n;
public boolean o;
public Subscription p;
public DisplayCutoutCompat q;
public boolean r;
/* renamed from: s reason: collision with root package name */
public VideoCallGridAdapter.CallUiInsets f2137s;
public boolean t;
public Drawable u;
public Drawable v;
public Function2<? super StreamResolution, ? super StreamFps, Unit> w;
/* renamed from: x reason: collision with root package name */
public Function2<? super StreamResolution, ? super StreamFps, Unit> f2138x;
/* compiled from: VideoCallParticipantView.kt */
public static final class ParticipantData implements FrameGridLayout.Data {
public final String a;
public final StoreVoiceParticipants.VoiceUser b;
/* renamed from: c reason: collision with root package name */
public final boolean f2139c;
public final RendererCommon.ScalingType d;
public final RendererCommon.ScalingType e;
public final ApplicationStreamState f;
public final Type g;
public final boolean h;
public final boolean i;
public final a j;
/* compiled from: VideoCallParticipantView.kt */
public enum ApplicationStreamState {
CONNECTING,
ACTIVE,
INACTIVE,
PAUSED,
ENDED
}
/* compiled from: VideoCallParticipantView.kt */
public enum Type {
DEFAULT,
APPLICATION_STREAMING
}
/* compiled from: VideoCallParticipantView.kt */
public static final class a {
public final boolean a;
public final StreamResolution b;
/* renamed from: c reason: collision with root package name */
public final StreamFps f2140c;
public final boolean d;
public a(boolean z2, StreamResolution streamResolution, StreamFps streamFps, boolean z3) {
m.checkNotNullParameter(streamResolution, "resolution");
this.a = z2;
this.b = streamResolution;
this.f2140c = streamFps;
this.d = z3;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof a)) {
return false;
}
a aVar = (a) obj;
return this.a == aVar.a && m.areEqual(this.b, aVar.b) && m.areEqual(this.f2140c, aVar.f2140c) && this.d == aVar.d;
}
public int hashCode() {
boolean z2 = this.a;
int i = 1;
if (z2) {
z2 = true;
}
int i2 = z2 ? 1 : 0;
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = i2 * 31;
StreamResolution streamResolution = this.b;
int i6 = 0;
int hashCode = (i5 + (streamResolution != null ? streamResolution.hashCode() : 0)) * 31;
StreamFps streamFps = this.f2140c;
if (streamFps != null) {
i6 = streamFps.hashCode();
}
int i7 = (hashCode + i6) * 31;
boolean z3 = this.d;
if (!z3) {
i = z3 ? 1 : 0;
}
return i7 + i;
}
public String toString() {
StringBuilder K = c.d.b.a.a.K("StreamQualityIndicatorData(showPremiumIcon=");
K.append(this.a);
K.append(", resolution=");
K.append(this.b);
K.append(", fps=");
K.append(this.f2140c);
K.append(", isBadQuality=");
return c.d.b.a.a.F(K, this.d, ")");
}
}
/* JADX DEBUG: TODO: convert one arg to string using `String.valueOf()`, args: [(wrap: long : 0x002a: INVOKE (r4v1 long) =
(wrap: com.discord.models.user.User : 0x0026: INVOKE (r2v1 com.discord.models.user.User) = (r2v0 com.discord.stores.StoreVoiceParticipants$VoiceUser) type: VIRTUAL call: com.discord.stores.StoreVoiceParticipants.VoiceUser.getUser():com.discord.models.user.User)
type: INTERFACE call: com.discord.models.user.User.getId():long), (r7v0 com.discord.views.calls.VideoCallParticipantView$ParticipantData$Type)] */
public ParticipantData(StoreVoiceParticipants.VoiceUser voiceUser, boolean z2, RendererCommon.ScalingType scalingType, RendererCommon.ScalingType scalingType2, ApplicationStreamState applicationStreamState, Type type, boolean z3, boolean z4, a aVar) {
m.checkNotNullParameter(voiceUser, "participant");
m.checkNotNullParameter(type, "type");
this.b = voiceUser;
this.f2139c = z2;
this.d = scalingType;
this.e = scalingType2;
this.f = applicationStreamState;
this.g = type;
this.h = z3;
this.i = z4;
this.j = aVar;
StringBuilder sb = new StringBuilder();
sb.append(voiceUser.getUser().getId());
sb.append(type);
this.a = sb.toString();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ ParticipantData(StoreVoiceParticipants.VoiceUser voiceUser, boolean z2, RendererCommon.ScalingType scalingType, RendererCommon.ScalingType scalingType2, ApplicationStreamState applicationStreamState, Type type, boolean z3, boolean z4, a aVar, int i) {
this(voiceUser, (i & 2) != 0 ? false : z2, (i & 4) != 0 ? RendererCommon.ScalingType.SCALE_ASPECT_BALANCED : scalingType, (i & 8) != 0 ? RendererCommon.ScalingType.SCALE_ASPECT_FIT : scalingType2, (i & 16) != 0 ? null : applicationStreamState, (i & 32) != 0 ? Type.DEFAULT : type, (i & 64) != 0 ? false : z3, (i & 128) != 0 ? false : z4, null);
int i2 = i & 256;
}
public static ParticipantData a(ParticipantData participantData, StoreVoiceParticipants.VoiceUser voiceUser, boolean z2, RendererCommon.ScalingType scalingType, RendererCommon.ScalingType scalingType2, ApplicationStreamState applicationStreamState, Type type, boolean z3, boolean z4, a aVar, int i) {
Type type2 = null;
StoreVoiceParticipants.VoiceUser voiceUser2 = (i & 1) != 0 ? participantData.b : null;
boolean z5 = (i & 2) != 0 ? participantData.f2139c : z2;
RendererCommon.ScalingType scalingType3 = (i & 4) != 0 ? participantData.d : scalingType;
RendererCommon.ScalingType scalingType4 = (i & 8) != 0 ? participantData.e : scalingType2;
ApplicationStreamState applicationStreamState2 = (i & 16) != 0 ? participantData.f : null;
if ((i & 32) != 0) {
type2 = participantData.g;
}
boolean z6 = (i & 64) != 0 ? participantData.h : z3;
boolean z7 = (i & 128) != 0 ? participantData.i : z4;
a aVar2 = (i & 256) != 0 ? participantData.j : aVar;
m.checkNotNullParameter(voiceUser2, "participant");
m.checkNotNullParameter(type2, "type");
return new ParticipantData(voiceUser2, z5, scalingType3, scalingType4, applicationStreamState2, type2, z6, z7, aVar2);
}
public final Integer b() {
VoiceState voiceState;
int ordinal = this.g.ordinal();
if (ordinal == 0) {
VoiceState voiceState2 = this.b.getVoiceState();
if (voiceState2 == null || !voiceState2.j()) {
return null;
}
return this.b.getCallStreamId();
} else if (ordinal == 1) {
ApplicationStreamState applicationStreamState = this.f;
if ((applicationStreamState == ApplicationStreamState.CONNECTING || applicationStreamState == ApplicationStreamState.ACTIVE || applicationStreamState == ApplicationStreamState.PAUSED) && (voiceState = this.b.getVoiceState()) != null && voiceState.i()) {
return this.b.getApplicationStreamId();
}
return null;
} else {
throw new NoWhenBranchMatchedException();
}
}
@Override // com.discord.utilities.view.grid.FrameGridLayout.Data
public View createView(Context context) {
m.checkNotNullParameter(context, "context");
return new VideoCallParticipantView(context, null, 0, 6);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ParticipantData)) {
return false;
}
ParticipantData participantData = (ParticipantData) obj;
return m.areEqual(this.b, participantData.b) && this.f2139c == participantData.f2139c && m.areEqual(this.d, participantData.d) && m.areEqual(this.e, participantData.e) && m.areEqual(this.f, participantData.f) && m.areEqual(this.g, participantData.g) && this.h == participantData.h && this.i == participantData.i && m.areEqual(this.j, participantData.j);
}
@Override // com.discord.utilities.view.grid.FrameGridLayout.Data
public String getId() {
return this.a;
}
public int hashCode() {
StoreVoiceParticipants.VoiceUser voiceUser = this.b;
int i = 0;
int hashCode = (voiceUser != null ? voiceUser.hashCode() : 0) * 31;
boolean z2 = this.f2139c;
int i2 = 1;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
int i6 = (hashCode + i3) * 31;
RendererCommon.ScalingType scalingType = this.d;
int hashCode2 = (i6 + (scalingType != null ? scalingType.hashCode() : 0)) * 31;
RendererCommon.ScalingType scalingType2 = this.e;
int hashCode3 = (hashCode2 + (scalingType2 != null ? scalingType2.hashCode() : 0)) * 31;
ApplicationStreamState applicationStreamState = this.f;
int hashCode4 = (hashCode3 + (applicationStreamState != null ? applicationStreamState.hashCode() : 0)) * 31;
Type type = this.g;
int hashCode5 = (hashCode4 + (type != null ? type.hashCode() : 0)) * 31;
boolean z3 = this.h;
if (z3) {
z3 = true;
}
int i7 = z3 ? 1 : 0;
int i8 = z3 ? 1 : 0;
int i9 = z3 ? 1 : 0;
int i10 = (hashCode5 + i7) * 31;
boolean z4 = this.i;
if (!z4) {
i2 = z4 ? 1 : 0;
}
int i11 = (i10 + i2) * 31;
a aVar = this.j;
if (aVar != null) {
i = aVar.hashCode();
}
return i11 + i;
}
public String toString() {
StringBuilder K = c.d.b.a.a.K("ParticipantData(participant=");
K.append(this.b);
K.append(", mirrorVideo=");
K.append(this.f2139c);
K.append(", scalingType=");
K.append(this.d);
K.append(", scalingTypeMismatchOrientation=");
K.append(this.e);
K.append(", applicationStreamState=");
K.append(this.f);
K.append(", type=");
K.append(this.g);
K.append(", showLabel=");
K.append(this.h);
K.append(", isFocused=");
K.append(this.i);
K.append(", streamQualityIndicatorData=");
K.append(this.j);
K.append(")");
return K.toString();
}
}
/* compiled from: VideoCallParticipantView.kt */
public static final class StreamFps {
public final int a;
public StreamFps(int i) {
this.a = i;
}
public final boolean a() {
return this.a == 60;
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof StreamFps) && this.a == ((StreamFps) obj).a;
}
return true;
}
public int hashCode() {
return this.a;
}
public String toString() {
return c.d.b.a.a.w(c.d.b.a.a.K("StreamFps(fps="), this.a, ")");
}
}
/* compiled from: VideoCallParticipantView.kt */
public static abstract class StreamResolution {
/* compiled from: VideoCallParticipantView.kt */
public static final class a extends StreamResolution {
public final int a;
public a(int i) {
super(null);
this.a = i;
}
@Override // com.discord.views.calls.VideoCallParticipantView.StreamResolution
public CharSequence a(Context context) {
m.checkNotNullParameter(context, "context");
return c.a.k.b.g(context, 2131893213, new Object[]{Integer.valueOf(this.a)}, null, 4);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof a) && this.a == ((a) obj).a;
}
return true;
}
public int hashCode() {
return this.a;
}
public String toString() {
return c.d.b.a.a.w(c.d.b.a.a.K("Fixed(heightPx="), this.a, ")");
}
}
/* compiled from: VideoCallParticipantView.kt */
public static final class b extends StreamResolution {
public static final b a = new b();
public b() {
super(null);
}
@Override // com.discord.views.calls.VideoCallParticipantView.StreamResolution
public CharSequence a(Context context) {
m.checkNotNullParameter(context, "context");
return c.a.k.b.g(context, 2131893217, new Object[0], null, 4);
}
}
public StreamResolution() {
}
public StreamResolution(DefaultConstructorMarker defaultConstructorMarker) {
}
public abstract CharSequence a(Context context);
public final boolean b() {
return (this instanceof b) || ((this instanceof a) && ((a) this).a == 1080);
}
}
/* compiled from: VideoCallParticipantView.kt */
public static final class a implements View.OnClickListener {
public final /* synthetic */ VideoCallParticipantView i;
public final /* synthetic */ ParticipantData.a j;
public a(VideoCallParticipantView videoCallParticipantView, ParticipantData.a aVar) {
this.i = videoCallParticipantView;
this.j = aVar;
}
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
Function2<? super StreamResolution, ? super StreamFps, Unit> function2 = this.i.w;
ParticipantData.a aVar = this.j;
function2.invoke(aVar.b, aVar.f2140c);
}
}
public VideoCallParticipantView(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0, 4);
}
/* JADX WARNING: Illegal instructions before constructor call */
public VideoCallParticipantView(Context context, AttributeSet attributeSet, int i, int i2) {
super(context, r13, r0);
boolean z2;
AppVideoStreamRenderer appVideoStreamRenderer;
AttributeSet attributeSet2 = (i2 & 2) != 0 ? null : attributeSet;
int i3 = (i2 & 4) != 0 ? 0 : i;
m.checkNotNullParameter(context, "context");
LayoutInflater.from(context).inflate(2131558836, this);
int i4 = 2131364239;
View findViewById = findViewById(2131364239);
if (findViewById != null) {
i4 = 2131364240;
View findViewById2 = findViewById(2131364240);
if (findViewById2 != null) {
i4 = 2131364241;
ImageView imageView = (ImageView) findViewById(2131364241);
if (imageView != null) {
i4 = 2131364242;
ConstraintLayout constraintLayout = (ConstraintLayout) findViewById(2131364242);
if (constraintLayout != null) {
i4 = 2131364243;
Space space = (Space) findViewById(2131364243);
if (space != null) {
i4 = 2131364244;
ImageView imageView2 = (ImageView) findViewById(2131364244);
if (imageView2 != null) {
i4 = 2131364245;
TextView textView = (TextView) findViewById(2131364245);
if (textView != null) {
i4 = 2131364246;
LinearLayout linearLayout = (LinearLayout) findViewById(2131364246);
if (linearLayout != null) {
i4 = 2131364247;
TextView textView2 = (TextView) findViewById(2131364247);
if (textView2 != null) {
i4 = 2131364248;
TextView textView3 = (TextView) findViewById(2131364248);
if (textView3 != null) {
i4 = 2131364249;
ImageView imageView3 = (ImageView) findViewById(2131364249);
if (imageView3 != null) {
i4 = 2131364250;
ConstraintLayout constraintLayout2 = (ConstraintLayout) findViewById(2131364250);
if (constraintLayout2 != null) {
i4 = 2131364251;
ImageView imageView4 = (ImageView) findViewById(2131364251);
if (imageView4 != null) {
i4 = 2131364252;
TextView textView4 = (TextView) findViewById(2131364252);
if (textView4 != null) {
i4 = 2131364253;
TextView textView5 = (TextView) findViewById(2131364253);
if (textView5 != null) {
i4 = 2131364254;
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(2131364254);
if (simpleDraweeView != null) {
i4 = 2131364255;
TextView textView6 = (TextView) findViewById(2131364255);
if (textView6 != null) {
i4 = 2131364256;
TextView textView7 = (TextView) findViewById(2131364256);
if (textView7 != null) {
i4 = 2131364257;
ProgressBar progressBar = (ProgressBar) findViewById(2131364257);
if (progressBar != null) {
i4 = 2131364258;
AppVideoStreamRenderer appVideoStreamRenderer2 = (AppVideoStreamRenderer) findViewById(2131364258);
if (appVideoStreamRenderer2 != null) {
i4 = 2131364259;
LinearLayout linearLayout2 = (LinearLayout) findViewById(2131364259);
if (linearLayout2 != null) {
i4 = 2131364260;
VoiceUserView voiceUserView = (VoiceUserView) findViewById(2131364260);
if (voiceUserView != null) {
x3 x3Var = new x3(this, findViewById, findViewById2, imageView, constraintLayout, space, imageView2, textView, linearLayout, textView2, textView3, imageView3, constraintLayout2, imageView4, textView4, textView5, simpleDraweeView, textView6, textView7, progressBar, appVideoStreamRenderer2, linearLayout2, voiceUserView);
m.checkNotNullExpressionValue(x3Var, "ViewVideoCallParticipant…ater.from(context), this)");
this.i = x3Var;
this.m = j.i;
this.f2137s = new VideoCallGridAdapter.CallUiInsets(0, 0, 0, 0);
this.u = ContextCompat.getDrawable(context, 2131230947);
this.v = ContextCompat.getDrawable(context, 2131230948);
this.w = t.i;
this.f2138x = t.j;
if (attributeSet2 != null) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet2, R.a.VideoCallParticipantView, 0, 0);
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr… 0\n )");
z2 = obtainStyledAttributes.getBoolean(0, false);
this.j = obtainStyledAttributes.getBoolean(1, false);
obtainStyledAttributes.recycle();
appVideoStreamRenderer = appVideoStreamRenderer2;
} else {
this.j = false;
appVideoStreamRenderer = appVideoStreamRenderer2;
z2 = false;
}
appVideoStreamRenderer.setIsOverlay(z2);
appVideoStreamRenderer.setMatchVideoOrientation(this.j);
return;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i4)));
}
public static /* synthetic */ void d(VideoCallParticipantView videoCallParticipantView, ParticipantData participantData, DisplayCutoutCompat displayCutoutCompat, boolean z2, VideoCallGridAdapter.CallUiInsets callUiInsets, boolean z3, int i) {
VideoCallGridAdapter.CallUiInsets callUiInsets2 = null;
DisplayCutoutCompat displayCutoutCompat2 = (i & 2) != 0 ? videoCallParticipantView.q : null;
if ((i & 4) != 0) {
z2 = videoCallParticipantView.r;
}
if ((i & 8) != 0) {
callUiInsets2 = videoCallParticipantView.f2137s;
}
if ((i & 16) != 0) {
z3 = videoCallParticipantView.t;
}
videoCallParticipantView.c(participantData, displayCutoutCompat2, z2, callUiInsets2, z3);
}
/* JADX DEBUG: TODO: convert one arg to string using `String.valueOf()`, args: [(r10v8 java.lang.CharSequence), (' ' char), (r2v13 java.lang.CharSequence)] */
public final void a(ParticipantData participantData) {
CharSequence charSequence;
ParticipantData.a aVar = participantData.j;
int i = 0;
if (!participantData.i || !this.t || aVar == null) {
b(false);
return;
}
ConstraintLayout constraintLayout = this.i.e;
constraintLayout.setTranslationX(-((float) this.f2137s.getRight()));
constraintLayout.setTranslationY((float) this.f2137s.getTop());
constraintLayout.setOnClickListener(new a(this, aVar));
ImageView imageView = this.i.f;
m.checkNotNullExpressionValue(imageView, "binding.participantFullscreenStreamqualIcon");
imageView.setVisibility(aVar.a ? 0 : 8);
StreamResolution streamResolution = aVar.b;
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
CharSequence a2 = streamResolution.a(context);
StreamFps streamFps = aVar.f2140c;
if (streamFps != null) {
Context context2 = getContext();
m.checkNotNullExpressionValue(context2, "context");
m.checkNotNullParameter(context2, "context");
charSequence = b.g(context2, 2131893206, new Object[]{Integer.valueOf(streamFps.a)}, null, 4);
} else {
charSequence = "";
}
StringBuilder sb = new StringBuilder();
sb.append(a2);
sb.append(' ');
sb.append(charSequence);
String sb2 = sb.toString();
Objects.requireNonNull(sb2, "null cannot be cast to non-null type kotlin.CharSequence");
String obj = w.trim(sb2).toString();
Drawable drawable = (!(obj.length() == 0) || aVar.a) ? this.v : this.u;
TextView textView = this.i.h;
m.checkNotNullExpressionValue(textView, "binding.participantFulls…enStreamqualLiveIndicator");
textView.setBackground(drawable);
int i2 = aVar.d ? 2131100121 : 2131100428;
TextView textView2 = this.i.g;
textView2.setText(obj);
CharSequence text = textView2.getText();
m.checkNotNullExpressionValue(text, "text");
if (!(text.length() > 0)) {
i = 8;
}
textView2.setVisibility(i);
textView2.setTextColor(ContextCompat.getColor(textView2.getContext(), i2));
textView2.requestLayout();
this.f2138x.invoke(aVar.b, aVar.f2140c);
b(true);
}
public final void b(boolean z2) {
ViewExtensions.fadeBy(this.i.e, z2, 200);
}
/* JADX WARNING: Removed duplicated region for block: B:139:0x0499 */
/* JADX WARNING: Removed duplicated region for block: B:140:0x049c */
/* JADX WARNING: Removed duplicated region for block: B:142:0x049f */
/* JADX WARNING: Removed duplicated region for block: B:143:0x04a2 */
/* JADX WARNING: Removed duplicated region for block: B:145:0x04a5 */
/* JADX WARNING: Removed duplicated region for block: B:146:0x04aa */
/* JADX WARNING: Removed duplicated region for block: B:149:0x04b4 */
/* JADX WARNING: Removed duplicated region for block: B:151:0x04b9 */
/* JADX WARNING: Removed duplicated region for block: B:154:0x04fb */
/* JADX WARNING: Removed duplicated region for block: B:155:0x04fe */
/* JADX WARNING: Removed duplicated region for block: B:173:0x0598 */
/* JADX WARNING: Removed duplicated region for block: B:190:? A[RETURN, SYNTHETIC] */
@MainThread
public final void c(ParticipantData participantData, DisplayCutoutCompat displayCutoutCompat, boolean z2, VideoCallGridAdapter.CallUiInsets callUiInsets, boolean z3) {
ParticipantData.Type type;
boolean z4;
Integer num;
boolean z5;
Subscription subscription;
ParticipantData.Type type2;
boolean z6;
m.checkNotNullParameter(callUiInsets, "callUiInsets");
this.q = displayCutoutCompat;
this.r = z2;
this.f2137s = callUiInsets;
this.t = z3;
StoreVoiceParticipants.VoiceUser voiceUser = participantData != null ? participantData.b : null;
if (voiceUser != null) {
this.i.f183s.setOnBitmapLoadedListener(new k(voiceUser));
this.i.f183s.a(voiceUser, 2131165288);
Subscription subscription2 = this.n;
if (subscription2 != null) {
subscription2.unsubscribe();
}
Observable<Integer> b02 = RepresentativeColorsKt.getUserRepresentativeColors().observeRepresentativeColor(Long.valueOf(voiceUser.getUser().getId())).b0(l.i);
m.checkNotNullExpressionValue(b02, "UserRepresentativeColors….takeUntil { it != null }");
ObservableExtensionsKt.appSubscribe$default(b02, VideoCallParticipantView.class, (Context) null, new o(0, this), (Function1) null, (Function0) null, (Function0) null, new c.a.y.i0.m(this), 58, (Object) null);
}
String forUser$default = IconUtils.getForUser$default(voiceUser != null ? voiceUser.getUser() : null, false, null, 6, null);
if (!m.areEqual(forUser$default, this.l)) {
this.l = forUser$default;
}
ParticipantData participantData2 = this.k;
if (participantData2 == null || (type = participantData2.g) == null) {
type = ParticipantData.Type.DEFAULT;
}
boolean z7 = participantData2 != null && participantData2.i;
Integer b = participantData2 != null ? participantData2.b() : null;
this.k = participantData;
Integer b2 = participantData != null ? participantData.b() : null;
Integer b3 = participantData != null ? participantData.b() : null;
if (!m.areEqual(b3, b)) {
if (b3 != null) {
AppVideoStreamRenderer appVideoStreamRenderer = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer, "binding.participantVideoStreamRenderer");
appVideoStreamRenderer.setVisibility(8);
View view = this.i.f182c;
m.checkNotNullExpressionValue(view, "binding.participantBgLetterbox");
SimpleDraweeView simpleDraweeView = this.i.m;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.participantStreamPreviewImage");
view.setVisibility((simpleDraweeView.getVisibility() == 0) ^ true ? 0 : 8);
ProgressBar progressBar = this.i.p;
m.checkNotNullExpressionValue(progressBar, "binding.participantVideoLoadingIndicator");
progressBar.setVisibility(0);
} else {
AppVideoStreamRenderer appVideoStreamRenderer2 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer2, "binding.participantVideoStreamRenderer");
appVideoStreamRenderer2.setVisibility(8);
View view2 = this.i.f182c;
m.checkNotNullExpressionValue(view2, "binding.participantBgLetterbox");
view2.setVisibility(8);
ProgressBar progressBar2 = this.i.p;
m.checkNotNullExpressionValue(progressBar2, "binding.participantVideoLoadingIndicator");
progressBar2.setVisibility(8);
}
}
if ((participantData != null ? participantData.g : null) == ParticipantData.Type.APPLICATION_STREAMING) {
View view3 = this.i.b;
m.checkNotNullExpressionValue(view3, "binding.participantBgAvatar");
view3.setVisibility(8);
VoiceUserView voiceUserView = this.i.f183s;
m.checkNotNullExpressionValue(voiceUserView, "binding.participantVoiceUserView");
voiceUserView.setVisibility(8);
ImageView imageView = this.i.j;
m.checkNotNullExpressionValue(imageView, "binding.participantMuteStatusIndicator");
imageView.setVisibility(8);
ImageView imageView2 = this.i.d;
m.checkNotNullExpressionValue(imageView2, "binding.participantDeafenStatusIndicator");
imageView2.setVisibility(8);
ParticipantData.ApplicationStreamState applicationStreamState = participantData.f;
if (applicationStreamState != null) {
int ordinal = applicationStreamState.ordinal();
if (ordinal == 0) {
ProgressBar progressBar3 = this.i.p;
m.checkNotNullExpressionValue(progressBar3, "binding.participantVideoLoadingIndicator");
progressBar3.setVisibility(0);
TextView textView = this.i.l;
m.checkNotNullExpressionValue(textView, "binding.participantStreamPaused");
textView.setVisibility(8);
ConstraintLayout constraintLayout = this.i.k;
m.checkNotNullExpressionValue(constraintLayout, "binding.participantStreamEnded");
constraintLayout.setVisibility(8);
SimpleDraweeView simpleDraweeView2 = this.i.m;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.participantStreamPreviewImage");
simpleDraweeView2.setVisibility(0);
TextView textView2 = this.i.n;
m.checkNotNullExpressionValue(textView2, "binding.participantStreamPreviewText");
textView2.setVisibility(8);
TextView textView3 = this.i.i;
m.checkNotNullExpressionValue(textView3, "binding.participantLiveIndicator");
textView3.setVisibility(participantData.i ^ true ? 0 : 8);
b(false);
} else if (ordinal == 1) {
TextView textView4 = this.i.n;
m.checkNotNullExpressionValue(textView4, "binding.participantStreamPreviewText");
textView4.setVisibility(8);
TextView textView5 = this.i.l;
m.checkNotNullExpressionValue(textView5, "binding.participantStreamPaused");
textView5.setVisibility(8);
ConstraintLayout constraintLayout2 = this.i.k;
m.checkNotNullExpressionValue(constraintLayout2, "binding.participantStreamEnded");
constraintLayout2.setVisibility(8);
TextView textView6 = this.i.i;
m.checkNotNullExpressionValue(textView6, "binding.participantLiveIndicator");
textView6.setVisibility(participantData.i ^ true ? 0 : 8);
a(participantData);
} else if (ordinal == 2) {
ProgressBar progressBar4 = this.i.p;
m.checkNotNullExpressionValue(progressBar4, "binding.participantVideoLoadingIndicator");
progressBar4.setVisibility(8);
SimpleDraweeView simpleDraweeView3 = this.i.m;
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.participantStreamPreviewImage");
simpleDraweeView3.setVisibility(0);
TextView textView7 = this.i.n;
m.checkNotNullExpressionValue(textView7, "binding.participantStreamPreviewText");
textView7.setVisibility(0);
TextView textView8 = this.i.l;
m.checkNotNullExpressionValue(textView8, "binding.participantStreamPaused");
textView8.setVisibility(8);
ConstraintLayout constraintLayout3 = this.i.k;
m.checkNotNullExpressionValue(constraintLayout3, "binding.participantStreamEnded");
constraintLayout3.setVisibility(8);
TextView textView9 = this.i.i;
m.checkNotNullExpressionValue(textView9, "binding.participantLiveIndicator");
textView9.setVisibility(8);
this.i.n.setOnClickListener(new n(this, participantData));
StreamContext streamContext = participantData.b.getStreamContext();
StoreApplicationStreamPreviews.StreamPreview preview = streamContext != null ? streamContext.getPreview() : null;
if (preview instanceof StoreApplicationStreamPreviews.StreamPreview.Resolved) {
this.i.m.setImageURI(((StoreApplicationStreamPreviews.StreamPreview.Resolved) preview).getUrl());
} else {
this.i.m.setImageURI((String) null);
}
b(false);
} else if (ordinal == 3) {
ProgressBar progressBar5 = this.i.p;
m.checkNotNullExpressionValue(progressBar5, "binding.participantVideoLoadingIndicator");
progressBar5.setVisibility(8);
SimpleDraweeView simpleDraweeView4 = this.i.m;
m.checkNotNullExpressionValue(simpleDraweeView4, "binding.participantStreamPreviewImage");
simpleDraweeView4.setVisibility(0);
TextView textView10 = this.i.n;
m.checkNotNullExpressionValue(textView10, "binding.participantStreamPreviewText");
textView10.setVisibility(8);
TextView textView11 = this.i.l;
m.checkNotNullExpressionValue(textView11, "binding.participantStreamPaused");
textView11.setVisibility(0);
ConstraintLayout constraintLayout4 = this.i.k;
m.checkNotNullExpressionValue(constraintLayout4, "binding.participantStreamEnded");
constraintLayout4.setVisibility(8);
TextView textView12 = this.i.i;
m.checkNotNullExpressionValue(textView12, "binding.participantLiveIndicator");
textView12.setVisibility(participantData.i ^ true ? 0 : 8);
a(participantData);
} else if (ordinal == 4) {
ProgressBar progressBar6 = this.i.p;
m.checkNotNullExpressionValue(progressBar6, "binding.participantVideoLoadingIndicator");
progressBar6.setVisibility(8);
TextView textView13 = this.i.n;
m.checkNotNullExpressionValue(textView13, "binding.participantStreamPreviewText");
textView13.setVisibility(8);
TextView textView14 = this.i.l;
m.checkNotNullExpressionValue(textView14, "binding.participantStreamPaused");
textView14.setVisibility(8);
ConstraintLayout constraintLayout5 = this.i.k;
m.checkNotNullExpressionValue(constraintLayout5, "binding.participantStreamEnded");
constraintLayout5.setVisibility(0);
TextView textView15 = this.i.i;
m.checkNotNullExpressionValue(textView15, "binding.participantLiveIndicator");
textView15.setVisibility(8);
b(false);
}
}
} else {
SimpleDraweeView simpleDraweeView5 = this.i.m;
m.checkNotNullExpressionValue(simpleDraweeView5, "binding.participantStreamPreviewImage");
simpleDraweeView5.setVisibility(8);
TextView textView16 = this.i.n;
m.checkNotNullExpressionValue(textView16, "binding.participantStreamPreviewText");
textView16.setVisibility(8);
TextView textView17 = this.i.l;
m.checkNotNullExpressionValue(textView17, "binding.participantStreamPaused");
textView17.setVisibility(8);
ConstraintLayout constraintLayout6 = this.i.k;
m.checkNotNullExpressionValue(constraintLayout6, "binding.participantStreamEnded");
constraintLayout6.setVisibility(8);
b(false);
ImageView imageView3 = this.i.j;
m.checkNotNullExpressionValue(imageView3, "binding.participantMuteStatusIndicator");
imageView3.setVisibility(voiceUser != null ? voiceUser.isMuted() : false ? 0 : 8);
ImageView imageView4 = this.i.d;
m.checkNotNullExpressionValue(imageView4, "binding.participantDeafenStatusIndicator");
imageView4.setVisibility(voiceUser != null ? voiceUser.isDeafened() : false ? 0 : 8);
if (b2 != null) {
View view4 = this.i.b;
m.checkNotNullExpressionValue(view4, "binding.participantBgAvatar");
view4.setVisibility(8);
VoiceUserView voiceUserView2 = this.i.f183s;
m.checkNotNullExpressionValue(voiceUserView2, "binding.participantVoiceUserView");
voiceUserView2.setVisibility(8);
} else {
View view5 = this.i.b;
m.checkNotNullExpressionValue(view5, "binding.participantBgAvatar");
view5.setVisibility(0);
VoiceUserView voiceUserView3 = this.i.f183s;
m.checkNotNullExpressionValue(voiceUserView3, "binding.participantVoiceUserView");
voiceUserView3.setVisibility(0);
}
TextView textView18 = this.i.i;
m.checkNotNullExpressionValue(textView18, "binding.participantLiveIndicator");
textView18.setVisibility(8);
}
LinearLayout linearLayout = this.i.r;
m.checkNotNullExpressionValue(linearLayout, "binding.participantVoiceIndicators");
LinearLayout linearLayout2 = this.i.r;
m.checkNotNullExpressionValue(linearLayout2, "binding.participantVoiceIndicators");
Iterator<View> it = ViewGroupKt.getChildren(linearLayout2).iterator();
while (true) {
if (!it.hasNext()) {
z4 = false;
break;
}
if (it.next().getVisibility() == 0) {
z6 = true;
continue;
} else {
z6 = false;
continue;
}
if (z6) {
z4 = true;
break;
}
}
linearLayout.setVisibility(z4 ? 0 : 8);
ConstraintSet constraintSet = new ConstraintSet();
constraintSet.clone(this);
DisplayCutoutCompat displayCutoutCompat2 = this.q;
if ((displayCutoutCompat2 != null ? displayCutoutCompat2.getSafeInsetTop() : 0) > 0 && this.r) {
LinearLayout linearLayout3 = this.i.r;
m.checkNotNullExpressionValue(linearLayout3, "binding.participantVoiceIndicators");
if (!(linearLayout3.getVisibility() == 0)) {
TextView textView19 = this.i.i;
m.checkNotNullExpressionValue(textView19, "binding.participantLiveIndicator");
constraintSet.connect(textView19.getId(), 2, 0, 2, DimenUtils.dpToPixels(8));
TextView textView20 = this.i.i;
m.checkNotNullExpressionValue(textView20, "binding.participantLiveIndicator");
constraintSet.connect(textView20.getId(), 4, 0, 4, DimenUtils.dpToPixels(8));
TextView textView21 = this.i.i;
m.checkNotNullExpressionValue(textView21, "binding.participantLiveIndicator");
constraintSet.clear(textView21.getId(), 3);
AppVideoStreamRenderer appVideoStreamRenderer3 = this.i.q;
RendererCommon.ScalingType scalingType = participantData == null ? participantData.d : null;
RendererCommon.ScalingType scalingType2 = participantData == null ? participantData.e : null;
if (participantData == null) {
z5 = participantData.f2139c;
num = b2;
} else {
num = b2;
z5 = false;
}
appVideoStreamRenderer3.c(num, scalingType, scalingType2, z5);
subscription = this.p;
if (subscription != null) {
subscription.unsubscribe();
}
if (num != null) {
BehaviorSubject<Point> behaviorSubject = this.i.q.m;
m.checkNotNullExpressionValue(behaviorSubject, "currentFrameResolutionSubject");
Observable<R> F = behaviorSubject.x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
ObservableExtensionsKt.appSubscribe$default(F, VideoCallParticipantView.class, (Context) null, new o(1, this), (Function1) null, (Function0) null, (Function0) null, new o(this), 58, (Object) null);
}
ParticipantData participantData3 = this.k;
type2 = participantData3 == null ? participantData3.g : null;
boolean z8 = participantData == null && participantData.i;
if (!(type2 == null || (type2 == type && z8 == z7))) {
if (type2 == ParticipantData.Type.DEFAULT || z8) {
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(-2, -2);
AppVideoStreamRenderer appVideoStreamRenderer4 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer4, "binding.participantVideoStreamRenderer");
appVideoStreamRenderer4.setLayoutParams(layoutParams);
AppVideoStreamRenderer appVideoStreamRenderer5 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer5, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultHeight(appVideoStreamRenderer5.getId(), 1);
AppVideoStreamRenderer appVideoStreamRenderer6 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer6, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultWidth(appVideoStreamRenderer6.getId(), 1);
} else {
ConstraintLayout.LayoutParams layoutParams2 = new ConstraintLayout.LayoutParams(0, 0);
AppVideoStreamRenderer appVideoStreamRenderer7 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer7, "binding.participantVideoStreamRenderer");
appVideoStreamRenderer7.setLayoutParams(layoutParams2);
AppVideoStreamRenderer appVideoStreamRenderer8 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer8, "binding.participantVideoStreamRenderer");
constraintSet.constrainHeight(appVideoStreamRenderer8.getId(), 0);
AppVideoStreamRenderer appVideoStreamRenderer9 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer9, "binding.participantVideoStreamRenderer");
constraintSet.constrainWidth(appVideoStreamRenderer9.getId(), 0);
AppVideoStreamRenderer appVideoStreamRenderer10 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer10, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultHeight(appVideoStreamRenderer10.getId(), 0);
AppVideoStreamRenderer appVideoStreamRenderer11 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer11, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultWidth(appVideoStreamRenderer11.getId(), 0);
}
}
constraintSet.applyTo(this);
if (voiceUser == null) {
TextView textView22 = this.i.o;
m.checkNotNullExpressionValue(textView22, "binding.participantVideoLabel");
textView22.setText(voiceUser.getDisplayName());
if (participantData.g == ParticipantData.Type.APPLICATION_STREAMING) {
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
setContentDescription(b.g(context, 2131889136, new Object[]{voiceUser.getDisplayName()}, null, 4));
this.i.o.setCompoundDrawablesWithIntrinsicBounds(2131231927, 0, 0, 0);
} else {
setContentDescription(voiceUser.getDisplayName());
this.i.o.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
if (this.o) {
ViewExtensions.fadeBy(this.i.o, participantData.h, 200);
return;
}
TextView textView23 = this.i.o;
m.checkNotNullExpressionValue(textView23, "binding.participantVideoLabel");
textView23.setVisibility(participantData.h ? 0 : 8);
this.o = true;
return;
}
return;
}
}
TextView textView24 = this.i.i;
m.checkNotNullExpressionValue(textView24, "binding.participantLiveIndicator");
constraintSet.connect(textView24.getId(), 2, 0, 2, DimenUtils.dpToPixels(8));
TextView textView25 = this.i.i;
m.checkNotNullExpressionValue(textView25, "binding.participantLiveIndicator");
constraintSet.connect(textView25.getId(), 3, 0, 3, DimenUtils.dpToPixels(8));
TextView textView26 = this.i.i;
m.checkNotNullExpressionValue(textView26, "binding.participantLiveIndicator");
constraintSet.clear(textView26.getId(), 4);
AppVideoStreamRenderer appVideoStreamRenderer3 = this.i.q;
if (participantData == null) {
}
if (participantData == null) {
}
if (participantData == null) {
}
appVideoStreamRenderer3.c(num, scalingType, scalingType2, z5);
subscription = this.p;
if (subscription != null) {
}
if (num != null) {
}
ParticipantData participantData3 = this.k;
if (participantData3 == null) {
}
if (participantData == null) {
}
if (type2 == ParticipantData.Type.DEFAULT) {
}
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(-2, -2);
AppVideoStreamRenderer appVideoStreamRenderer4 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer4, "binding.participantVideoStreamRenderer");
appVideoStreamRenderer4.setLayoutParams(layoutParams);
AppVideoStreamRenderer appVideoStreamRenderer5 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer5, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultHeight(appVideoStreamRenderer5.getId(), 1);
AppVideoStreamRenderer appVideoStreamRenderer6 = this.i.q;
m.checkNotNullExpressionValue(appVideoStreamRenderer6, "binding.participantVideoStreamRenderer");
constraintSet.constrainDefaultWidth(appVideoStreamRenderer6.getId(), 1);
constraintSet.applyTo(this);
if (voiceUser == null) {
}
}
public final ParticipantData getData() {
return this.k;
}
@Override // com.discord.utilities.view.grid.FrameGridLayout.DataView
public String getDataId() {
ParticipantData participantData = this.k;
if (participantData != null) {
return participantData.a;
}
return null;
}
@Override // com.discord.utilities.view.grid.FrameGridLayout.DataView
public void onBind(FrameGridLayout.Data data) {
m.checkNotNullParameter(data, "data");
d(this, (ParticipantData) data, null, false, null, false, 30);
}
@Override // android.view.ViewGroup, android.view.View
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
Subscription subscription = this.n;
if (subscription != null) {
subscription.unsubscribe();
}
this.o = false;
this.i.q.c(null, null, null, false);
}
@Override // com.discord.utilities.view.grid.FrameGridLayout.DataView
public void onRemove() {
FrameGridLayout.DataView.DefaultImpls.onRemove(this);
}
public final void setData(ParticipantData participantData) {
this.k = participantData;
}
public final void setOnWatchStreamClicked(Function1<? super String, Unit> function1) {
m.checkNotNullParameter(function1, "onWatchStreamClicked");
this.m = function1;
}
}