]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
List files only once, also avoids a potential race condition.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 30 Oct 2016 00:00:49 +0000 (02:00 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 30 Oct 2016 00:00:49 +0000 (02:00 +0200)
src/com/hughes/android/dictionary/DictionaryApplication.java

index 5d1ca0ecc33d283f2668b940454d5669d6c81972..1e46f4b0c1adb87b8bd25e9d1d82768dfc7a7143 100644 (file)
@@ -406,7 +406,8 @@ public class DictionaryApplication extends Application {
         final File defaultDictDir = new File(Environment.getExternalStorageDirectory(), "quickDic");
         String dir = defaultDictDir.getAbsolutePath();
         File dictDir = new File(dir);
-        if (dictDir.isDirectory() && dictDir.list() != null && dictDir.list().length > 0) {
+        String[] fileList = dictDir.isDirectory() ? dictDir.list() : null;
+        if (fileList != null && fileList.length > 0) {
             return dir;
         }
         File efd = null;