如果SKMaps文件夹不存在,并且这是它的打算方式,SKPrepareMapTextureThread只会复制文件,因为地图资源的解压缩需要相当长的时间,并且只能执行一次。 要更新样式,将需要一个解决方法:
1)从映射资源路径中删除文件.installed.txt并调用SKPrepareMapTextureThread,以便资源从资产中恢复。虽然这是最简单的方法,它也是最消耗时间:
2)更优化的方法是编写一个程序,随着新一个
copyFile(new File("path/daystyle.json"), new File("mapResourcesDirPath/SKMaps/daystyle/daystyle.json"));
...
public static void copyFile(File sourceFile, File destFile) throws IOException {
if(!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
// previous code: destination.transferFrom(source, 0, source.size());
// to avoid infinite loops, should be:
long count = 0;
long size = source.size();
while((count += destination.transferFrom(source, count, size-count))<size);
}
finally {
if(source != null) {
source.close();
}
if(destination != null) {
destination.close();
}
}
}
取代旧的风格,我们我们正在研究它 - 我们将回到开发团队的答案 – SylviA 2015-02-27 09:52:46