pr fixes
This commit is contained in:
parent
05ed6b38b3
commit
58101263c3
1 changed files with 34 additions and 10 deletions
|
@ -3,11 +3,15 @@ package net.osmand.plus;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -68,16 +72,22 @@ public class GpxSelectionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreSelectedGpxFiles() {
|
public void restoreSelectedGpxFiles() {
|
||||||
if (!selectedGpxFilesBackUp.isEmpty()) {
|
for (Entry<GPXFile, Long> gpxEntry : selectedGpxFilesBackUp.entrySet()) {
|
||||||
for(Map.Entry<GPXFile, Long> gpx : selectedGpxFilesBackUp.entrySet()) {
|
if (!Algorithms.isEmpty(gpxEntry.getKey().path)) {
|
||||||
LOG.debug("file path: " + gpx.getKey().path);
|
final File file = new File(gpxEntry.getKey().path);
|
||||||
if (!Algorithms.isEmpty(gpx.getKey().path)) {
|
if (file.exists() && !file.isDirectory()) {
|
||||||
File file = new File(gpx.getKey().path);
|
if (file.lastModified() > gpxEntry.getValue()) {
|
||||||
if (file.exists() && !file.isDirectory()) {
|
try {
|
||||||
if (file.lastModified() > gpx.getValue()) {
|
GPXFile reloadedFile = new LoadGpxFileInBackground(file).execute().get();
|
||||||
GPXUtilities.loadGPXFile(file);
|
if (reloadedFile != null) {
|
||||||
|
selectGpxFile(reloadedFile, true, false);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
selectGpxFile(gpx.getKey(), true, false);
|
|
||||||
|
} else {
|
||||||
|
selectGpxFile(gpxEntry.getKey(), true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +95,20 @@ public class GpxSelectionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class LoadGpxFileInBackground extends AsyncTask<Void, Void, GPXFile> {
|
||||||
|
|
||||||
|
File fileToLoad;
|
||||||
|
|
||||||
|
LoadGpxFileInBackground(File fileToLoad) {
|
||||||
|
this.fileToLoad = fileToLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GPXFile doInBackground(Void... voids) {
|
||||||
|
return GPXUtilities.loadGPXFile(fileToLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isShowingAnyGpxFiles() {
|
public boolean isShowingAnyGpxFiles() {
|
||||||
return !selectedGPXFiles.isEmpty();
|
return !selectedGPXFiles.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -477,7 +501,7 @@ public class GpxSelectionHelper {
|
||||||
if (gpx.error != null) {
|
if (gpx.error != null) {
|
||||||
save = true;
|
save = true;
|
||||||
} else if(obj.has(BACKUP)) {
|
} else if(obj.has(BACKUP)) {
|
||||||
selectedGpxFilesBackUp.put(gpx, System.currentTimeMillis());
|
selectedGpxFilesBackUp.put(gpx, gpx.modifiedTime);
|
||||||
} else {
|
} else {
|
||||||
selectGpxFile(gpx, true, false, true, selectedByUser, false);
|
selectGpxFile(gpx, true, false, true, selectedByUser, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue