112 lines
5.2 KiB
Java
112 lines
5.2 KiB
Java
package com.discord.widgets.botuikit.views;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.ViewGroup;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.a.i.b2;
|
|
import c.a.i.m4;
|
|
import com.discord.api.botuikit.ComponentType;
|
|
import com.discord.models.botuikit.ActionInteractionComponentState;
|
|
import com.discord.models.botuikit.ActionRowMessageComponent;
|
|
import com.discord.models.botuikit.MessageComponent;
|
|
import com.discord.models.botuikit.MessageComponentUtils;
|
|
import com.discord.widgets.botuikit.ComponentProvider;
|
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterItemBotComponentRowKt;
|
|
import com.google.android.flexbox.FlexboxLayout;
|
|
import d0.t.n;
|
|
import d0.t.o;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: ActionRowComponentView.kt */
|
|
public final class ActionRowComponentView extends LinearLayout implements ComponentView<ActionRowMessageComponent> {
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
/* compiled from: ActionRowComponentView.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final ActionRowComponentView inflateComponent(Context context, ViewGroup viewGroup) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(viewGroup, "root");
|
|
m4 a = m4.a(LayoutInflater.from(context).inflate(2131558974, viewGroup, false));
|
|
m.checkNotNullExpressionValue(a, "WidgetChatListBotUiActio…om(context), root, false)");
|
|
ActionRowComponentView actionRowComponentView = a.a;
|
|
m.checkNotNullExpressionValue(actionRowComponentView, "WidgetChatListBotUiActio…ntext), root, false).root");
|
|
return actionRowComponentView;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public ActionRowComponentView(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 ActionRowComponentView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(attributeSet, "attrs");
|
|
}
|
|
|
|
public void configure(ActionRowMessageComponent actionRowMessageComponent, ComponentProvider componentProvider, ComponentActionListener componentActionListener) {
|
|
m.checkNotNullParameter(actionRowMessageComponent, "component");
|
|
m.checkNotNullParameter(componentProvider, "componentProvider");
|
|
m.checkNotNullParameter(componentActionListener, "componentActionListener");
|
|
m4 a = m4.a(this);
|
|
m.checkNotNullExpressionValue(a, "WidgetChatListBotUiActio…mponentBinding.bind(this)");
|
|
List<MessageComponent> components = actionRowMessageComponent.getComponents();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(components, 10));
|
|
int i = 0;
|
|
int i2 = 0;
|
|
for (Object obj : components) {
|
|
int i3 = i2 + 1;
|
|
if (i2 < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
arrayList.add(componentProvider.getConfiguredComponentView(componentActionListener, (MessageComponent) obj, this, i2));
|
|
i2 = i3;
|
|
}
|
|
FlexboxLayout flexboxLayout = a.b;
|
|
m.checkNotNullExpressionValue(flexboxLayout, "binding.actionRowComponentViewGroup");
|
|
WidgetChatListAdapterItemBotComponentRowKt.replaceViews(flexboxLayout, u.filterNotNull(arrayList));
|
|
ActionInteractionComponentState.Failed childError = MessageComponentUtils.INSTANCE.getChildError(actionRowMessageComponent);
|
|
b2 b2Var = a.f128c;
|
|
m.checkNotNullExpressionValue(b2Var, "binding.actionRowComponentViewGroupErrorRow");
|
|
ConstraintLayout constraintLayout = b2Var.a;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.actionRowComponentViewGroupErrorRow.root");
|
|
if (!(childError != null)) {
|
|
i = 8;
|
|
}
|
|
constraintLayout.setVisibility(i);
|
|
if (childError != null) {
|
|
String errorMessage = childError.getErrorMessage();
|
|
if (errorMessage == null) {
|
|
errorMessage = getResources().getString(2131886379);
|
|
m.checkNotNullExpressionValue(errorMessage, "resources.getString(R.st…plication_command_failed)");
|
|
}
|
|
TextView textView = a.f128c.b;
|
|
m.checkNotNullExpressionValue(textView, "binding.actionRowCompone…ractionFailedLabelMessage");
|
|
textView.setText(errorMessage);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.widgets.botuikit.views.ComponentView
|
|
public ComponentType type() {
|
|
return ComponentType.ACTION_ROW;
|
|
}
|
|
}
|