package com.discord.utilities.mg_recycler; import androidx.recyclerview.widget.RecyclerView; import com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter.Payload; import com.discord.utilities.mg_recycler.DragAndDropAdapter; import d0.t.c0; import d0.z.d.m; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import kotlin.ranges.IntRange; /* compiled from: CategoricalDragAndDropAdapter.kt */ public abstract class CategoricalDragAndDropAdapter extends DragAndDropAdapter { /* compiled from: CategoricalDragAndDropAdapter.kt */ public interface Payload extends DragAndDropAdapter.Payload { String getCategory(); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public CategoricalDragAndDropAdapter(RecyclerView recyclerView) { super(recyclerView); m.checkNotNullParameter(recyclerView, "recycler"); } @Override // com.discord.utilities.mg_recycler.DragAndDropAdapter public Map computeChangedPositions() { HashMap hashMap = new HashMap(); if (getDataCopy().isEmpty()) { return hashMap; } String category = ((Payload) getDataCopy().get(0)).getCategory(); int size = getDataCopy().size(); int i = 0; for (int i2 = 0; i2 < size; i2++) { Payload payload = (Payload) getDataCopy().get(i2); if (!m.areEqual(payload.getCategory(), category)) { category = payload.getCategory(); i = 0; } Integer num = getOrigPositions().get(payload.getKey()); if (num == null || num.intValue() != i) { hashMap.put(payload.getKey(), Integer.valueOf(i)); } i++; } return hashMap; } @Override // com.discord.utilities.mg_recycler.DragAndDropHelper.Adapter public boolean isValidMove(int i, int i2) { String category = ((Payload) getDataCopy().get(i)).getCategory(); IntRange intRange = new IntRange(Math.min(i, i2), Math.max(i, i2)); if ((intRange instanceof Collection) && ((Collection) intRange).isEmpty()) { return true; } Iterator it = intRange.iterator(); while (it.hasNext()) { if (!m.areEqual(((Payload) getDataCopy().get(((c0) it).nextInt())).getCategory(), category)) { return false; } } return true; } }