Пример #1
0
 @Override
 protected void findPosition(ImageData data) {
   if (data.position == -1) {
     if (data.cursor == null) {
       openCursor(data);
     }
     if (data.cursor != null) {
       int dataIndex = data.cursor.getColumnIndex(MediaStore.Images.Media.DATA);
       data.cursor.moveToPosition(-1);
       while (data.position == -1 && data.cursor.moveToNext()) {
         String url = data.cursor.getString(dataIndex);
         if (url != null && url.equals(data.url)) {
           data.position = data.cursor.getPosition();
         }
       }
       if (data.position == -1) {
         // oops!  The image isn't in this album. How did we get here?
         data.position = INVALID;
       }
     }
   }
 }
Пример #2
0
  @Override
  protected ImageData unpackImageData(Cursor cursor, ImageData data) {
    if (data == null) {
      data = new ImageData();
    }
    int dataIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
    int orientationIndex = cursor.getColumnIndex(MediaStore.Images.Media.ORIENTATION);
    int bucketIndex = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID);

    data.url = cursor.getString(dataIndex);
    data.albumId = cursor.getString(bucketIndex);
    data.position = UNINITIALIZED;
    data.cursor = null;
    data.orientation = cursor.getInt(orientationIndex);

    return data;
  }