[Android] No need to launch in threadpool, call already is

Geoffrey Métais git at videolan.org
Tue Jul 18 17:44:08 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jul 18 17:30:23 2017 +0200| [2453810f1021346a74938d181e089c5c959ec972] | committer: Geoffrey Métais

No need to launch in threadpool, call already is

> https://code.videolan.org/videolan/vlc-android/commit/2453810f1021346a74938d181e089c5c959ec972
---

 .../org/videolan/vlc/gui/helpers/AudioUtil.java    | 37 ++++++++++------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
index e2a5af729..2bd2acc4c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
@@ -131,28 +131,23 @@ public class AudioUtil {
     }
 
     @SuppressLint("NewApi")
+    @WorkerThread
     public static void prepareCacheFolder(final Context context) {
-        VLCApplication.runBackground(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    if (AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
-                        CACHE_DIR = context.getExternalCacheDir().getPath();
-                    else
-                        CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
-                } catch (Exception e) { // catch NPE thrown by getExternalCacheDir()
-                    CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
-                }
-                ART_DIR.set(CACHE_DIR + "/art/");
-                COVER_DIR.set(CACHE_DIR + "/covers/");
-//        PLAYLIST_DIR.set(CACHE_DIR + "/playlists/");
-                for(String path : Arrays.asList(ART_DIR.get(), COVER_DIR.get())) {
-                    File file = new File(path);
-                    if (!file.exists())
-                        file.mkdirs();
-                }
-            }
-        });
+        try {
+            if (AndroidDevices.hasExternalStorage() && context.getExternalCacheDir() != null)
+                CACHE_DIR = context.getExternalCacheDir().getPath();
+            else
+                CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
+        } catch (Exception e) { // catch NPE thrown by getExternalCacheDir()
+            CACHE_DIR = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + BuildConfig.APPLICATION_ID + "/cache";
+        }
+        ART_DIR.set(CACHE_DIR + "/art/");
+        COVER_DIR.set(CACHE_DIR + "/covers/");
+        for(String path : Arrays.asList(ART_DIR.get(), COVER_DIR.get())) {
+            File file = new File(path);
+            if (!file.exists())
+                file.mkdirs();
+        }
     }
 
     public static void clearCacheFolders() {



More information about the Android mailing list