649 lines
26 KiB
Java
649 lines
26 KiB
Java
package com.discord.widgets.servers;
|
|
|
|
import a0.a.a.b;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.databinding.SettingsChannelListCategoryItemBinding;
|
|
import com.discord.databinding.SettingsChannelListItemBinding;
|
|
import com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter;
|
|
import com.discord.utilities.mg_recycler.DragAndDropHelper;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import d0.t.h0;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.functions.Action1;
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public final class SettingsChannelListAdapter extends CategoricalDragAndDropAdapter<CategoricalDragAndDropAdapter.Payload> {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int TYPE_CATEGORY = 1;
|
|
public static final int TYPE_CHANNEL = 0;
|
|
private Function1<? super Long, Unit> onClickListener;
|
|
private Function1<? super Map<Long, UpdatedPosition>, Unit> onPositionUpdateListener;
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class CategoryItem implements CategoricalDragAndDropAdapter.Payload {
|
|
private final boolean canManageCategory;
|
|
private final boolean canManageChannelsOfCategory;
|
|
|
|
/* renamed from: id reason: collision with root package name */
|
|
private final long f2157id;
|
|
private final boolean isDraggable;
|
|
private final String key;
|
|
private final String name;
|
|
private final int pos;
|
|
private final int type = 1;
|
|
|
|
public CategoryItem(String str, long j, int i, boolean z2, boolean z3, boolean z4) {
|
|
this.name = str;
|
|
this.f2157id = j;
|
|
this.pos = i;
|
|
this.isDraggable = z2;
|
|
this.canManageCategory = z3;
|
|
this.canManageChannelsOfCategory = z4;
|
|
this.key = String.valueOf(j);
|
|
}
|
|
|
|
private final int component3() {
|
|
return this.pos;
|
|
}
|
|
|
|
public static /* synthetic */ CategoryItem copy$default(CategoryItem categoryItem, String str, long j, int i, boolean z2, boolean z3, boolean z4, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
str = categoryItem.name;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
j = categoryItem.f2157id;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
i = categoryItem.pos;
|
|
}
|
|
if ((i2 & 8) != 0) {
|
|
z2 = categoryItem.isDraggable;
|
|
}
|
|
if ((i2 & 16) != 0) {
|
|
z3 = categoryItem.canManageCategory;
|
|
}
|
|
if ((i2 & 32) != 0) {
|
|
z4 = categoryItem.canManageChannelsOfCategory;
|
|
}
|
|
return categoryItem.copy(str, j, i, z2, z3, z4);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.name;
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.f2157id;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.isDraggable;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.canManageCategory;
|
|
}
|
|
|
|
public final boolean component6() {
|
|
return this.canManageChannelsOfCategory;
|
|
}
|
|
|
|
public final CategoryItem copy(String str, long j, int i, boolean z2, boolean z3, boolean z4) {
|
|
return new CategoryItem(str, j, i, z2, z3, z4);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof CategoryItem)) {
|
|
return false;
|
|
}
|
|
CategoryItem categoryItem = (CategoryItem) obj;
|
|
return m.areEqual(this.name, categoryItem.name) && this.f2157id == categoryItem.f2157id && this.pos == categoryItem.pos && this.isDraggable == categoryItem.isDraggable && this.canManageCategory == categoryItem.canManageCategory && this.canManageChannelsOfCategory == categoryItem.canManageChannelsOfCategory;
|
|
}
|
|
|
|
public final boolean getCanManageCategory() {
|
|
return this.canManageCategory;
|
|
}
|
|
|
|
public final boolean getCanManageChannelsOfCategory() {
|
|
return this.canManageChannelsOfCategory;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter.Payload
|
|
public String getCategory() {
|
|
return String.valueOf(getType());
|
|
}
|
|
|
|
public final long getId() {
|
|
return this.f2157id;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
public final String getName() {
|
|
return this.name;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropAdapter.Payload
|
|
public int getPosition() {
|
|
return this.pos;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
|
|
public int getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.name;
|
|
int a = (((b.a(this.f2157id) + ((str != null ? str.hashCode() : 0) * 31)) * 31) + this.pos) * 31;
|
|
boolean z2 = this.isDraggable;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (a + i2) * 31;
|
|
boolean z3 = this.canManageCategory;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i6 = z3 ? 1 : 0;
|
|
int i7 = z3 ? 1 : 0;
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = (i5 + i6) * 31;
|
|
boolean z4 = this.canManageChannelsOfCategory;
|
|
if (!z4) {
|
|
i = z4 ? 1 : 0;
|
|
}
|
|
return i9 + i;
|
|
}
|
|
|
|
public final boolean isDraggable() {
|
|
return this.isDraggable;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("CategoryItem(name=");
|
|
L.append(this.name);
|
|
L.append(", id=");
|
|
L.append(this.f2157id);
|
|
L.append(", pos=");
|
|
L.append(this.pos);
|
|
L.append(", isDraggable=");
|
|
L.append(this.isDraggable);
|
|
L.append(", canManageCategory=");
|
|
L.append(this.canManageCategory);
|
|
L.append(", canManageChannelsOfCategory=");
|
|
return a.G(L, this.canManageChannelsOfCategory, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class CategoryListItem extends MGRecyclerViewHolder<SettingsChannelListAdapter, CategoricalDragAndDropAdapter.Payload> implements DragAndDropHelper.DraggableViewHolder {
|
|
private final SettingsChannelListCategoryItemBinding binding;
|
|
private CategoryItem categoryItem;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public CategoryListItem(SettingsChannelListAdapter settingsChannelListAdapter) {
|
|
super(2131558657, settingsChannelListAdapter);
|
|
m.checkNotNullParameter(settingsChannelListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131364923;
|
|
ImageView imageView = (ImageView) view.findViewById(2131364923);
|
|
if (imageView != null) {
|
|
i = 2131364924;
|
|
TextView textView = (TextView) view.findViewById(2131364924);
|
|
if (textView != null) {
|
|
SettingsChannelListCategoryItemBinding settingsChannelListCategoryItemBinding = new SettingsChannelListCategoryItemBinding((RelativeLayout) view, imageView, textView);
|
|
m.checkNotNullExpressionValue(settingsChannelListCategoryItemBinding, "SettingsChannelListCateg…temBinding.bind(itemView)");
|
|
this.binding = settingsChannelListCategoryItemBinding;
|
|
return;
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropHelper.DraggableViewHolder
|
|
public boolean canDrag() {
|
|
CategoryItem categoryItem = this.categoryItem;
|
|
return categoryItem != null && categoryItem.isDraggable() && categoryItem.getCanManageCategory();
|
|
}
|
|
|
|
public void onConfigure(int i, CategoricalDragAndDropAdapter.Payload payload) {
|
|
m.checkNotNullParameter(payload, "data");
|
|
super.onConfigure(i, (int) payload);
|
|
CategoryItem categoryItem = (CategoryItem) payload;
|
|
this.categoryItem = categoryItem;
|
|
if (categoryItem != null) {
|
|
Function1<Long, Unit> onClickListener = ((SettingsChannelListAdapter) this.adapter).getOnClickListener();
|
|
if (onClickListener != null) {
|
|
this.itemView.setOnClickListener(new SettingsChannelListAdapter$CategoryListItem$onConfigure$$inlined$let$lambda$1(onClickListener, categoryItem, this));
|
|
}
|
|
TextView textView = this.binding.f1624c;
|
|
m.checkNotNullExpressionValue(textView, "binding.settingsChannelListCategoryItemText");
|
|
String name = categoryItem.getName();
|
|
if (name == null) {
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
name = view.getContext().getString(2131894257);
|
|
}
|
|
textView.setText(name);
|
|
ImageView imageView = this.binding.b;
|
|
m.checkNotNullExpressionValue(imageView, "binding.settingsChannelListCategoryItemDrag");
|
|
imageView.setVisibility(canDrag() ? 0 : 8);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropHelper.DraggableViewHolder
|
|
public void onDragStateChanged(boolean z2) {
|
|
}
|
|
}
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class ChannelItem implements CategoricalDragAndDropAdapter.Payload {
|
|
private final boolean canManageCategoryOfChannel;
|
|
private final Channel channel;
|
|
private final boolean isDraggable;
|
|
private final String key;
|
|
private final long parentId;
|
|
private final int type;
|
|
|
|
public ChannelItem(Channel channel, boolean z2, long j, boolean z3) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
this.channel = channel;
|
|
this.isDraggable = z2;
|
|
this.parentId = j;
|
|
this.canManageCategoryOfChannel = z3;
|
|
this.key = String.valueOf(channel.h());
|
|
}
|
|
|
|
public static /* synthetic */ ChannelItem copy$default(ChannelItem channelItem, Channel channel, boolean z2, long j, boolean z3, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = channelItem.channel;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = channelItem.isDraggable;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
j = channelItem.parentId;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
z3 = channelItem.canManageCategoryOfChannel;
|
|
}
|
|
return channelItem.copy(channel, z2, j, z3);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.isDraggable;
|
|
}
|
|
|
|
public final long component3() {
|
|
return this.parentId;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.canManageCategoryOfChannel;
|
|
}
|
|
|
|
public final ChannelItem copy(Channel channel, boolean z2, long j, boolean z3) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
return new ChannelItem(channel, z2, j, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ChannelItem)) {
|
|
return false;
|
|
}
|
|
ChannelItem channelItem = (ChannelItem) obj;
|
|
return m.areEqual(this.channel, channelItem.channel) && this.isDraggable == channelItem.isDraggable && this.parentId == channelItem.parentId && this.canManageCategoryOfChannel == channelItem.canManageCategoryOfChannel;
|
|
}
|
|
|
|
public final boolean getCanManageCategoryOfChannel() {
|
|
return this.canManageCategoryOfChannel;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter.Payload
|
|
public String getCategory() {
|
|
return String.valueOf(getType());
|
|
}
|
|
|
|
public final Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
public final long getParentId() {
|
|
return this.parentId;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropAdapter.Payload
|
|
public int getPosition() {
|
|
return this.channel.t();
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
|
|
public int getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = this.channel;
|
|
int hashCode = (channel != null ? channel.hashCode() : 0) * 31;
|
|
boolean z2 = this.isDraggable;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int a = (b.a(this.parentId) + ((hashCode + i2) * 31)) * 31;
|
|
boolean z3 = this.canManageCategoryOfChannel;
|
|
if (!z3) {
|
|
i = z3 ? 1 : 0;
|
|
}
|
|
return a + i;
|
|
}
|
|
|
|
public final boolean isDraggable() {
|
|
return this.isDraggable;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("ChannelItem(channel=");
|
|
L.append(this.channel);
|
|
L.append(", isDraggable=");
|
|
L.append(this.isDraggable);
|
|
L.append(", parentId=");
|
|
L.append(this.parentId);
|
|
L.append(", canManageCategoryOfChannel=");
|
|
return a.G(L, this.canManageCategoryOfChannel, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class ChannelListItem extends MGRecyclerViewHolder<SettingsChannelListAdapter, CategoricalDragAndDropAdapter.Payload> implements DragAndDropHelper.DraggableViewHolder {
|
|
private final SettingsChannelListItemBinding binding;
|
|
private ChannelItem channelItem;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ChannelListItem(SettingsChannelListAdapter settingsChannelListAdapter) {
|
|
super(2131558658, settingsChannelListAdapter);
|
|
m.checkNotNullParameter(settingsChannelListAdapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131364925;
|
|
ImageView imageView = (ImageView) view.findViewById(2131364925);
|
|
if (imageView != null) {
|
|
i = 2131364926;
|
|
ImageView imageView2 = (ImageView) view.findViewById(2131364926);
|
|
if (imageView2 != null) {
|
|
i = 2131364927;
|
|
TextView textView = (TextView) view.findViewById(2131364927);
|
|
if (textView != null) {
|
|
i = 2131364928;
|
|
View findViewById = view.findViewById(2131364928);
|
|
if (findViewById != null) {
|
|
SettingsChannelListItemBinding settingsChannelListItemBinding = new SettingsChannelListItemBinding((RelativeLayout) view, imageView, imageView2, textView, findViewById);
|
|
m.checkNotNullExpressionValue(settingsChannelListItemBinding, "SettingsChannelListItemBinding.bind(itemView)");
|
|
this.binding = settingsChannelListItemBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropHelper.DraggableViewHolder
|
|
public boolean canDrag() {
|
|
ChannelItem channelItem = this.channelItem;
|
|
return channelItem != null && channelItem.isDraggable() && channelItem.getCanManageCategoryOfChannel();
|
|
}
|
|
|
|
public void onConfigure(int i, CategoricalDragAndDropAdapter.Payload payload) {
|
|
m.checkNotNullParameter(payload, "data");
|
|
super.onConfigure(i, (int) payload);
|
|
ChannelItem channelItem = (ChannelItem) payload;
|
|
this.channelItem = channelItem;
|
|
if (channelItem != null) {
|
|
this.itemView.setOnClickListener(null);
|
|
Function1<Long, Unit> onClickListener = ((SettingsChannelListAdapter) this.adapter).getOnClickListener();
|
|
if (onClickListener != null) {
|
|
this.itemView.setOnClickListener(new SettingsChannelListAdapter$ChannelListItem$onConfigure$$inlined$let$lambda$1(onClickListener, channelItem, this));
|
|
}
|
|
ImageView imageView = this.binding.f1625c;
|
|
int A = channelItem.getChannel().A();
|
|
imageView.setImageResource(A != 2 ? A != 5 ? A != 13 ? 2131231496 : 2131231491 : 2131231481 : 2131231505);
|
|
TextView textView = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView, "binding.settingsChannelListItemName");
|
|
textView.setText(AnimatableValueParser.y0(channelItem.getChannel()));
|
|
ImageView imageView2 = this.binding.b;
|
|
m.checkNotNullExpressionValue(imageView2, "binding.settingsChannelListItemDrag");
|
|
imageView2.setVisibility(canDrag() ? 0 : 8);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropHelper.DraggableViewHolder
|
|
public void onDragStateChanged(boolean z2) {
|
|
View view = this.binding.e;
|
|
m.checkNotNullExpressionValue(view, "binding.settingsChannelListItemSelectedOverlay");
|
|
view.setVisibility(z2 ? 0 : 8);
|
|
}
|
|
}
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: SettingsChannelListAdapter.kt */
|
|
public static final class UpdatedPosition {
|
|
private final Long parentId;
|
|
private final int position;
|
|
|
|
public UpdatedPosition(int i, Long l) {
|
|
this.position = i;
|
|
this.parentId = l;
|
|
}
|
|
|
|
public static /* synthetic */ UpdatedPosition copy$default(UpdatedPosition updatedPosition, int i, Long l, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
i = updatedPosition.position;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
l = updatedPosition.parentId;
|
|
}
|
|
return updatedPosition.copy(i, l);
|
|
}
|
|
|
|
public final int component1() {
|
|
return this.position;
|
|
}
|
|
|
|
public final Long component2() {
|
|
return this.parentId;
|
|
}
|
|
|
|
public final UpdatedPosition copy(int i, Long l) {
|
|
return new UpdatedPosition(i, l);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof UpdatedPosition)) {
|
|
return false;
|
|
}
|
|
UpdatedPosition updatedPosition = (UpdatedPosition) obj;
|
|
return this.position == updatedPosition.position && m.areEqual(this.parentId, updatedPosition.parentId);
|
|
}
|
|
|
|
public final Long getParentId() {
|
|
return this.parentId;
|
|
}
|
|
|
|
public final int getPosition() {
|
|
return this.position;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int i = this.position * 31;
|
|
Long l = this.parentId;
|
|
return i + (l != null ? l.hashCode() : 0);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("UpdatedPosition(position=");
|
|
L.append(this.position);
|
|
L.append(", parentId=");
|
|
return a.B(L, this.parentId, ")");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public SettingsChannelListAdapter(RecyclerView recyclerView, boolean z2) {
|
|
super(recyclerView);
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
if (z2) {
|
|
new ItemTouchHelper(new DragAndDropHelper(this, 0, 2, null)).attachToRecyclerView(recyclerView);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ SettingsChannelListAdapter(RecyclerView recyclerView, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(recyclerView, (i & 2) != 0 ? true : z2);
|
|
}
|
|
|
|
private final void handleChangedPositions(Map<Long, Integer> map, Map<Long, Long> map2) {
|
|
HashMap hashMap = new HashMap();
|
|
for (Map.Entry<Long, Integer> entry : map.entrySet()) {
|
|
long longValue = entry.getKey().longValue();
|
|
hashMap.put(Long.valueOf(longValue), new UpdatedPosition(entry.getValue().intValue(), map2.get(Long.valueOf(longValue))));
|
|
}
|
|
Function1<? super Map<Long, UpdatedPosition>, Unit> function1 = this.onPositionUpdateListener;
|
|
if (function1 != null) {
|
|
function1.invoke(hashMap);
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter, com.discord.utilities.mg_recycler.DragAndDropAdapter
|
|
public Map<String, Integer> computeChangedPositions() {
|
|
SettingsChannelListAdapter$computeChangedPositions$1 settingsChannelListAdapter$computeChangedPositions$1 = SettingsChannelListAdapter$computeChangedPositions$1.INSTANCE;
|
|
SettingsChannelListAdapter$computeChangedPositions$2 settingsChannelListAdapter$computeChangedPositions$2 = SettingsChannelListAdapter$computeChangedPositions$2.INSTANCE;
|
|
SettingsChannelListAdapter$computeChangedPositions$3 settingsChannelListAdapter$computeChangedPositions$3 = SettingsChannelListAdapter$computeChangedPositions$3.INSTANCE;
|
|
HashMap hashMap = new HashMap();
|
|
HashMap hashMap2 = new HashMap();
|
|
int i = 0;
|
|
Long l = null;
|
|
for (Object obj : getDataCopy()) {
|
|
int i2 = i + 1;
|
|
if (i < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
CategoricalDragAndDropAdapter.Payload payload = (CategoricalDragAndDropAdapter.Payload) obj;
|
|
Long invoke = SettingsChannelListAdapter$computeChangedPositions$1.INSTANCE.invoke(payload);
|
|
long longValue = invoke != null ? invoke.longValue() : 0;
|
|
if (payload.getType() == 1) {
|
|
l = SettingsChannelListAdapter$computeChangedPositions$2.INSTANCE.invoke(longValue);
|
|
}
|
|
Long invoke2 = payload.getType() != 0 ? null : SettingsChannelListAdapter$computeChangedPositions$2.INSTANCE.invoke(((ChannelItem) payload).getParentId());
|
|
Integer num = getOrigPositions().get(payload.getKey());
|
|
if ((num == null || num.intValue() != i) && SettingsChannelListAdapter$computeChangedPositions$3.INSTANCE.invoke(payload)) {
|
|
hashMap.put(Long.valueOf(longValue), Integer.valueOf(i));
|
|
if ((!m.areEqual(invoke2, l)) && payload.getType() == 0) {
|
|
hashMap2.put(Long.valueOf(longValue), Long.valueOf(l != null ? l.longValue() : -1));
|
|
}
|
|
}
|
|
i = i2;
|
|
}
|
|
handleChangedPositions(hashMap, hashMap2);
|
|
return h0.emptyMap();
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super java.lang.Long, kotlin.Unit>, kotlin.jvm.functions.Function1<java.lang.Long, kotlin.Unit> */
|
|
public final Function1<Long, Unit> getOnClickListener() {
|
|
return this.onClickListener;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter, com.discord.utilities.mg_recycler.DragAndDropHelper.Adapter
|
|
public boolean isValidMove(int i, int i2) {
|
|
if (i2 <= 0) {
|
|
return false;
|
|
}
|
|
CategoricalDragAndDropAdapter.Payload item = getItem(i2 - 1);
|
|
int type = item.getType();
|
|
if (type == 0) {
|
|
return ((ChannelItem) item).getCanManageCategoryOfChannel();
|
|
}
|
|
if (type != 1) {
|
|
return false;
|
|
}
|
|
return ((CategoryItem) item).getCanManageChannelsOfCategory();
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public MGRecyclerViewHolder<SettingsChannelListAdapter, CategoricalDragAndDropAdapter.Payload> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
if (i == 0) {
|
|
return new ChannelListItem(this);
|
|
}
|
|
if (i == 1) {
|
|
return new CategoryListItem(this);
|
|
}
|
|
throw invalidViewTypeException(i);
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.DragAndDropAdapter
|
|
public void onNewPositions(Map<String, Integer> map) {
|
|
m.checkNotNullParameter(map, "newPositions");
|
|
}
|
|
|
|
public final void setOnClickListener(Function1<? super Long, Unit> function1) {
|
|
this.onClickListener = function1;
|
|
}
|
|
|
|
public final void setPositionUpdateListener(Action1<Map<Long, UpdatedPosition>> action1) {
|
|
m.checkNotNullParameter(action1, "onPositionUpdateListener");
|
|
this.onPositionUpdateListener = new SettingsChannelListAdapter$setPositionUpdateListener$1(action1);
|
|
}
|
|
}
|