Github user sgrebnov commented on a diff in the pull request:

    
https://github.com/apache/cordova-plugin-camera/pull/115#discussion_r39375449
  
    --- Diff: src/android/CameraLauncher.java ---
    @@ -983,12 +983,39 @@ private Cursor queryImgDB(Uri contentStore) {
          * @param newImage
          */
         private void cleanup(int imageType, Uri oldImage, Uri newImage, Bitmap 
bitmap) {
    +        Uri contentStore = whichContentStore();
    +        Cursor cursor = queryImgDB(contentStore);
    +        int currentNumOfImages = cursor.getCount();
    +        int diff = currentNumOfImages - numPics;
    +        int id;
    +
             if (bitmap != null) {
                 bitmap.recycle();
             }
     
    -        // Clean up initial camera-written image file.
    -        (new 
File(FileHelper.stripFileProtocol(oldImage.toString()))).delete();
    +        // Check for camera-written image files that are not the chosen 
image
    +        // Gets rid of inital camera-written image file as well as any 
retakes
    +        // Addresses issue CD-9490
    +        if (currentNumOfImages > 0 && diff > 0) {
    +            cursor.moveToLast();
    +            id = 
Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID)));
    +
    +            if (imageType == FILE_URI) {
    +                id--;
    +                for (int i = diff; i > 0; i--) {
    +                    Uri uri = Uri.parse(contentStore + "/" + id);
    +                    
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
    +                    id--;
    +                }
    +            } else {
    +                for (int i = diff; i > 0; i--) {
    --- End diff --
    
    looks like this `for` loop is the same as above; what if we keep only one 
loop, for example
    
    ```
    if (imageType == FILE_URI) {
        id--;
    }
    
    for (int i = diff; i > 0; i--) {
        Uri uri = Uri.parse(contentStore + "/" + id);
        this.cordova.getActivity().getContentResolver().delete(uri, null, null);
        id--;
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to