예제 #1
0
 private static void updatePath(
     File root, HashMap<Integer, Entry> entries, WidgetDatabaseHelper dbHelper) {
   File[] files = root.listFiles();
   if (files != null) {
     for (File file : files) {
       if (file.isDirectory() && !entries.isEmpty()) {
         String path = file.getAbsolutePath();
         String oldPath = OLD_EXT_PATH + path.substring(RELATIVE_PATH_START);
         int oldBucketId = GalleryUtils.getBucketId(oldPath);
         Entry entry = entries.remove(oldBucketId);
         if (entry != null) {
           int newBucketId = GalleryUtils.getBucketId(path);
           String newAlbumPath =
               Path.fromString(entry.albumPath).getParent().getChild(newBucketId).toString();
           Log.d(TAG, "migrate from " + entry.albumPath + " to " + newAlbumPath);
           entry.albumPath = newAlbumPath;
           dbHelper.updateEntry(entry);
         }
         updatePath(file, entries, dbHelper); // recursion
       }
     }
   }
 }