Initial commit
This commit is contained in:
133
sources/com/daimajia/swipe/implments/SwipeItemMangerImpl.java
Normal file
133
sources/com/daimajia/swipe/implments/SwipeItemMangerImpl.java
Normal file
@@ -0,0 +1,133 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.daimajia.swipe.implments;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.daimajia.swipe.SwipeLayout;
|
||||
import com.daimajia.swipe.implments.SwipeItemMangerImpl;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SwipeItemRecyclerMangerImpl extends SwipeItemMangerImpl {
|
||||
public SwipeItemRecyclerMangerImpl(RecyclerView.Adapter adapter) {
|
||||
super(adapter);
|
||||
}
|
||||
|
||||
public void a(View view, int i) {
|
||||
int a = a(i);
|
||||
SwipeItemMangerImpl.OnLayoutListener onLayoutListener = new SwipeItemMangerImpl.OnLayoutListener(i);
|
||||
SwipeLayout swipeLayout = (SwipeLayout) view.findViewById(a);
|
||||
if (swipeLayout == null) {
|
||||
throw new IllegalStateException("can not find SwipeLayout in target view");
|
||||
}
|
||||
if (swipeLayout.getTag(a) != null) {
|
||||
SwipeItemMangerImpl.ValueBox valueBox = (SwipeItemMangerImpl.ValueBox) swipeLayout.getTag(a);
|
||||
valueBox.b.a(i);
|
||||
valueBox.a.a(i);
|
||||
valueBox.c = i;
|
||||
return;
|
||||
}
|
||||
SwipeItemMangerImpl.SwipeMemory swipeMemory = new SwipeItemMangerImpl.SwipeMemory(i);
|
||||
swipeLayout.a(swipeMemory);
|
||||
swipeLayout.a(onLayoutListener);
|
||||
swipeLayout.setTag(a, new SwipeItemMangerImpl.ValueBox(this, i, swipeMemory, onLayoutListener));
|
||||
this.d.add(swipeLayout);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user