diff --git a/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java b/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java index c053ab4..1c3fda9 100644 --- a/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java +++ b/android/src/main/java/com/reactnativecommunity/imageeditor/ImageEditorModule.java @@ -97,7 +97,6 @@ public class ImageEditorModule extends ReactContextBaseJavaModule { public ImageEditorModule(ReactApplicationContext reactContext) { super(reactContext); - new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @Override @@ -110,49 +109,6 @@ public Map getConstants() { return Collections.emptyMap(); } - @Override - public void onCatalystInstanceDestroy() { - new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - - /** - * Asynchronous task that cleans up cache dirs (internal and, if available, external) of cropped - * image files. This is run when the catalyst instance is being destroyed (i.e. app is shutting - * down) and when the module is instantiated, to handle the case where the app crashed. - */ - private static class CleanTask extends GuardedAsyncTask { - private final Context mContext; - - private CleanTask(ReactContext context) { - super(context); - mContext = context; - } - - @Override - protected void doInBackgroundGuarded(Void... params) { - cleanDirectory(mContext.getCacheDir()); - File externalCacheDir = mContext.getExternalCacheDir(); - if (externalCacheDir != null) { - cleanDirectory(externalCacheDir); - } - } - - private void cleanDirectory(File directory) { - File[] toDelete = directory.listFiles( - new FilenameFilter() { - @Override - public boolean accept(File dir, String filename) { - return filename.startsWith(TEMP_FILE_PREFIX); - } - }); - if (toDelete != null) { - for (File file: toDelete) { - file.delete(); - } - } - } - } - /** * Crop an image. If all goes well, the promise will be resolved with the file:// URI of * the new image as the only argument. This is a temporary file - consider using