Merge pull request #11314 from osmandapp/fix_10904

Fix_10904
This commit is contained in:
vshcherb 2021-04-01 17:20:44 +02:00 committed by GitHub
commit 432f0e6abd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -611,7 +611,7 @@ public class GpxUiHelper {
} }
} }
dialog.dismiss(); dialog.dismiss();
updateSelectedTracksAppearance(app, fileNames); updateSelectedTracksAppearance(app, fileNames, gpxAppearanceParams);
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
fileNames.toArray(new String[0])); fileNames.toArray(new String[0]));
} }
@ -718,13 +718,7 @@ public class GpxUiHelper {
return dlg; return dlg;
} }
private static void updateSelectedTracksAppearance(OsmandApplication app, List<String> fileNames) { private static void updateSelectedTracksAppearance(final OsmandApplication app, List<String> fileNames, final Map<String, String> params) {
final GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
final boolean showStartFinish = app.getSettings().SHOW_START_FINISH_ICONS.get();
final String savedWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get();
String savedColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get();
final int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor);
GpxDataItemCallback callback = new GpxDataItemCallback() { GpxDataItemCallback callback = new GpxDataItemCallback() {
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
@ -733,22 +727,35 @@ public class GpxUiHelper {
@Override @Override
public void onGpxDataItemReady(GpxDataItem item) { public void onGpxDataItemReady(GpxDataItem item) {
updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish); updateTrackAppearance(app, item, params);
} }
}; };
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
for (String name : fileNames) { for (String name : fileNames) {
GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback); GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback);
if (item != null) { if (item != null) {
updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish); updateTrackAppearance(app, item, params);
} }
} }
} }
private static void updateTrackAppearance(GpxDbHelper gpxDbHelper, GpxDataItem item, String width, int color, boolean showStartFinish) { private static void updateTrackAppearance(OsmandApplication app, GpxDataItem item, Map<String, String> params) {
OsmandSettings settings = app.getSettings();
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
if (params.containsKey(CURRENT_TRACK_COLOR_ATTR)) {
String savedColor = settings.getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get();
int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor);
gpxDbHelper.updateColor(item, color); gpxDbHelper.updateColor(item, color);
}
if (params.containsKey(CURRENT_TRACK_WIDTH_ATTR)) {
String width = settings.getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get();
gpxDbHelper.updateWidth(item, width); gpxDbHelper.updateWidth(item, width);
}
if (params.containsKey(SHOW_START_FINISH_ATTR)) {
boolean showStartFinish = settings.SHOW_START_FINISH_ICONS.get();
gpxDbHelper.updateShowStartFinish(item, showStartFinish); gpxDbHelper.updateShowStartFinish(item, showStartFinish);
} }
}
public static void updateGpxInfoView(final @NonNull OsmandApplication app, public static void updateGpxInfoView(final @NonNull OsmandApplication app,
final @NonNull View v, final @NonNull View v,