package o; import android.content.Context; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; import java.util.List; /* loaded from: classes.dex */ public abstract class BjL extends WYJ { public List a; public Context c; private SparseArray g = new SparseArray<>(); private boolean b = true; private boolean d = false; private boolean e = true; protected abstract View anU_(ViewGroup viewGroup); protected abstract void c(View view, int i); @Override // o.WYJ public int getItemPosition(Object obj) { return -2; } @Override // o.WYJ public boolean isViewFromObject(View view, Object obj) { return view == obj; } public BjL(Context context, List list) { this.c = context; c(list); } public final void c(List list) { this.g = new SparseArray<>(); this.a = list; this.b = list.size() > 1; notifyDataSetChanged(); } @Override // o.WYJ public Object instantiateItem(ViewGroup viewGroup, int i) { View view; if (this.e && this.b) { i = d(i); } if (this.g.get(0, null) == null) { view = anU_(viewGroup); } else { view = this.g.get(0); this.g.remove(0); } c(view, i); viewGroup.addView(view); return view; } @Override // o.WYJ public void destroyItem(ViewGroup viewGroup, int i, Object obj) { if (this.e && this.b) { d(i); } View view = (View) obj; viewGroup.removeView(view); if (this.d) { return; } this.g.put(0, view); } @Override // o.WYJ public void notifyDataSetChanged() { this.d = true; super.notifyDataSetChanged(); this.d = false; } @Override // o.WYJ public int getCount() { List list = this.a; int size = list != null ? list.size() : 0; return (this.e && this.b) ? size + 2 : size; } private int d(int i) { if (!this.e || !this.b) { return i; } if (i == 0) { return getCount() - 3; } if (i > getCount() - 2) { return 0; } return i - 1; } public final int c() { if (this.e) { List list = this.a; if (list == null) { return 0; } return list.size(); } if (this.a != null) { return r0.size() - 1; } return 0; } }