discord-jadx/app/src/main/java/com/discord/views/StreamPreviewView.java

106 lines
4.6 KiB
Java

package com.discord.views;
import android.content.Context;
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.MainThread;
import androidx.constraintlayout.widget.ConstraintLayout;
import c.a.i.p3;
import c.a.k.b;
import com.discord.stores.StoreApplicationStreamPreviews;
import com.discord.utilities.streams.StreamContext;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.facebook.drawee.view.SimpleDraweeView;
import d0.z.d.m;
import kotlin.NoWhenBranchMatchedException;
/* compiled from: StreamPreviewView.kt */
public final class StreamPreviewView extends FrameLayout {
public final p3 i;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public StreamPreviewView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
View inflate = LayoutInflater.from(getContext()).inflate(2131558827, (ViewGroup) this, false);
addView(inflate);
int i = 2131365245;
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(2131365245);
if (simpleDraweeView != null) {
i = 2131365246;
TextView textView = (TextView) inflate.findViewById(2131365246);
if (textView != null) {
i = 2131365247;
TextView textView2 = (TextView) inflate.findViewById(2131365247);
if (textView2 != null) {
p3 p3Var = new p3((ConstraintLayout) inflate, simpleDraweeView, textView, textView2);
m.checkNotNullExpressionValue(p3Var, "ViewStreamPreviewBinding…rom(context), this, true)");
this.i = p3Var;
setClickable(true);
setFocusable(false);
setFocusableInTouchMode(false);
return;
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
}
private final void setCaptionText(CharSequence charSequence) {
TextView textView = this.i.d;
m.checkNotNullExpressionValue(textView, "binding.streamPreviewPlaceholderCaption");
ViewExtensions.setTextAndVisibilityBy(textView, charSequence);
}
private final void setImage(String str) {
this.i.b.setImageURI(str);
}
private final void setOverlayCaptionText(CharSequence charSequence) {
TextView textView = this.i.f142c;
m.checkNotNullExpressionValue(textView, "binding.streamPreviewOverlayText");
ViewExtensions.setTextAndVisibilityBy(textView, charSequence);
}
@MainThread
public final void a(StoreApplicationStreamPreviews.StreamPreview streamPreview, StreamContext.Joinability joinability, boolean z2) {
m.checkNotNullParameter(streamPreview, "preview");
m.checkNotNullParameter(joinability, "joinability");
if (streamPreview instanceof StoreApplicationStreamPreviews.StreamPreview.Fetching) {
setCaptionText(getContext().getString(2131893841));
} else if (streamPreview instanceof StoreApplicationStreamPreviews.StreamPreview.Resolved) {
StoreApplicationStreamPreviews.StreamPreview.Resolved resolved = (StoreApplicationStreamPreviews.StreamPreview.Resolved) streamPreview;
if (resolved.getUrl() != null) {
setImage(resolved.getUrl());
setCaptionText(null);
} else {
setImage(null);
if (joinability == StreamContext.Joinability.CAN_CONNECT) {
setCaptionText(getContext().getString(2131893829));
} else {
setCaptionText(null);
}
}
} else {
throw new NoWhenBranchMatchedException();
}
if (z2) {
setOverlayCaptionText(b.i(this, 2131894805, new Object[0], null, 4));
return;
}
int ordinal = joinability.ordinal();
if (ordinal == 0) {
setOverlayCaptionText(b.i(this, 2131890813, new Object[0], null, 4));
} else if (ordinal == 1) {
setOverlayCaptionText(b.i(this, 2131894267, new Object[0], null, 4));
} else if (ordinal == 2) {
setOverlayCaptionText(b.i(this, 2131887276, new Object[0], null, 4));
} else {
throw new NoWhenBranchMatchedException();
}
}
}