content: 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 okhttp3.HttpUrl;
  
  public class SimpleCursorAdapter extends ResourceCursorAdapter {
      private CursorToStringConverter mCursorToStringConverter;
      protected int[] mFrom;
      String[] mOriginalFrom;
      private int mStringConversionColumn = -1;
      protected int[] mTo;
      private ViewBinder mViewBinder;
  
      public interface CursorToStringConverter {
          CharSequence convertToString(Cursor cursor);
      }
  
      public interface ViewBinder {
          boolean setViewValue(View view, Cursor cursor, int i);
      }
  
      @Deprecated
      public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
          super(context, layout, c);
          this.mTo = to;
          this.mOriginalFrom = from;
          findColumns(c, from);
      }
  
      public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
          super(context, layout, c, flags);
          this.mTo = to;
          this.mOriginalFrom = from;
          findColumns(c, from);
      }
  
      private void findColumns(Cursor c, String[] from) {
          if (c != null) {
              int length = from.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] = c.getColumnIndexOrThrow(from[i]);
              }
              return;
          }
          this.mFrom = null;
      }
  
      public void bindView(View view, Context context, Cursor cursor) {
          ViewBinder viewBinder = this.mViewBinder;
          int length = this.mTo.length;
          int[] iArr = this.mFrom;
          int[] iArr2 = this.mTo;
          for (int i = 0; i < length; i++) {
              View findViewById = view.findViewById(iArr2[i]);
              if (findViewById != null) {
                  boolean z = false;
                  if (viewBinder != null) {
                      z = viewBinder.setViewValue(findViewById, cursor, iArr[i]);
                  }
                  if (z) {
                      continue;
                  } else {
                      String string = cursor.getString(iArr[i]);
                      if (string == null) {
                          string = HttpUrl.FRAGMENT_ENCODE_SET;
                      }
                      if (findViewById instanceof TextView) {
                          setViewText((TextView) findViewById, string);
                      } else if (findViewById instanceof ImageView) {
                          setViewImage((ImageView) findViewById, string);
                      } else {
                          throw new IllegalStateException(findViewById.getClass().getName() + " is not a " + " view that can be bounds by this SimpleCursorAdapter");
                      }
                  }
              }
          }
      }
  
      public void changeCursorAndColumns(Cursor c, String[] from, int[] to) {
          this.mOriginalFrom = from;
          this.mTo = to;
          findColumns(c, from);
          super.changeCursor(c);
      }
  
      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 stringConversionColumn) {
          this.mStringConversionColumn = stringConversionColumn;
      }
  
      public void setViewBinder(ViewBinder viewBinder) {
          this.mViewBinder = viewBinder;
      }
  
      public void setViewImage(ImageView v, String value) {
          try {
              v.setImageResource(Integer.parseInt(value));
          } catch (NumberFormatException e) {
              v.setImageURI(Uri.parse(value));
          }
      }
  
      public void setViewText(TextView v, String text) {
          v.setText(text);
      }
  
      public Cursor swapCursor(Cursor c) {
          findColumns(c, this.mOriginalFrom);
          return super.swapCursor(c);
      }
  }
  