230 lines
9.4 KiB
Java
230 lines
9.4 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.databinding.ViewCheckableRoleListItemBinding;
|
|
import com.discord.utilities.guilds.RoleUtils;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.views.CheckedSetting;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: WidgetServerSettingsEditMemberRolesAdapter.kt */
|
|
public final class WidgetServerSettingsEditMemberRolesAdapter extends MGRecyclerAdapterSimple<RoleItem> {
|
|
private Function1<? super Long, Unit> roleClickListener;
|
|
|
|
/* compiled from: WidgetServerSettingsEditMemberRolesAdapter.kt */
|
|
public static final class RoleItem implements MGRecyclerDataPayload {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int TYPE_ROLE = 1;
|
|
private final boolean isManageable;
|
|
private final boolean isUserHasRole;
|
|
private final String key;
|
|
private final GuildRole role;
|
|
private final int type;
|
|
|
|
/* compiled from: WidgetServerSettingsEditMemberRolesAdapter.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public RoleItem(GuildRole guildRole, boolean z2, GuildRole guildRole2, boolean z3, boolean z4) {
|
|
this(guildRole, z2, !guildRole.d() && (z3 || RoleUtils.rankIsHigher(guildRole2, guildRole)) && z4);
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
}
|
|
|
|
public RoleItem(GuildRole guildRole, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
this.role = guildRole;
|
|
this.isUserHasRole = z2;
|
|
this.isManageable = z3;
|
|
this.type = 1;
|
|
this.key = String.valueOf(guildRole.getId());
|
|
}
|
|
|
|
public static /* synthetic */ RoleItem copy$default(RoleItem roleItem, GuildRole guildRole, boolean z2, boolean z3, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
guildRole = roleItem.role;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = roleItem.isUserHasRole;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z3 = roleItem.isManageable;
|
|
}
|
|
return roleItem.copy(guildRole, z2, z3);
|
|
}
|
|
|
|
public final GuildRole component1() {
|
|
return this.role;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.isUserHasRole;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isManageable;
|
|
}
|
|
|
|
public final RoleItem copy(GuildRole guildRole, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(guildRole, "role");
|
|
return new RoleItem(guildRole, z2, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof RoleItem)) {
|
|
return false;
|
|
}
|
|
RoleItem roleItem = (RoleItem) obj;
|
|
return m.areEqual(this.role, roleItem.role) && this.isUserHasRole == roleItem.isUserHasRole && this.isManageable == roleItem.isManageable;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
public final GuildRole getRole() {
|
|
return this.role;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
|
|
public int getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public int hashCode() {
|
|
GuildRole guildRole = this.role;
|
|
int hashCode = (guildRole != null ? guildRole.hashCode() : 0) * 31;
|
|
boolean z2 = this.isUserHasRole;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode + i2) * 31;
|
|
boolean z3 = this.isManageable;
|
|
if (!z3) {
|
|
i = z3 ? 1 : 0;
|
|
}
|
|
return i5 + i;
|
|
}
|
|
|
|
public final boolean isManageable() {
|
|
return this.isManageable;
|
|
}
|
|
|
|
public final boolean isRoleManaged() {
|
|
return this.role.d();
|
|
}
|
|
|
|
public final boolean isUserHasRole() {
|
|
return this.isUserHasRole;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("RoleItem(role=");
|
|
L.append(this.role);
|
|
L.append(", isUserHasRole=");
|
|
L.append(this.isUserHasRole);
|
|
L.append(", isManageable=");
|
|
return a.G(L, this.isManageable, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetServerSettingsEditMemberRolesAdapter.kt */
|
|
public static final class RoleListItem extends MGRecyclerViewHolder<WidgetServerSettingsEditMemberRolesAdapter, RoleItem> {
|
|
private final ViewCheckableRoleListItemBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public RoleListItem(WidgetServerSettingsEditMemberRolesAdapter widgetServerSettingsEditMemberRolesAdapter) {
|
|
super(2131558737, widgetServerSettingsEditMemberRolesAdapter);
|
|
m.checkNotNullParameter(widgetServerSettingsEditMemberRolesAdapter, "adapter");
|
|
View view = this.itemView;
|
|
Objects.requireNonNull(view, "rootView");
|
|
CheckedSetting checkedSetting = (CheckedSetting) view;
|
|
ViewCheckableRoleListItemBinding viewCheckableRoleListItemBinding = new ViewCheckableRoleListItemBinding(checkedSetting, checkedSetting);
|
|
m.checkNotNullExpressionValue(viewCheckableRoleListItemBinding, "ViewCheckableRoleListItemBinding.bind(itemView)");
|
|
this.binding = viewCheckableRoleListItemBinding;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetServerSettingsEditMemberRolesAdapter access$getAdapter$p(RoleListItem roleListItem) {
|
|
return (WidgetServerSettingsEditMemberRolesAdapter) roleListItem.adapter;
|
|
}
|
|
|
|
public void onConfigure(int i, RoleItem roleItem) {
|
|
m.checkNotNullParameter(roleItem, "data");
|
|
super.onConfigure(i, (int) roleItem);
|
|
this.binding.b.setText(roleItem.getRole().f());
|
|
CheckedSetting checkedSetting = this.binding.b;
|
|
GuildRole role = roleItem.getRole();
|
|
CheckedSetting checkedSetting2 = this.binding.b;
|
|
m.checkNotNullExpressionValue(checkedSetting2, "binding.roleItemCheckedSetting");
|
|
Context context = checkedSetting2.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.roleItemCheckedSetting.context");
|
|
checkedSetting.setTextColor(RoleUtils.getRoleColor$default(role, context, null, 2, null));
|
|
CheckedSetting checkedSetting3 = this.binding.b;
|
|
m.checkNotNullExpressionValue(checkedSetting3, "binding.roleItemCheckedSetting");
|
|
checkedSetting3.setChecked(roleItem.isUserHasRole());
|
|
if (roleItem.isManageable()) {
|
|
this.binding.b.e(new WidgetServerSettingsEditMemberRolesAdapter$RoleListItem$onConfigure$1(this, roleItem));
|
|
} else if (roleItem.isRoleManaged()) {
|
|
this.binding.b.b(2131891070);
|
|
} else {
|
|
CheckedSetting.d(this.binding.b, null, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetServerSettingsEditMemberRolesAdapter(RecyclerView recyclerView) {
|
|
super(recyclerView, false, 2, null);
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
}
|
|
|
|
public static final /* synthetic */ Function1 access$getRoleClickListener$p(WidgetServerSettingsEditMemberRolesAdapter widgetServerSettingsEditMemberRolesAdapter) {
|
|
return widgetServerSettingsEditMemberRolesAdapter.roleClickListener;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setRoleClickListener$p(WidgetServerSettingsEditMemberRolesAdapter widgetServerSettingsEditMemberRolesAdapter, Function1 function1) {
|
|
widgetServerSettingsEditMemberRolesAdapter.roleClickListener = function1;
|
|
}
|
|
|
|
public final void configure(List<RoleItem> list, Function1<? super Long, Unit> function1) {
|
|
m.checkNotNullParameter(list, "roleItems");
|
|
m.checkNotNullParameter(function1, "roleClickListener");
|
|
this.roleClickListener = function1;
|
|
setData(list);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public RoleListItem onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
if (i == 1) {
|
|
return new RoleListItem(this);
|
|
}
|
|
throw invalidViewTypeException(i);
|
|
}
|
|
}
|