package io.happie.cordovaCamera;

import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;

public class HappieCameraJSON {

    private static AtomicInteger ACTIVE_PROCESSES;

    public static void INITIALZIE_ACTIVE_PROCESSES(){
        ACTIVE_PROCESSES = new AtomicInteger(0);
    }

    public static void INCREMENT_ACTIVE_PROCESSES(){
        ACTIVE_PROCESSES.incrementAndGet();
    }

    public static void DECREMENT_ACTIVE_PROCESSES(){
        ACTIVE_PROCESSES.decrementAndGet();
    }

    public static int GET_ACTIVE_PROCESSES(){
        if(ACTIVE_PROCESSES == null){
            ACTIVE_PROCESSES = new AtomicInteger(0);
        }
        return ACTIVE_PROCESSES.intValue();
    }

    public static int GET_TOTAL_IMAGES(){
        File mediaDir = new File(HappieCamera.filesDir + "/media/" + HappieCamera.userId + "/" + HappieCamera.jnId);
        File[] mediaFiles = mediaDir.listFiles();
        int total = 0;
        for(File file : mediaFiles){
            String name = file.getName();
            if(!name.contains(".json")) total++;
        }
        return total - 1;
    }
}
@@ -738,24 +738,41 @@
 L_IMAGES()%7B%0A
+        try%7B%0A    
         File
@@ -880,24 +880,28 @@
 d);%0A        
+  
+  
 File%5B%5D media
@@ -938,16 +938,20 @@
         
+    
 int tota
@@ -957,16 +957,20 @@
 al = 0;%0A
+    
         
@@ -1010,16 +1010,20 @@
         
+    
 String n
@@ -1040,24 +1040,28 @@
 .getName();%0A
+    
             
@@ -1097,34 +1097,42 @@
 otal++;%0A        
+ 
-%7D%0A
+   %7D%0A    
         return t
@@ -1145,11 +1145,117 @@
  1;%0A
+        %7D%0A        catch(Exception e)%7B%0A            RaygunClient.send(e);%0A            return -1;%0A        %7D%0A
     %7D%0A%7D
+%0A

update try catch