diff --git a/src/ru/nsu/ccfit/zuev/osu/Config.java b/src/ru/nsu/ccfit/zuev/osu/Config.java index b4854ca00..39d4d437a 100644 --- a/src/ru/nsu/ccfit/zuev/osu/Config.java +++ b/src/ru/nsu/ccfit/zuev/osu/Config.java @@ -138,13 +138,13 @@ public static void loadConfig(final Context context) { soundVolume = prefs.getInt("soundvolume", 100) / 100f; bgmVolume = prefs.getInt("bgmvolume", 100) / 100f; cursorSize = prefs.getInt("cursorSize", 50) / 100f; - }catch(RuntimeException e) { // migrate to integers to prevent crash + }catch(RuntimeException e) { // use valid integer since this makes the game crash on android m prefs.edit() - .putInt("offset", Integer.parseInt(prefs.getString("offset", "0"))) - .putInt("bgbrightness", Integer.parseInt(prefs.getString("bgbrightness", "25"))) - .putInt("soundvolume", Integer.parseInt(prefs.getString("soundvolume", "100"))) - .putInt("bgmvolume", Integer.parseInt(prefs.getString("bgmvolume", "100"))) - .putInt("cursorSize", Integer.parseInt(prefs.getString("cursorSize", "50"))) + .putInt("offset", 0) + .putInt("bgbrightness", 25) + .putInt("soundvolume", 100) + .putInt("bgmvolume", 100) + .putInt("cursorSize", 50) .commit(); Config.loadConfig(context); } @@ -196,14 +196,6 @@ public static void loadConfig(final Context context) { comboColors[i - 1] = RGBColor.hex2Rgb(ColorPickerPreference.convertToRGB(prefs.getInt("combo" + i, 0xff000000))); } - // skins - File[] folders = FileUtils.listFiles(new File(skinTopPath), file -> file.isDirectory() && !file.getName().startsWith(".")); - skins = new HashMap(); - for(File folder : folders) { - skins.put(folder.getName(), folder.getPath()); - Debug.i("skins: " + folder.getName() + " - " + folder.getPath()); - } - // beatmaps DELETE_OSZ = prefs.getBoolean("deleteosz", true); SCAN_DOWNLOAD = prefs.getBoolean("scandownload", false); @@ -767,6 +759,15 @@ public static String getDefaultCorePath() { return defaultCorePath; } + public static void loadSkins() { + File[] folders = FileUtils.listFiles(new File(skinTopPath), file -> file.isDirectory() && !file.getName().startsWith(".")); + skins = new HashMap(); + for(File folder : folders) { + skins.put(folder.getName(), folder.getPath()); + Debug.i("skins: " + folder.getName() + " - " + folder.getPath()); + } + } + public static Map getSkins(){ return skins; } diff --git a/src/ru/nsu/ccfit/zuev/osu/MainActivity.java b/src/ru/nsu/ccfit/zuev/osu/MainActivity.java index d18684973..b9e36de84 100644 --- a/src/ru/nsu/ccfit/zuev/osu/MainActivity.java +++ b/src/ru/nsu/ccfit/zuev/osu/MainActivity.java @@ -309,6 +309,7 @@ public void run() { GlobalManager.getInstance().init(); analytics.logEvent(FirebaseAnalytics.Event.APP_OPEN, null); GlobalManager.getInstance().setLoadingProgress(50); + Config.loadSkins(); checkNewSkins(); checkNewBeatmaps(); if (!LibraryManager.getInstance().loadLibraryCache(MainActivity.this, true)) { diff --git a/src/ru/nsu/ccfit/zuev/osu/helper/FileUtils.java b/src/ru/nsu/ccfit/zuev/osu/helper/FileUtils.java index f7242b6ee..57674c433 100644 --- a/src/ru/nsu/ccfit/zuev/osu/helper/FileUtils.java +++ b/src/ru/nsu/ccfit/zuev/osu/helper/FileUtils.java @@ -6,6 +6,7 @@ import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.File; +import java.io.FileFilter; import java.io.FileNotFoundException; import java.io.IOException; @@ -176,11 +177,9 @@ public static File[] listFiles(File directory, String[] endsWithExtensions) { return null; } - public static File[] listFiles(File directory, FileUtilsFilter filter) { + public static File[] listFiles(File directory, FileFilter filter) { File[] filelist = null; - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { - filelist = directory.listFiles(pathname -> filter.accept(pathname)); - }else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { LinkedList cachedFiles = new LinkedList(); DirectoryStream.Filter directoryFilter = new DirectoryStream.Filter() { @Override @@ -196,12 +195,10 @@ public boolean accept(Path entry) { Debug.e("FileUtils.listFiles: " + err.getMessage(), err); } filelist = cachedFiles.toArray(new File[cachedFiles.size()]); + }else { + filelist = directory.listFiles(filter); } return filelist; } - public interface FileUtilsFilter { - boolean accept(File file); - } - }