From 79b2d47ced7b271e6239f9934e0cedd59802df04 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 2 Apr 2015 00:31:35 +0200 Subject: [PATCH] Make track deselectable --- .../plus/monitoring/DashTrackFragment.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index 58f2134bc9..dbb90dea6b 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -9,6 +9,7 @@ import net.osmand.access.AccessibleToast; import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -76,10 +77,6 @@ public class DashTrackFragment extends DashBaseFragment { updateEnable = false; } - - - - private void setupGpxFiles() { View mainView = getView(); final File dir = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR); @@ -154,6 +151,26 @@ public class DashTrackFragment extends DashBaseFragment { } }); ImageButton showOnMap = ((ImageButton) v.findViewById(R.id.show_on_map)); + showOnMap.setVisibility(View.VISIBLE); + updateShowOnMap(app, f, showOnMap); + tracks.addView(v); + } + } + + private void updateShowOnMap(final OsmandApplication app, final File f, final ImageButton showOnMap) { + final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper(); + final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath()); + if(selected != null) { + showOnMap.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_show_on_map, R.color.color_distance)); + showOnMap.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectedGpxHelper.selectGpxFile(selected.getGpxFile(), false, false); + updateShowOnMap(app, f, showOnMap); + } + }); + } else { + showOnMap.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_show_on_map)); showOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -166,9 +183,6 @@ public class DashTrackFragment extends DashBaseFragment { run.run(); } }); - showOnMap.setVisibility(View.VISIBLE); - showOnMap.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_show_on_map)); - tracks.addView(v); } }