161 lines
8.4 KiB
Java
161 lines
8.4 KiB
Java
package com.discord.widgets.botuikit.views.select;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.a.i.n4;
|
|
import c.a.i.o4;
|
|
import com.discord.api.botuikit.ComponentType;
|
|
import com.discord.api.botuikit.SelectItem;
|
|
import com.discord.models.botuikit.ActionInteractionComponentState;
|
|
import com.discord.models.botuikit.SelectMessageComponent;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.views.typing.TypingDots;
|
|
import com.discord.widgets.botuikit.ComponentProvider;
|
|
import com.discord.widgets.botuikit.views.ComponentActionListener;
|
|
import com.discord.widgets.botuikit.views.ComponentView;
|
|
import com.discord.widgets.botuikit.views.ComponentViewUtils;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.flexbox.FlexboxLayout;
|
|
import com.google.android.material.textview.MaterialTextView;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: SelectComponentView.kt */
|
|
public final class SelectComponentView extends ConstraintLayout implements ComponentView<SelectMessageComponent> {
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
/* compiled from: SelectComponentView.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final SelectComponentView inflateComponent(Context context, ViewGroup viewGroup) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(viewGroup, "root");
|
|
n4 a = n4.a(LayoutInflater.from(context).inflate(2131558976, viewGroup, false));
|
|
m.checkNotNullExpressionValue(a, "WidgetChatListBotUiSelec…om(context), root, false)");
|
|
SelectComponentView selectComponentView = a.a;
|
|
m.checkNotNullExpressionValue(selectComponentView, "WidgetChatListBotUiSelec…ntext), root, false).root");
|
|
return selectComponentView;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public SelectComponentView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(attributeSet, "attrs");
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public SelectComponentView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(attributeSet, "attrs");
|
|
}
|
|
|
|
public void configure(SelectMessageComponent selectMessageComponent, ComponentProvider componentProvider, ComponentActionListener componentActionListener) {
|
|
m.checkNotNullParameter(selectMessageComponent, "component");
|
|
m.checkNotNullParameter(componentProvider, "componentProvider");
|
|
m.checkNotNullParameter(componentActionListener, "componentActionListener");
|
|
n4 a = n4.a(this);
|
|
m.checkNotNullExpressionValue(a, "WidgetChatListBotUiSelec…mponentBinding.bind(this)");
|
|
String placeholder = selectMessageComponent.getPlaceholder();
|
|
if (placeholder == null) {
|
|
placeholder = getResources().getString(2131891315);
|
|
m.checkNotNullExpressionValue(placeholder, "resources.getString(R.st…nent_default_placeholder)");
|
|
}
|
|
int i = 0;
|
|
if (!(!selectMessageComponent.getSelectedOptions().isEmpty())) {
|
|
MaterialTextView materialTextView = a.e;
|
|
m.checkNotNullExpressionValue(materialTextView, "binding.selectComponentSelectionText");
|
|
materialTextView.setVisibility(0);
|
|
FlexboxLayout flexboxLayout = a.f;
|
|
m.checkNotNullExpressionValue(flexboxLayout, "binding.selectComponentSelectionsRoot");
|
|
flexboxLayout.setVisibility(8);
|
|
a.e.setTextColor(ColorCompat.getThemedColor(getContext(), 2130968949));
|
|
MaterialTextView materialTextView2 = a.e;
|
|
m.checkNotNullExpressionValue(materialTextView2, "binding.selectComponentSelectionText");
|
|
materialTextView2.setText(placeholder);
|
|
} else if (selectMessageComponent.getMaxValues() == 1) {
|
|
MaterialTextView materialTextView3 = a.e;
|
|
m.checkNotNullExpressionValue(materialTextView3, "binding.selectComponentSelectionText");
|
|
materialTextView3.setVisibility(0);
|
|
FlexboxLayout flexboxLayout2 = a.f;
|
|
m.checkNotNullExpressionValue(flexboxLayout2, "binding.selectComponentSelectionsRoot");
|
|
flexboxLayout2.setVisibility(8);
|
|
a.e.setTextColor(ColorCompat.getThemedColor(getContext(), 2130968989));
|
|
SelectItem selectItem = (SelectItem) u.firstOrNull((List<? extends Object>) selectMessageComponent.getSelectedOptions());
|
|
if (selectItem != null) {
|
|
MaterialTextView materialTextView4 = a.e;
|
|
m.checkNotNullExpressionValue(materialTextView4, "binding.selectComponentSelectionText");
|
|
materialTextView4.setText(selectItem.c());
|
|
ComponentViewUtils componentViewUtils = ComponentViewUtils.INSTANCE;
|
|
SimpleDraweeView simpleDraweeView = a.d;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.selectComponentSelectionIcon");
|
|
componentViewUtils.setEmojiOrHide(simpleDraweeView, selectItem.b());
|
|
}
|
|
} else {
|
|
FlexboxLayout flexboxLayout3 = a.f;
|
|
m.checkNotNullExpressionValue(flexboxLayout3, "binding.selectComponentSelectionsRoot");
|
|
MaterialTextView materialTextView5 = a.e;
|
|
m.checkNotNullExpressionValue(materialTextView5, "binding.selectComponentSelectionText");
|
|
materialTextView5.setVisibility(8);
|
|
flexboxLayout3.setVisibility(0);
|
|
flexboxLayout3.removeAllViews();
|
|
LayoutInflater from = LayoutInflater.from(getContext());
|
|
for (SelectItem selectItem2 : selectMessageComponent.getSelectedOptions()) {
|
|
View inflate = from.inflate(2131558977, (ViewGroup) null, false);
|
|
Objects.requireNonNull(inflate, "rootView");
|
|
MaterialTextView materialTextView6 = (MaterialTextView) inflate;
|
|
m.checkNotNullExpressionValue(new o4(materialTextView6), "WidgetChatListBotUiSelec…Binding.inflate(inflater)");
|
|
m.checkNotNullExpressionValue(materialTextView6, "WidgetChatListBotUiSelec…ng.inflate(inflater).root");
|
|
materialTextView6.setText(selectItem2.c());
|
|
flexboxLayout3.addView(materialTextView6);
|
|
}
|
|
}
|
|
boolean z2 = !(selectMessageComponent.getStateInteraction() instanceof ActionInteractionComponentState.Disabled);
|
|
boolean z3 = selectMessageComponent.getStateInteraction() instanceof ActionInteractionComponentState.Loading;
|
|
TypingDots typingDots = a.f133c;
|
|
if (z3) {
|
|
typingDots.a(false);
|
|
} else {
|
|
typingDots.b();
|
|
}
|
|
TypingDots typingDots2 = a.f133c;
|
|
m.checkNotNullExpressionValue(typingDots2, "binding.selectComponentLoading");
|
|
boolean z4 = !z3;
|
|
typingDots2.setVisibility(z4 ? 4 : 0);
|
|
ImageView imageView = a.b;
|
|
m.checkNotNullExpressionValue(imageView, "binding.selectComponentChevron");
|
|
if (z3) {
|
|
i = 4;
|
|
}
|
|
imageView.setVisibility(i);
|
|
SelectComponentView selectComponentView = a.a;
|
|
m.checkNotNullExpressionValue(selectComponentView, "binding.root");
|
|
ViewExtensions.setEnabledAlpha(selectComponentView, z2, 0.3f);
|
|
a.a.setOnClickListener(new SelectComponentView$configure$3(componentActionListener, selectMessageComponent, placeholder));
|
|
SelectComponentView selectComponentView2 = a.a;
|
|
m.checkNotNullExpressionValue(selectComponentView2, "binding.root");
|
|
selectComponentView2.setClickable(z4);
|
|
}
|
|
|
|
@Override // com.discord.widgets.botuikit.views.ComponentView
|
|
public ComponentType type() {
|
|
return ComponentType.SELECT;
|
|
}
|
|
}
|