package fr.bamlab.rncameraroll;

import android.content.Context;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.provider.MediaStore;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by almouro on 11/12/15.
 */
class CameraImagesManager {
    private static final String CAMERA_IMAGE_BUCKET_NAME =
            Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera";
    private static final String CAMERA_IMAGE_BUCKET_ID = getBucketId(CAMERA_IMAGE_BUCKET_NAME);

    private static String getBucketId(String path) {
        return String.valueOf(path.toLowerCase().hashCode());
    }

    public static List<CameraImage> getCameraImages(Context context, int count, String afterCursor) {
        final String[] projection = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
        final String selection = MediaStore.Images.Media.BUCKET_ID + " = ?";
        final String[] selectionArgs = {CAMERA_IMAGE_BUCKET_ID};
        final Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                null,
                null,
                null,
                null
        );

        ArrayList<CameraImage> cameraImagePaths = new ArrayList<>();

        if (cursor == null) {
            return cameraImagePaths;
        }

        boolean foundAfter = false;
        if (cursor.moveToLast()) {
            final int dataColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            do {
                String localPath = cursor.getString(dataColumn);

                if (!afterCursor.isEmpty() && !foundAfter) {
                    if (afterCursor.equals(localPath)) {
                        foundAfter = true;
                    }
                    continue; // Skip until we get to the first one
                }

                cameraImagePaths.add(new CameraImage(localPath));
            } while (cursor.moveToPrevious() && cameraImagePaths.size() < count);
        }
        cursor.close();

        return cameraImagePaths;
    }
}

@@ -787,247 +787,8 @@
 ) %7B%0A
-        final String%5B%5D projection = %7BMediaStore.Images.Media.DATA, MediaStore.Images.Media._ID%7D;%0A        final String selection = MediaStore.Images.Media.BUCKET_ID + %22 = ?%22;%0A        final String%5B%5D selectionArgs = %7BCAMERA_IMAGE_BUCKET_ID%7D;%0A
     

Remove unused variables