use of com.junjunguo.pocketmaps.downloader.MapUnzip in project PocketMaps by junjunguo.
the class DownloadMapActivity method unzipBg.
private static void unzipBg(final MyMap myMap, final MyDownloadAdapter dlAdapter) {
log("Unzipping map: " + myMap.getMapName());
myMap.setStatus(MyMap.DlStatus.Unzipping);
refreshMapEntry(myMap, dlAdapter);
new AsyncTask<URL, Integer, MyMap>() {
String errMsg = null;
@Override
protected MyMap doInBackground(URL... params) {
File ghzFile = MyMap.getMapFile(myMap, MyMap.MapFileType.DlMapFile);
if (ghzFile.exists()) {
try {
new MapUnzip().unzip(ghzFile.getPath(), new File(Variable.getVariable().getMapsFolder(), myMap.getMapName() + "-gh").getAbsolutePath());
} catch (IOException e) {
errMsg = "Error unpacking map: " + myMap.getMapName();
}
} else {
errMsg = "Error, missing downloaded file: " + ghzFile.getPath();
}
clearDlFile(myMap);
return myMap;
}
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(MyMap myMaps) {
super.onPostExecute(myMaps);
refreshMapEntry(myMap, dlAdapter);
if (errMsg != null) {
File idFile = MyMap.getMapFile(myMap, MyMap.MapFileType.DlIdFile);
IO.writeToFile("" + MyMap.DlStatus.Error + ": " + errMsg, idFile, false);
myMap.setStatus(MyMap.DlStatus.Error);
return;
}
Variable.getVariable().getRecentDownloadedMaps().add(myMap);
MyMap.setVersionCompatible(myMap.getMapName(), myMap);
myMap.setStatus(MyMap.DlStatus.Complete);
}
}.execute();
}
Aggregations