use of com.peterlaurence.trekadvisor.util.ZipTask in project TrekAdvisor by peterLaurence.
the class Map method zip.
/**
* Archives the map. <p>
* Creates a zip file named with this {@link Map} name and the date. This file is placed in the
* parent folder of the {@link Map}.
*
* @param listener The {@link com.peterlaurence.trekadvisor.util.ZipTask.ZipProgressionListener}.
*/
public void zip(ZipTask.ZipProgressionListener listener) {
/* Generate an output zip file named with the map name and the date */
Date date = new Date();
DateFormat dateFormat = new SimpleDateFormat("dd\\MM\\yyyy-HH:mm:ss", Locale.ENGLISH);
String zipFileName = getName() + "-" + dateFormat.format(date) + ".zip";
/* By default and for instance, the archive is placed in the parent folder of the map */
File zipDirectory = mConfigFile.getParentFile().getParentFile();
File outputFile = new File(zipDirectory, zipFileName);
try {
if (!outputFile.createNewFile()) {
listener.onZipError();
}
} catch (IOException e) {
Log.e(TAG, Tools.stackTraceToString(e));
listener.onZipError();
}
ZipTask zipTask = new ZipTask(mConfigFile.getParentFile(), outputFile, listener);
zipTask.execute();
}
Aggregations