]> www.infradead.org Git - users/mchehab/andors-trail.git/commitdiff
Create a ".nomedia" file in the same directory as the worldmap png files, to prevent...
authorOskar Wiksten <oskar.wiksten@gmail.com>
Sun, 7 Oct 2012 15:44:45 +0000 (17:44 +0200)
committerOskar Wiksten <oskar.wiksten@gmail.com>
Sun, 7 Oct 2012 15:44:45 +0000 (17:44 +0200)
AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/WorldMapController.java

index d71277ac8429292004d4325ae6e219d8d7815033..c3ab96ee917f1cf1f68f282dd8559c8f2b851cf1 100644 (file)
@@ -74,15 +74,15 @@ public final class WorldMapController {
        }
 
        private static void updateCachedBitmap(PredefinedMap map, MapRenderer renderer) throws IOException {
-
+               ensureWorldmapDirectoryExists();
+       
                File file = getFileForMap(map);
        if (file.exists()) {
                if (map.lastVisitVersion == AndorsTrailApplication.CURRENT_VERSION) return;
        }
                
                Bitmap image = renderer.drawMap();
-               ensureWorldmapDirectoryExists();
-       FileOutputStream fos = new FileOutputStream(file);
+               FileOutputStream fos = new FileOutputStream(file);
        image.compress(Bitmap.CompressFormat.PNG, 70, fos);
         fos.flush();
         fos.close();
@@ -136,12 +136,15 @@ public final class WorldMapController {
            }
        }
        
-    private static void ensureWorldmapDirectoryExists() {
+    private static void ensureWorldmapDirectoryExists() throws IOException {
        File root = Environment.getExternalStorageDirectory();
                File dir = new File(root, Constants.FILENAME_SAVEGAME_DIRECTORY);
                if (!dir.exists()) dir.mkdir();
                dir = new File(dir, Constants.FILENAME_WORLDMAP_DIRECTORY);
                if (!dir.exists()) dir.mkdir();
+               
+               File noMediaFile = new File(dir, ".nomedia");
+               if (!noMediaFile.exists()) noMediaFile.createNewFile();
     }
     public static File getFileForMap(PredefinedMap map) { return getFileForMap(map.name); }
     public static File getFileForMap(String mapName) {