105 lines
4.6 KiB
Java
105 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.o3;
|
|
import c.a.l.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 o3 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(2131558820, (ViewGroup) this, false);
|
|
addView(inflate);
|
|
int i = 2131365179;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(2131365179);
|
|
if (simpleDraweeView != null) {
|
|
i = 2131365180;
|
|
TextView textView = (TextView) inflate.findViewById(2131365180);
|
|
if (textView != null) {
|
|
i = 2131365181;
|
|
TextView textView2 = (TextView) inflate.findViewById(2131365181);
|
|
if (textView2 != null) {
|
|
o3 o3Var = new o3((ConstraintLayout) inflate, simpleDraweeView, textView, textView2);
|
|
m.checkNotNullExpressionValue(o3Var, "ViewStreamPreviewBinding…rom(context), this, true)");
|
|
this.i = o3Var;
|
|
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.f137c;
|
|
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(2131893720));
|
|
} 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(2131893708));
|
|
} else {
|
|
setCaptionText(null);
|
|
}
|
|
}
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
if (z2) {
|
|
setOverlayCaptionText(b.i(this, 2131894672, new Object[0], null, 4));
|
|
return;
|
|
}
|
|
int ordinal = joinability.ordinal();
|
|
if (ordinal == 0) {
|
|
setOverlayCaptionText(b.i(this, 2131890731, new Object[0], null, 4));
|
|
} else if (ordinal == 1) {
|
|
setOverlayCaptionText(b.i(this, 2131894139, new Object[0], null, 4));
|
|
} else if (ordinal == 2) {
|
|
setOverlayCaptionText(b.i(this, 2131887274, new Object[0], null, 4));
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
}
|
|
}
|