package c.a.y; import android.content.Context; import android.content.res.Configuration; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import c.a.i.r0; import com.discord.app.AppComponent; import com.discord.overlay.views.OverlayBubbleWrap; import com.discord.stores.StoreStream; import com.discord.stores.StoreVoiceParticipants; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.rx.ObservableExtensionsKt; import com.facebook.drawee.view.SimpleDraweeView; import d0.z.d.m; import d0.z.d.o; import j0.l.e.j; import java.util.Objects; import kotlin.Unit; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import rx.Observable; import rx.subjects.PublishSubject; import rx.subjects.Subject; /* compiled from: OverlayVoiceBubble.kt */ public final class v extends OverlayBubbleWrap implements AppComponent { public static final /* synthetic */ int w = 0; /* renamed from: x reason: collision with root package name */ public final r0 f240x; /* renamed from: y reason: collision with root package name */ public final Subject f241y; /* compiled from: OverlayVoiceBubble.kt */ public static final class a implements j0.k.b> { public static final a i = new a(); /* 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 // j0.k.b public Observable call(Long l) { Long l2 = l; if (l2 != null && l2.longValue() == 0) { return new j(null); } StoreVoiceParticipants voiceParticipants = StoreStream.Companion.getVoiceParticipants(); m.checkNotNullExpressionValue(l2, "channelId"); return voiceParticipants.get(l2.longValue()).F(u.i).r(); } } /* compiled from: OverlayVoiceBubble.kt */ public static final class b extends o implements Function1 { public final /* synthetic */ v this$0; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public b(v vVar) { super(1); this.this$0 = vVar; } /* 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(StoreVoiceParticipants.VoiceUser voiceUser) { StoreVoiceParticipants.VoiceUser voiceUser2 = voiceUser; v vVar = this.this$0; int i = v.w; if (voiceUser2 == null) { vVar.h(); } else { IconUtils.setIcon$default(vVar.getImageView$app_productionBetaRelease(), voiceUser2.getUser(), 0, null, null, null, 60, null); vVar.g(); } return Unit.a; } } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public v(Context context) { super(context); m.checkNotNullParameter(context, "context"); View inflate = LayoutInflater.from(getContext()).inflate(2131558616, (ViewGroup) this, false); addView(inflate); Objects.requireNonNull(inflate, "rootView"); SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate; r0 r0Var = new r0(simpleDraweeView, simpleDraweeView); m.checkNotNullExpressionValue(r0Var, "OverlayVoiceBubbleBindin…rom(context), this, true)"); this.f240x = r0Var; PublishSubject k0 = PublishSubject.k0(); m.checkNotNullExpressionValue(k0, "PublishSubject.create()"); this.f241y = k0; } @Override // com.discord.overlay.views.OverlayBubbleWrap public void a(boolean z2) { h(); super.a(z2); } @Override // com.discord.overlay.views.OverlayBubbleWrap public void b(View view) { m.checkNotNullParameter(view, "targetView"); super.b(view); g(); } public final void g() { getImageView$app_productionBetaRelease().animate().setDuration(100).alpha(1.0f).start(); } public final SimpleDraweeView getImageView$app_productionBetaRelease() { SimpleDraweeView simpleDraweeView = this.f240x.b; m.checkNotNullExpressionValue(simpleDraweeView, "binding.overlayBubbleIv"); return simpleDraweeView; } @Override // com.discord.app.AppComponent public Subject getUnsubscribeSignal() { return this.f241y; } public final void h() { getImageView$app_productionBetaRelease().animate().setDuration(200).alpha(0.5f).start(); } @Override // android.view.View, android.view.ViewGroup public void onAttachedToWindow() { super.onAttachedToWindow(); Observable Y = StoreStream.Companion.getVoiceChannelSelected().observeSelectedVoiceChannelId().Y(a.i); m.checkNotNullExpressionValue(Y, "StoreStream\n .get…d()\n }\n }"); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(Y), this, null, 2, null), v.class, getContext(), (Function1) null, (Function1) null, (Function0) null, (Function0) null, new b(this), 60, (Object) null); } @Override // com.discord.overlay.views.OverlayBubbleWrap, android.view.View public void onConfigurationChanged(Configuration configuration) { int i = getWindowLayoutParams().x; Context context = getContext(); m.checkNotNullExpressionValue(context, "context"); int i2 = i > e(context).centerX() ? Integer.MAX_VALUE : Integer.MIN_VALUE; super.onConfigurationChanged(configuration); OverlayBubbleWrap.c(this, i2, getWindowLayoutParams().y, null, 4, null); getSpringAnimationX().skipToEnd(); getSpringAnimationY().skipToEnd(); } @Override // android.view.View, android.view.ViewGroup public void onDetachedFromWindow() { getUnsubscribeSignal().onNext(null); super.onDetachedFromWindow(); } }