329 lines
14 KiB
Java
329 lines
14 KiB
Java
|
package com.discord.widgets.channels.permissions;
|
||
|
|
||
|
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 androidx.recyclerview.widget.LinearLayoutManager;
|
||
|
import androidx.recyclerview.widget.RecyclerView;
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.databinding.RemovablePermissionOwnerViewBinding;
|
||
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
||
|
import com.discord.views.permissions.ChannelPermissionOwnerView;
|
||
|
import d0.t.n;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.List;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public final class PermissionOwnerListView extends RecyclerView {
|
||
|
private final Adapter adapter;
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class Adapter extends RecyclerView.Adapter<PermissionOwnerViewHolder> {
|
||
|
private List<Item> data = n.emptyList();
|
||
|
private Function1<? super PermissionOwner, Unit> onRemoveClicked = PermissionOwnerListView$Adapter$onRemoveClicked$1.INSTANCE;
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||
|
public int getItemCount() {
|
||
|
return this.data.size();
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super com.discord.widgets.channels.permissions.PermissionOwner, kotlin.Unit>, kotlin.jvm.functions.Function1<com.discord.widgets.channels.permissions.PermissionOwner, kotlin.Unit> */
|
||
|
public final Function1<PermissionOwner, Unit> getOnRemoveClicked() {
|
||
|
return this.onRemoveClicked;
|
||
|
}
|
||
|
|
||
|
public void onBindViewHolder(PermissionOwnerViewHolder permissionOwnerViewHolder, int i) {
|
||
|
m.checkNotNullParameter(permissionOwnerViewHolder, "holder");
|
||
|
permissionOwnerViewHolder.configure(this.data.get(i), new PermissionOwnerListView$Adapter$onBindViewHolder$1(this, this.data.get(i)));
|
||
|
}
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
||
|
public PermissionOwnerViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
||
|
m.checkNotNullParameter(viewGroup, "parent");
|
||
|
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(2131558651, viewGroup, false);
|
||
|
int i2 = 2131364302;
|
||
|
ChannelPermissionOwnerView channelPermissionOwnerView = (ChannelPermissionOwnerView) inflate.findViewById(2131364302);
|
||
|
if (channelPermissionOwnerView != null) {
|
||
|
i2 = 2131364510;
|
||
|
ImageView imageView = (ImageView) inflate.findViewById(2131364510);
|
||
|
if (imageView != null) {
|
||
|
RemovablePermissionOwnerViewBinding removablePermissionOwnerViewBinding = new RemovablePermissionOwnerViewBinding((ConstraintLayout) inflate, channelPermissionOwnerView, imageView);
|
||
|
m.checkNotNullExpressionValue(removablePermissionOwnerViewBinding, "RemovablePermissionOwner…,\n false\n )");
|
||
|
return new PermissionOwnerViewHolder(removablePermissionOwnerViewBinding);
|
||
|
}
|
||
|
}
|
||
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
|
||
|
}
|
||
|
|
||
|
public final void setData(List<Item> list) {
|
||
|
m.checkNotNullParameter(list, "data");
|
||
|
this.data = list;
|
||
|
notifyDataSetChanged();
|
||
|
}
|
||
|
|
||
|
public final void setOnRemoveClicked(Function1<? super PermissionOwner, Unit> function1) {
|
||
|
m.checkNotNullParameter(function1, "<set-?>");
|
||
|
this.onRemoveClicked = function1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class Item {
|
||
|
private final PermissionOwner permissionOwner;
|
||
|
private final RemoveStatus removeStatus;
|
||
|
|
||
|
public Item(PermissionOwner permissionOwner, RemoveStatus removeStatus) {
|
||
|
m.checkNotNullParameter(permissionOwner, "permissionOwner");
|
||
|
m.checkNotNullParameter(removeStatus, "removeStatus");
|
||
|
this.permissionOwner = permissionOwner;
|
||
|
this.removeStatus = removeStatus;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ Item copy$default(Item item, PermissionOwner permissionOwner, RemoveStatus removeStatus, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
permissionOwner = item.permissionOwner;
|
||
|
}
|
||
|
if ((i & 2) != 0) {
|
||
|
removeStatus = item.removeStatus;
|
||
|
}
|
||
|
return item.copy(permissionOwner, removeStatus);
|
||
|
}
|
||
|
|
||
|
public final PermissionOwner component1() {
|
||
|
return this.permissionOwner;
|
||
|
}
|
||
|
|
||
|
public final RemoveStatus component2() {
|
||
|
return this.removeStatus;
|
||
|
}
|
||
|
|
||
|
public final Item copy(PermissionOwner permissionOwner, RemoveStatus removeStatus) {
|
||
|
m.checkNotNullParameter(permissionOwner, "permissionOwner");
|
||
|
m.checkNotNullParameter(removeStatus, "removeStatus");
|
||
|
return new Item(permissionOwner, removeStatus);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof Item)) {
|
||
|
return false;
|
||
|
}
|
||
|
Item item = (Item) obj;
|
||
|
return m.areEqual(this.permissionOwner, item.permissionOwner) && m.areEqual(this.removeStatus, item.removeStatus);
|
||
|
}
|
||
|
|
||
|
public final PermissionOwner getPermissionOwner() {
|
||
|
return this.permissionOwner;
|
||
|
}
|
||
|
|
||
|
public final RemoveStatus getRemoveStatus() {
|
||
|
return this.removeStatus;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
PermissionOwner permissionOwner = this.permissionOwner;
|
||
|
int i = 0;
|
||
|
int hashCode = (permissionOwner != null ? permissionOwner.hashCode() : 0) * 31;
|
||
|
RemoveStatus removeStatus = this.removeStatus;
|
||
|
if (removeStatus != null) {
|
||
|
i = removeStatus.hashCode();
|
||
|
}
|
||
|
return hashCode + i;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("Item(permissionOwner=");
|
||
|
K.append(this.permissionOwner);
|
||
|
K.append(", removeStatus=");
|
||
|
K.append(this.removeStatus);
|
||
|
K.append(")");
|
||
|
return K.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class PermissionOwnerViewHolder extends RecyclerView.ViewHolder {
|
||
|
private final RemovablePermissionOwnerViewBinding binding;
|
||
|
|
||
|
public final /* synthetic */ class WhenMappings {
|
||
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
||
|
|
||
|
static {
|
||
|
RemoveStatus.CannotRemove.Reason.values();
|
||
|
int[] iArr = new int[4];
|
||
|
$EnumSwitchMapping$0 = iArr;
|
||
|
iArr[RemoveStatus.CannotRemove.Reason.IS_NOT_OVERRIDE.ordinal()] = 1;
|
||
|
iArr[RemoveStatus.CannotRemove.Reason.HAS_NO_PERMISSION.ordinal()] = 2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public PermissionOwnerViewHolder(RemovablePermissionOwnerViewBinding removablePermissionOwnerViewBinding) {
|
||
|
super(removablePermissionOwnerViewBinding.a);
|
||
|
m.checkNotNullParameter(removablePermissionOwnerViewBinding, "binding");
|
||
|
this.binding = removablePermissionOwnerViewBinding;
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ RemovablePermissionOwnerViewBinding access$getBinding$p(PermissionOwnerViewHolder permissionOwnerViewHolder) {
|
||
|
return permissionOwnerViewHolder.binding;
|
||
|
}
|
||
|
|
||
|
public final void configure(Item item, Function0<Unit> function0) {
|
||
|
m.checkNotNullParameter(item, "item");
|
||
|
m.checkNotNullParameter(function0, "onRemoveClicked");
|
||
|
this.binding.b.a(item.getPermissionOwner());
|
||
|
ImageView imageView = this.binding.f1625c;
|
||
|
m.checkNotNullExpressionValue(imageView, "binding.remove");
|
||
|
ViewExtensions.setEnabledAlpha$default(imageView, item.getRemoveStatus() instanceof RemoveStatus.CanRemove, 0.0f, 2, null);
|
||
|
this.binding.f1625c.setOnClickListener(new PermissionOwnerListView$PermissionOwnerViewHolder$configure$1(this, item, function0));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static abstract class RemoveStatus {
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class CanRemove extends RemoveStatus {
|
||
|
public static final CanRemove INSTANCE = new CanRemove();
|
||
|
|
||
|
private CanRemove() {
|
||
|
super(null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class CannotRemove extends RemoveStatus {
|
||
|
private final Reason reason;
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public enum Reason {
|
||
|
IS_GUILD_OWNER,
|
||
|
IS_ADMINISTRATOR,
|
||
|
IS_NOT_OVERRIDE,
|
||
|
HAS_NO_PERMISSION
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public CannotRemove(Reason reason) {
|
||
|
super(null);
|
||
|
m.checkNotNullParameter(reason, "reason");
|
||
|
this.reason = reason;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ CannotRemove copy$default(CannotRemove cannotRemove, Reason reason, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
reason = cannotRemove.reason;
|
||
|
}
|
||
|
return cannotRemove.copy(reason);
|
||
|
}
|
||
|
|
||
|
public final Reason component1() {
|
||
|
return this.reason;
|
||
|
}
|
||
|
|
||
|
public final CannotRemove copy(Reason reason) {
|
||
|
m.checkNotNullParameter(reason, "reason");
|
||
|
return new CannotRemove(reason);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this != obj) {
|
||
|
return (obj instanceof CannotRemove) && m.areEqual(this.reason, ((CannotRemove) obj).reason);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public final Reason getReason() {
|
||
|
return this.reason;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
Reason reason = this.reason;
|
||
|
if (reason != null) {
|
||
|
return reason.hashCode();
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("CannotRemove(reason=");
|
||
|
K.append(this.reason);
|
||
|
K.append(")");
|
||
|
return K.toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: PermissionOwnerListView.kt */
|
||
|
public static final class IsRemoving extends RemoveStatus {
|
||
|
public static final IsRemoving INSTANCE = new IsRemoving();
|
||
|
|
||
|
private IsRemoving() {
|
||
|
super(null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private RemoveStatus() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ RemoveStatus(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public PermissionOwnerListView(Context context) {
|
||
|
super(context);
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
Adapter adapter = new Adapter();
|
||
|
this.adapter = adapter;
|
||
|
setLayoutManager(new LinearLayoutManager(getContext(), 1, false));
|
||
|
setAdapter(adapter);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public PermissionOwnerListView(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
Adapter adapter = new Adapter();
|
||
|
this.adapter = adapter;
|
||
|
setLayoutManager(new LinearLayoutManager(getContext(), 1, false));
|
||
|
setAdapter(adapter);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public PermissionOwnerListView(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
Adapter adapter = new Adapter();
|
||
|
this.adapter = adapter;
|
||
|
setLayoutManager(new LinearLayoutManager(getContext(), 1, false));
|
||
|
setAdapter(adapter);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ PermissionOwnerListView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ PermissionOwnerListView(Context context, AttributeSet attributeSet, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(context, (i & 2) != 0 ? null : attributeSet);
|
||
|
}
|
||
|
|
||
|
public final void setData(List<Item> list, Function1<? super PermissionOwner, Unit> function1) {
|
||
|
m.checkNotNullParameter(list, "permissionOwners");
|
||
|
m.checkNotNullParameter(function1, "onRemoveClicked");
|
||
|
this.adapter.setOnRemoveClicked(function1);
|
||
|
this.adapter.setData(list);
|
||
|
}
|
||
|
}
|