alexandroid/decompiled/jadx/sources/androidx/cursoradapter/widget/SimpleCursorAdapter.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

156 lines
5.5 KiB
Java

package androidx.cursoradapter.widget;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.RestrictTo;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes13.dex */
public class SimpleCursorAdapter extends ResourceCursorAdapter {
private CursorToStringConverter mCursorToStringConverter;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
protected int[] mFrom;
String[] mOriginalFrom;
private int mStringConversionColumn;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
protected int[] mTo;
private ViewBinder mViewBinder;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public interface CursorToStringConverter {
CharSequence convertToString(Cursor cursor);
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public interface ViewBinder {
boolean setViewValue(View view, Cursor cursor, int i);
}
@Deprecated
public SimpleCursorAdapter(Context context, int i, Cursor cursor, String[] strArr, int[] iArr) {
super(context, i, cursor);
this.mStringConversionColumn = -1;
this.mTo = iArr;
this.mOriginalFrom = strArr;
findColumns(cursor, strArr);
}
private void findColumns(Cursor cursor, String[] strArr) {
if (cursor == null) {
this.mFrom = null;
return;
}
int length = strArr.length;
int[] iArr = this.mFrom;
if (iArr == null || iArr.length != length) {
this.mFrom = new int[length];
}
for (int i = 0; i < length; i++) {
this.mFrom[i] = cursor.getColumnIndexOrThrow(strArr[i]);
}
}
@Override // androidx.cursoradapter.widget.CursorAdapter
public void bindView(View view, Context context, Cursor cursor) {
ViewBinder viewBinder = this.mViewBinder;
int[] iArr = this.mTo;
int length = iArr.length;
int[] iArr2 = this.mFrom;
for (int i = 0; i < length; i++) {
View findViewById = view.findViewById(iArr[i]);
if (findViewById != null) {
if (viewBinder != null ? viewBinder.setViewValue(findViewById, cursor, iArr2[i]) : false) {
continue;
} else {
String string = cursor.getString(iArr2[i]);
if (string == null) {
string = "";
}
if (findViewById instanceof TextView) {
setViewText((TextView) findViewById, string);
} else {
if (!(findViewById instanceof ImageView)) {
Single$$ExternalSyntheticBUOutline0.m$2(findViewById.getClass().getName().concat(" is not a view that can be bounds by this SimpleCursorAdapter"));
return;
}
setViewImage((ImageView) findViewById, string);
}
}
}
}
}
public void changeCursorAndColumns(Cursor cursor, String[] strArr, int[] iArr) {
this.mOriginalFrom = strArr;
this.mTo = iArr;
findColumns(cursor, strArr);
super.changeCursor(cursor);
}
@Override // androidx.cursoradapter.widget.CursorAdapter, androidx.cursoradapter.widget.CursorFilter.CursorFilterClient
public CharSequence convertToString(Cursor cursor) {
CursorToStringConverter cursorToStringConverter = this.mCursorToStringConverter;
if (cursorToStringConverter != null) {
return cursorToStringConverter.convertToString(cursor);
}
int i = this.mStringConversionColumn;
return i > -1 ? cursor.getString(i) : super.convertToString(cursor);
}
public CursorToStringConverter getCursorToStringConverter() {
return this.mCursorToStringConverter;
}
public int getStringConversionColumn() {
return this.mStringConversionColumn;
}
public ViewBinder getViewBinder() {
return this.mViewBinder;
}
public void setCursorToStringConverter(CursorToStringConverter cursorToStringConverter) {
this.mCursorToStringConverter = cursorToStringConverter;
}
public void setStringConversionColumn(int i) {
this.mStringConversionColumn = i;
}
public void setViewBinder(ViewBinder viewBinder) {
this.mViewBinder = viewBinder;
}
public void setViewImage(ImageView imageView, String str) {
try {
imageView.setImageResource(Integer.parseInt(str));
} catch (NumberFormatException unused) {
imageView.setImageURI(Uri.parse(str));
}
}
public void setViewText(TextView textView, String str) {
textView.setText(str);
}
@Override // androidx.cursoradapter.widget.CursorAdapter
public Cursor swapCursor(Cursor cursor) {
findColumns(cursor, this.mOriginalFrom);
return super.swapCursor(cursor);
}
public SimpleCursorAdapter(Context context, int i, Cursor cursor, String[] strArr, int[] iArr, int i2) {
super(context, i, cursor, i2);
this.mStringConversionColumn = -1;
this.mTo = iArr;
this.mOriginalFrom = strArr;
findColumns(cursor, strArr);
}
}