Make updating wpt category names lazy
This commit is contained in:
parent
c2489ff440
commit
7f31a6861b
2 changed files with 4 additions and 30 deletions
|
@ -1,7 +1,5 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
|
@ -253,36 +251,9 @@ public class GPXDatabase {
|
|||
|
||||
if (oldVersion < 7) {
|
||||
db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_WPT_CATEGORY_NAMES + " TEXT");
|
||||
updateWptCategoryNames();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void updateWptCategoryNames() {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
if (db != null) {
|
||||
try {
|
||||
for (GpxDataItem item : getItems()) {
|
||||
GPXUtilities.GPXFile gpxFile = GPXUtilities.loadGPXFile(context, item.file);
|
||||
String fileName = getFileName(item.file);
|
||||
String fileDir = getFileDir(item.file);
|
||||
db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " +
|
||||
GPX_COL_WPT_CATEGORY_NAMES + " = ? " +
|
||||
" WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
|
||||
new Object[] { Algorithms.encodeStringSet(gpxFile.getWaypointCategories(true)), fileName, fileDir });
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private boolean updateLastModifiedTime(GpxDataItem item) {
|
||||
SQLiteConnection db = openConnection(false);
|
||||
if (db != null) {
|
||||
|
|
|
@ -124,7 +124,10 @@ public class AddTracksGroupBottomSheetDialogFragment extends AddGroupBottomSheet
|
|||
processGPXFolder(gpxFile, sub);
|
||||
} else if (gpxFile.isFile() && gpxFile.getName().toLowerCase().endsWith(".gpx")) {
|
||||
GpxDataItem item = processedDataFiles.get(gpxFile);
|
||||
if (item == null || item.getFileLastModifiedTime() != gpxFile.lastModified()) {
|
||||
if (item == null
|
||||
|| item.getFileLastModifiedTime() != gpxFile.lastModified()
|
||||
|| item.getAnalysis().wptCategoryNames == null
|
||||
|| (item.getAnalysis().wptPoints > 0 && item.getAnalysis().wptCategoryNames.isEmpty())) {
|
||||
GPXFile f = GPXUtilities.loadGPXFile(app, gpxFile);
|
||||
GPXTrackAnalysis analysis = f.getAnalysis(gpxFile.lastModified());
|
||||
if (item == null) {
|
||||
|
|
Loading…
Reference in a new issue