214 lines
5.9 KiB
Java
214 lines
5.9 KiB
Java
package o;
|
|
|
|
import android.content.Context;
|
|
import android.database.ContentObserver;
|
|
import android.database.Cursor;
|
|
import android.database.DataSetObserver;
|
|
import android.os.Handler;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.BaseAdapter;
|
|
import android.widget.Filter;
|
|
import android.widget.FilterQueryProvider;
|
|
import android.widget.Filterable;
|
|
import o.yQj;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class BEC extends BaseAdapter implements Filterable, yQj.LWm {
|
|
private Context a;
|
|
private FilterQueryProvider f;
|
|
private yQj i;
|
|
private boolean e = true;
|
|
public Cursor d = null;
|
|
protected boolean c = false;
|
|
private int h = -1;
|
|
private Sts b = new Sts(this);
|
|
private DataSetObserver j = new IeS(this);
|
|
|
|
@Override // android.widget.BaseAdapter, android.widget.Adapter
|
|
public boolean hasStableIds() {
|
|
return true;
|
|
}
|
|
|
|
public abstract void wJ_(View view, Cursor cursor);
|
|
|
|
public abstract View wV_(Context context, Cursor cursor, ViewGroup viewGroup);
|
|
|
|
public BEC(Context context) {
|
|
this.a = context;
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public int getCount() {
|
|
Cursor cursor;
|
|
if (!this.c || (cursor = this.d) == null) {
|
|
return 0;
|
|
}
|
|
return cursor.getCount();
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public Object getItem(int i) {
|
|
Cursor cursor;
|
|
if (!this.c || (cursor = this.d) == null) {
|
|
return null;
|
|
}
|
|
cursor.moveToPosition(i);
|
|
return this.d;
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public long getItemId(int i) {
|
|
Cursor cursor;
|
|
if (this.c && (cursor = this.d) != null && cursor.moveToPosition(i)) {
|
|
return this.d.getLong(this.h);
|
|
}
|
|
return 0L;
|
|
}
|
|
|
|
@Override // android.widget.Adapter
|
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
|
if (!this.c) {
|
|
throw new IllegalStateException("this should only be called when the cursor is valid");
|
|
}
|
|
if (!this.d.moveToPosition(i)) {
|
|
throw new IllegalStateException("couldn't move cursor to position ".concat(String.valueOf(i)));
|
|
}
|
|
if (view == null) {
|
|
view = wV_(this.a, this.d, viewGroup);
|
|
}
|
|
wJ_(view, this.d);
|
|
return view;
|
|
}
|
|
|
|
@Override // android.widget.BaseAdapter, android.widget.SpinnerAdapter
|
|
public View getDropDownView(int i, View view, ViewGroup viewGroup) {
|
|
if (!this.c) {
|
|
return null;
|
|
}
|
|
this.d.moveToPosition(i);
|
|
if (view == null) {
|
|
view = wU_(this.a, this.d, viewGroup);
|
|
}
|
|
wJ_(view, this.d);
|
|
return view;
|
|
}
|
|
|
|
public View wU_(Context context, Cursor cursor, ViewGroup viewGroup) {
|
|
return wV_(context, cursor, viewGroup);
|
|
}
|
|
|
|
@Override // o.yQj.LWm
|
|
public void wQ_(Cursor cursor) {
|
|
Cursor cursor2 = this.d;
|
|
if (cursor == cursor2) {
|
|
cursor2 = null;
|
|
} else {
|
|
if (cursor2 != null) {
|
|
Sts sts = this.b;
|
|
if (sts != null) {
|
|
cursor2.unregisterContentObserver(sts);
|
|
}
|
|
DataSetObserver dataSetObserver = this.j;
|
|
if (dataSetObserver != null) {
|
|
cursor2.unregisterDataSetObserver(dataSetObserver);
|
|
}
|
|
}
|
|
this.d = cursor;
|
|
if (cursor != null) {
|
|
Sts sts2 = this.b;
|
|
if (sts2 != null) {
|
|
cursor.registerContentObserver(sts2);
|
|
}
|
|
DataSetObserver dataSetObserver2 = this.j;
|
|
if (dataSetObserver2 != null) {
|
|
cursor.registerDataSetObserver(dataSetObserver2);
|
|
}
|
|
this.h = cursor.getColumnIndexOrThrow("_id");
|
|
this.c = true;
|
|
notifyDataSetChanged();
|
|
} else {
|
|
this.h = -1;
|
|
this.c = false;
|
|
notifyDataSetInvalidated();
|
|
}
|
|
}
|
|
if (cursor2 != null) {
|
|
cursor2.close();
|
|
}
|
|
}
|
|
|
|
@Override // o.yQj.LWm
|
|
public CharSequence wR_(Cursor cursor) {
|
|
return cursor == null ? "" : cursor.toString();
|
|
}
|
|
|
|
@Override // o.yQj.LWm
|
|
public Cursor wT_(CharSequence charSequence) {
|
|
return this.d;
|
|
}
|
|
|
|
@Override // android.widget.Filterable
|
|
public Filter getFilter() {
|
|
if (this.i == null) {
|
|
this.i = new yQj(this);
|
|
}
|
|
return this.i;
|
|
}
|
|
|
|
protected final void e() {
|
|
Cursor cursor;
|
|
if (!this.e || (cursor = this.d) == null || cursor.isClosed()) {
|
|
return;
|
|
}
|
|
this.c = this.d.requery();
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
class Sts extends ContentObserver {
|
|
final BEC d;
|
|
|
|
@Override // android.database.ContentObserver
|
|
public final boolean deliverSelfNotifications() {
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
Sts(BEC bec) {
|
|
super(new Handler());
|
|
this.d = bec;
|
|
}
|
|
|
|
@Override // android.database.ContentObserver
|
|
public final void onChange(boolean z) {
|
|
this.d.e();
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
class IeS extends DataSetObserver {
|
|
final BEC d;
|
|
|
|
IeS(BEC bec) {
|
|
this.d = bec;
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public final void onChanged() {
|
|
this.d.c = true;
|
|
this.d.notifyDataSetChanged();
|
|
}
|
|
|
|
@Override // android.database.DataSetObserver
|
|
public final void onInvalidated() {
|
|
this.d.c = false;
|
|
this.d.notifyDataSetInvalidated();
|
|
}
|
|
}
|
|
|
|
@Override // o.yQj.LWm
|
|
public final Cursor wS_() {
|
|
return this.d;
|
|
}
|
|
}
|