Fix kmz file import

This commit is contained in:
Vitaliy 2020-06-01 15:47:01 +03:00
parent 9fd029b089
commit 48dbb64d09

View file

@ -71,6 +71,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import static android.app.Activity.RESULT_OK;
@ -314,7 +315,9 @@ public class ImportHelper {
} else if (fileName != null && fileName.endsWith(KMZ_SUFFIX)) {
try {
zis = new ZipInputStream(is);
zis.getNextEntry();
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.getName().endsWith(KML_SUFFIX)) {
final String result = Kml2Gpx.toGpx(zis);
if (result != null) {
try {
@ -323,6 +326,8 @@ public class ImportHelper {
return null;
}
}
}
}
} catch (Exception e) {
return null;
}
@ -418,7 +423,10 @@ public class ImportHelper {
is = app.getContentResolver().openInputStream(kmzFile);
if (is != null) {
zis = new ZipInputStream(is);
zis.getNextEntry();
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.getName().endsWith(KML_SUFFIX)) {
final String result = Kml2Gpx.toGpx(zis);
if (result != null) {
try {
@ -428,6 +436,8 @@ public class ImportHelper {
}
}
}
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {