134 lines
4.0 KiB
Java
134 lines
4.0 KiB
Java
package com.daimajia.swipe.implments;
|
|
|
|
import android.widget.BaseAdapter;
|
|
import android.widget.SpinnerAdapter;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.daimajia.swipe.SimpleSwipeListener;
|
|
import com.daimajia.swipe.SwipeLayout;
|
|
import com.daimajia.swipe.interfaces.SwipeAdapterInterface;
|
|
import com.daimajia.swipe.interfaces.SwipeItemMangerInterface;
|
|
import com.daimajia.swipe.util.Attributes$Mode;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class SwipeItemMangerImpl implements SwipeItemMangerInterface {
|
|
private Attributes$Mode a = Attributes$Mode.Single;
|
|
protected int b = -1;
|
|
protected Set<Integer> c = new HashSet();
|
|
protected Set<SwipeLayout> d = new HashSet();
|
|
protected BaseAdapter e;
|
|
protected RecyclerView.Adapter f;
|
|
|
|
class OnLayoutListener implements SwipeLayout.OnLayout {
|
|
private int a;
|
|
|
|
OnLayoutListener(int i) {
|
|
this.a = i;
|
|
}
|
|
|
|
public void a(int i) {
|
|
this.a = i;
|
|
}
|
|
|
|
@Override // com.daimajia.swipe.SwipeLayout.OnLayout
|
|
public void a(SwipeLayout swipeLayout) {
|
|
if (SwipeItemMangerImpl.this.b(this.a)) {
|
|
swipeLayout.b(false, false);
|
|
} else {
|
|
swipeLayout.a(false, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
class ValueBox {
|
|
OnLayoutListener a;
|
|
SwipeMemory b;
|
|
int c;
|
|
|
|
ValueBox(SwipeItemMangerImpl swipeItemMangerImpl, int i, SwipeMemory swipeMemory, OnLayoutListener onLayoutListener) {
|
|
this.b = swipeMemory;
|
|
this.a = onLayoutListener;
|
|
}
|
|
}
|
|
|
|
public SwipeItemMangerImpl(RecyclerView.Adapter adapter) {
|
|
if (adapter == null) {
|
|
throw new IllegalArgumentException("Adapter can not be null");
|
|
}
|
|
if (!(adapter instanceof SwipeItemMangerInterface)) {
|
|
throw new IllegalArgumentException("adapter should implement the SwipeAdapterInterface");
|
|
}
|
|
this.f = adapter;
|
|
}
|
|
|
|
public boolean b(int i) {
|
|
return this.a == Attributes$Mode.Multiple ? this.c.contains(Integer.valueOf(i)) : this.b == i;
|
|
}
|
|
|
|
class SwipeMemory extends SimpleSwipeListener {
|
|
private int a;
|
|
|
|
SwipeMemory(int i) {
|
|
this.a = i;
|
|
}
|
|
|
|
@Override // com.daimajia.swipe.SwipeLayout.SwipeListener
|
|
public void a(SwipeLayout swipeLayout) {
|
|
if (SwipeItemMangerImpl.this.a == Attributes$Mode.Single) {
|
|
SwipeItemMangerImpl.this.a(swipeLayout);
|
|
}
|
|
}
|
|
|
|
@Override // com.daimajia.swipe.SwipeLayout.SwipeListener
|
|
public void c(SwipeLayout swipeLayout) {
|
|
if (SwipeItemMangerImpl.this.a == Attributes$Mode.Multiple) {
|
|
SwipeItemMangerImpl.this.c.add(Integer.valueOf(this.a));
|
|
return;
|
|
}
|
|
SwipeItemMangerImpl.this.a(swipeLayout);
|
|
SwipeItemMangerImpl.this.b = this.a;
|
|
}
|
|
|
|
@Override // com.daimajia.swipe.SwipeLayout.SwipeListener
|
|
public void d(SwipeLayout swipeLayout) {
|
|
if (SwipeItemMangerImpl.this.a == Attributes$Mode.Multiple) {
|
|
SwipeItemMangerImpl.this.c.remove(Integer.valueOf(this.a));
|
|
} else {
|
|
SwipeItemMangerImpl.this.b = -1;
|
|
}
|
|
}
|
|
|
|
public void a(int i) {
|
|
this.a = i;
|
|
}
|
|
}
|
|
|
|
public void a(Attributes$Mode attributes$Mode) {
|
|
this.a = attributes$Mode;
|
|
this.c.clear();
|
|
this.d.clear();
|
|
this.b = -1;
|
|
}
|
|
|
|
public int a(int i) {
|
|
SpinnerAdapter spinnerAdapter = this.e;
|
|
if (spinnerAdapter != null) {
|
|
return ((SwipeAdapterInterface) spinnerAdapter).a(i);
|
|
}
|
|
Object obj = this.f;
|
|
if (obj != null) {
|
|
return ((SwipeAdapterInterface) obj).a(i);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public void a(SwipeLayout swipeLayout) {
|
|
for (SwipeLayout swipeLayout2 : this.d) {
|
|
if (swipeLayout2 != swipeLayout) {
|
|
swipeLayout2.a();
|
|
}
|
|
}
|
|
}
|
|
}
|