forked from Juby210/discord-jadx
115 lines
4.5 KiB
Java
115 lines
4.5 KiB
Java
package com.discord.widgets.guilds.list;
|
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: GuildsDragAndDropCallback.kt */
|
|
public final class GuildsDragAndDropCallback extends ItemTouchHelper.Callback {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int DEFAULT_DRAG_SCROLL_SPEED = 20;
|
|
private static final float MOVE_THRESHOLD = 0.2f;
|
|
private final Controller controller;
|
|
|
|
/* compiled from: GuildsDragAndDropCallback.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: GuildsDragAndDropCallback.kt */
|
|
public interface Controller {
|
|
RecyclerView.ViewHolder chooseDropTarget(RecyclerView.ViewHolder viewHolder, List<RecyclerView.ViewHolder> list, int i, int i2);
|
|
|
|
void onDragStarted(RecyclerView.ViewHolder viewHolder);
|
|
|
|
void onDrop();
|
|
|
|
boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2);
|
|
}
|
|
|
|
/* compiled from: GuildsDragAndDropCallback.kt */
|
|
public interface DraggableViewHolder {
|
|
boolean canDrag();
|
|
}
|
|
|
|
public GuildsDragAndDropCallback(Controller controller) {
|
|
m.checkNotNullParameter(controller, "controller");
|
|
this.controller = controller;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public RecyclerView.ViewHolder chooseDropTarget(RecyclerView.ViewHolder viewHolder, List<RecyclerView.ViewHolder> list, int i, int i2) {
|
|
m.checkNotNullParameter(viewHolder, "selected");
|
|
m.checkNotNullParameter(list, "dropTargets");
|
|
return this.controller.chooseDropTarget(viewHolder, list, i, i2);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public float getMoveThreshold(RecyclerView.ViewHolder viewHolder) {
|
|
m.checkNotNullParameter(viewHolder, "viewHolder");
|
|
return 0.2f;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
|
m.checkNotNullParameter(recyclerView, "recyclerView");
|
|
m.checkNotNullParameter(viewHolder, "viewHolder");
|
|
if (!(viewHolder instanceof DraggableViewHolder)) {
|
|
viewHolder = null;
|
|
}
|
|
DraggableViewHolder draggableViewHolder = (DraggableViewHolder) viewHolder;
|
|
boolean z2 = true;
|
|
if (draggableViewHolder == null || !draggableViewHolder.canDrag()) {
|
|
z2 = false;
|
|
}
|
|
return ItemTouchHelper.Callback.makeMovementFlags(z2 ? 3 : 0, 0);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public int interpolateOutOfBoundsScroll(RecyclerView recyclerView, int i, int i2, int i3, long j) {
|
|
m.checkNotNullParameter(recyclerView, "recyclerView");
|
|
return ((int) Math.signum((float) i2)) * 20;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public boolean isItemViewSwipeEnabled() {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public boolean isLongPressDragEnabled() {
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2) {
|
|
m.checkNotNullParameter(recyclerView, "recyclerView");
|
|
m.checkNotNullParameter(viewHolder, "source");
|
|
m.checkNotNullParameter(viewHolder2, "target");
|
|
return this.controller.onMove(recyclerView, viewHolder, viewHolder2);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int i) {
|
|
if (i == 2) {
|
|
if (viewHolder != null) {
|
|
this.controller.onDragStarted(viewHolder);
|
|
}
|
|
} else if (i == 0) {
|
|
this.controller.onDrop();
|
|
}
|
|
super.onSelectedChanged(viewHolder, i);
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
|
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int i) {
|
|
m.checkNotNullParameter(viewHolder, "viewHolder");
|
|
}
|
|
}
|