2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.roles;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2021-08-19 06:48:32 +00:00
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import androidx.cardview.widget.CardView;
|
2021-08-20 05:39:29 +00:00
|
|
|
import c.a.i.r;
|
2021-10-15 06:18:26 +00:00
|
|
|
import c0.t.n;
|
|
|
|
import c0.z.d.m;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.R;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.api.role.GuildRole;
|
|
|
|
import com.discord.stores.StoreStream;
|
2021-08-19 06:48:32 +00:00
|
|
|
import com.discord.utilities.color.ColorCompatKt;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
|
|
import com.discord.utilities.guilds.RoleUtils;
|
|
|
|
import com.google.android.material.chip.ChipGroup;
|
|
|
|
import java.util.List;
|
|
|
|
/* compiled from: RolesListView.kt */
|
|
|
|
public final class RolesListView extends ChipGroup {
|
|
|
|
private List<GuildRole> roles = n.emptyList();
|
|
|
|
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
|
|
public RolesListView(Context context, AttributeSet attributeSet) {
|
|
|
|
super(context, attributeSet);
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
m.checkNotNullParameter(attributeSet, "attrs");
|
|
|
|
int dpToPixels = DimenUtils.dpToPixels(4);
|
|
|
|
setChipSpacingVertical(dpToPixels);
|
|
|
|
setChipSpacingHorizontal(dpToPixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<GuildRole> getRoles() {
|
|
|
|
return this.roles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setRoles(List<GuildRole> list) {
|
|
|
|
m.checkNotNullParameter(list, "<set-?>");
|
|
|
|
this.roles = list;
|
|
|
|
}
|
|
|
|
|
2021-08-19 06:48:32 +00:00
|
|
|
public final void updateView(List<GuildRole> list, int i, long j) {
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullParameter(list, "roles");
|
|
|
|
if (!m.areEqual(list, this.roles)) {
|
|
|
|
boolean isDeveloperMode = StoreStream.Companion.getUserSettings().getIsDeveloperMode();
|
|
|
|
this.roles = list;
|
|
|
|
removeAllViews();
|
|
|
|
for (GuildRole guildRole : list) {
|
2021-08-09 22:51:56 +00:00
|
|
|
View inflate = LayoutInflater.from(getContext()).inflate(R.layout.guild_role_chip, (ViewGroup) null, false);
|
2021-08-19 06:48:32 +00:00
|
|
|
int i2 = R.id.role_chip_dot;
|
|
|
|
ImageView imageView = (ImageView) inflate.findViewById(R.id.role_chip_dot);
|
|
|
|
if (imageView != null) {
|
|
|
|
i2 = R.id.role_chip_icon;
|
|
|
|
RoleIconView roleIconView = (RoleIconView) inflate.findViewById(R.id.role_chip_icon);
|
|
|
|
if (roleIconView != null) {
|
|
|
|
i2 = R.id.role_chip_text;
|
|
|
|
TextView textView = (TextView) inflate.findViewById(R.id.role_chip_text);
|
|
|
|
if (textView != null) {
|
|
|
|
CardView cardView = (CardView) inflate;
|
2021-08-20 05:39:29 +00:00
|
|
|
m.checkNotNullExpressionValue(new r(cardView, imageView, roleIconView, textView), "GuildRoleChipBinding.inf…om(context), null, false)");
|
2021-08-19 06:48:32 +00:00
|
|
|
m.checkNotNullExpressionValue(textView, "binding.roleChipText");
|
|
|
|
textView.setText(guildRole.g());
|
|
|
|
int opaqueColor = RoleUtils.isDefaultColor(guildRole) ? i : RoleUtils.getOpaqueColor(guildRole);
|
|
|
|
m.checkNotNullExpressionValue(imageView, "binding.roleChipDot");
|
|
|
|
ColorCompatKt.tintWithColor(imageView, opaqueColor);
|
|
|
|
roleIconView.setRole(guildRole, Long.valueOf(j));
|
|
|
|
if (isDeveloperMode) {
|
|
|
|
cardView.setOnClickListener(new RolesListView$updateView$$inlined$forEach$lambda$1(guildRole, this, i, j, isDeveloperMode));
|
|
|
|
}
|
|
|
|
addView(cardView);
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-08-19 06:48:32 +00:00
|
|
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|