256 lines
10 KiB
Java
256 lines
10 KiB
Java
package com.discord.views;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Bitmap;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.DimenRes;
|
|
import androidx.annotation.MainThread;
|
|
import androidx.annotation.Px;
|
|
import c.a.i.y3;
|
|
import c.a.y.f0;
|
|
import c.a.y.g0;
|
|
import c.a.y.h0;
|
|
import com.discord.R;
|
|
import com.discord.api.voice.state.VoiceState;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.StoreVoiceParticipants;
|
|
import com.discord.utilities.anim.RingAnimator;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: VoiceUserView.kt */
|
|
public final class VoiceUserView extends FrameLayout {
|
|
public static final /* synthetic */ int i = 0;
|
|
public int j;
|
|
public final y3 k;
|
|
public a l;
|
|
public final RingAnimator m;
|
|
public StoreVoiceParticipants.VoiceUser n;
|
|
public Function1<? super Bitmap, Unit> o;
|
|
public String p;
|
|
public boolean q;
|
|
public boolean r;
|
|
|
|
/* compiled from: VoiceUserView.kt */
|
|
public enum a {
|
|
CONNECTED,
|
|
SPEAKING,
|
|
MUTED,
|
|
RINGING,
|
|
DISCONNECTED
|
|
}
|
|
|
|
/* compiled from: VoiceUserView.kt */
|
|
public static final class b extends o implements Function1<View, Unit> {
|
|
public final /* synthetic */ int $avatarSize;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public b(int i) {
|
|
super(1);
|
|
this.$avatarSize = i;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(View view) {
|
|
invoke(view);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(View view) {
|
|
m.checkNotNullParameter(view, "$this$resizeLayoutParams");
|
|
if (view.getLayoutParams().width != this.$avatarSize || view.getLayoutParams().height != this.$avatarSize) {
|
|
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
|
|
int i = this.$avatarSize;
|
|
layoutParams.width = i;
|
|
layoutParams.height = i;
|
|
view.setLayoutParams(layoutParams);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: VoiceUserView.kt */
|
|
public static final class c extends o implements Function1<ImageRequestBuilder, Unit> {
|
|
public final /* synthetic */ VoiceUserView this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(VoiceUserView voiceUserView) {
|
|
super(1);
|
|
this.this$0 = voiceUserView;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(ImageRequestBuilder imageRequestBuilder) {
|
|
ImageRequestBuilder imageRequestBuilder2 = imageRequestBuilder;
|
|
m.checkNotNullParameter(imageRequestBuilder2, "imageRequestBuilder");
|
|
imageRequestBuilder2.j = new h0(this);
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
public VoiceUserView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0, 4);
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public VoiceUserView(Context context, AttributeSet attributeSet, int i2, int i3) {
|
|
super(context, attributeSet, i2);
|
|
attributeSet = (i3 & 2) != 0 ? null : attributeSet;
|
|
i2 = (i3 & 4) != 0 ? 0 : i2;
|
|
m.checkNotNullParameter(context, "context");
|
|
this.j = 17170445;
|
|
LayoutInflater.from(context).inflate(2131558837, this);
|
|
int i4 = 2131365705;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(2131365705);
|
|
if (simpleDraweeView != null) {
|
|
i4 = 2131365718;
|
|
TextView textView = (TextView) findViewById(2131365718);
|
|
if (textView != null) {
|
|
y3 y3Var = new y3(this, simpleDraweeView, textView);
|
|
m.checkNotNullExpressionValue(y3Var, "ViewVoiceUserBinding.inf…ater.from(context), this)");
|
|
this.k = y3Var;
|
|
this.m = new RingAnimator(this, new g0(this));
|
|
this.o = f0.i;
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.VoiceUserView, 0, 0);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…able.VoiceUserView, 0, 0)");
|
|
int dimension = (int) obtainStyledAttributes.getDimension(1, 0.0f);
|
|
boolean z2 = obtainStyledAttributes.getBoolean(2, false);
|
|
boolean z3 = obtainStyledAttributes.getBoolean(0, false);
|
|
obtainStyledAttributes.recycle();
|
|
if (dimension > 0) {
|
|
setAvatarSize(dimension);
|
|
}
|
|
setFadeWhenDisconnected(z2);
|
|
setAnimateAvatarWhenRinging(z3);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(getResources().getResourceName(i4)));
|
|
}
|
|
|
|
private final void setVoiceState(StoreVoiceParticipants.VoiceUser voiceUser) {
|
|
VoiceState voiceState = voiceUser.getVoiceState();
|
|
setVoiceState(voiceUser.isSpeaking() ? a.SPEAKING : voiceUser.isRinging() ? a.RINGING : !voiceUser.isConnected() ? a.DISCONNECTED : voiceState != null && (voiceState.h() || voiceState.e() || voiceState.l()) ? a.MUTED : a.CONNECTED);
|
|
}
|
|
|
|
private final void setVoiceState(a aVar) {
|
|
if (aVar != this.l) {
|
|
this.l = aVar;
|
|
setBackgroundResource(aVar.ordinal() != 1 ? this.j : 2131231269);
|
|
float f = (aVar != a.DISCONNECTED || !this.q) ? 1.0f : 0.3f;
|
|
SimpleDraweeView simpleDraweeView = this.k.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.voiceUserAvatar");
|
|
simpleDraweeView.setAlpha(f);
|
|
setAlpha(f);
|
|
this.m.onUpdate();
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void a(StoreVoiceParticipants.VoiceUser voiceUser, @DimenRes int i2) {
|
|
m.checkNotNullParameter(voiceUser, "voiceUser");
|
|
if (!m.areEqual(this.n, voiceUser)) {
|
|
this.n = voiceUser;
|
|
int dimensionPixelSize = getResources().getDimensionPixelSize(i2);
|
|
User user = null;
|
|
Integer valueOf = dimensionPixelSize > 0 ? Integer.valueOf(IconUtils.getMediaProxySize(dimensionPixelSize)) : null;
|
|
GuildMember guildMember = voiceUser.getGuildMember();
|
|
IconUtils iconUtils = IconUtils.INSTANCE;
|
|
StoreVoiceParticipants.VoiceUser voiceUser2 = this.n;
|
|
if (voiceUser2 != null) {
|
|
user = voiceUser2.getUser();
|
|
}
|
|
String forGuildMemberOrUser = iconUtils.getForGuildMemberOrUser(user, guildMember, valueOf);
|
|
if (!m.areEqual(this.p, forGuildMemberOrUser)) {
|
|
this.p = forGuildMemberOrUser;
|
|
SimpleDraweeView simpleDraweeView = this.k.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.voiceUserAvatar");
|
|
IconUtils.setIcon$default(simpleDraweeView, forGuildMemberOrUser, i2, new c(this), (MGImages.ChangeDetector) null, 16, (Object) null);
|
|
}
|
|
TextView textView = this.k.f189c;
|
|
m.checkNotNullExpressionValue(textView, "binding.voiceUserNameDisplay");
|
|
textView.setText(voiceUser.getDisplayName());
|
|
setVoiceState(voiceUser);
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void setAnimateAvatarWhenRinging(boolean z2) {
|
|
this.r = z2;
|
|
}
|
|
|
|
@MainThread
|
|
public final void setAvatarSize(int i2) {
|
|
b bVar = new b(i2);
|
|
SimpleDraweeView simpleDraweeView = this.k.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.voiceUserAvatar");
|
|
bVar.invoke((View) simpleDraweeView);
|
|
TextView textView = this.k.f189c;
|
|
m.checkNotNullExpressionValue(textView, "binding.voiceUserNameDisplay");
|
|
bVar.invoke((View) textView);
|
|
requestLayout();
|
|
}
|
|
|
|
public final void setDefaultVoiceStateBackground(int i2) {
|
|
this.j = i2;
|
|
}
|
|
|
|
@MainThread
|
|
public final void setFadeWhenDisconnected(boolean z2) {
|
|
this.q = z2;
|
|
}
|
|
|
|
public final void setOnBitmapLoadedListener(Function1<? super Bitmap, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "onBitmapLoadedListener");
|
|
this.o = function1;
|
|
}
|
|
|
|
@MainThread
|
|
public final void setRingMargin(@Px int i2) {
|
|
SimpleDraweeView simpleDraweeView = this.k.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.voiceUserAvatar");
|
|
SimpleDraweeView simpleDraweeView2 = this.k.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.voiceUserAvatar");
|
|
ViewGroup.LayoutParams layoutParams = simpleDraweeView2.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
|
|
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
|
|
layoutParams2.setMargins(i2, i2, i2, i2);
|
|
simpleDraweeView.setLayoutParams(layoutParams2);
|
|
requestLayout();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void setSelected(boolean z2) {
|
|
boolean z3 = isSelected() != z2;
|
|
super.setSelected(z2);
|
|
if (z3) {
|
|
ViewExtensions.fadeBy$default(this.k.f189c, isSelected(), 0, 2, null);
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void setVoiceUser(StoreVoiceParticipants.VoiceUser voiceUser) {
|
|
a(voiceUser, 2131165297);
|
|
}
|
|
}
|