From c75aa594eacc9ffd924ab94ebbbdffce0c4044ef Mon Sep 17 00:00:00 2001 From: Nazar-Kutz Date: Tue, 13 Oct 2020 13:26:02 +0300 Subject: [PATCH] fix "selected graph changed after recalculation" --- .../plus/measurementtool/MtGraphFragment.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MtGraphFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MtGraphFragment.java index f3b4bbcf8c..eadc5c6a7e 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MtGraphFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MtGraphFragment.java @@ -101,6 +101,15 @@ public class MtGraphFragment extends BaseCard return R.layout.fragment_measurement_tool_graph; } + @Override + public void onUpdateAdditionalInfo() { + if (!isRouteCalculating()) { + updateGraphData(); + refreshGraphTypesSelectionMenu(); + } + updateDataView(); + } + private void refreshGraphTypesSelectionMenu() { rvGraphTypesMenu.removeAllViews(); OsmandApplication app = getMyApplication(); @@ -112,7 +121,7 @@ public class MtGraphFragment extends BaseCard if (type.isCustom()) { item.setTitleColorId(activeColorId); } - if (type.hasData() || type.canBeCalculated) { + if (type.isAvailable()) { items.add(item); } } @@ -134,13 +143,6 @@ public class MtGraphFragment extends BaseCard adapter.notifyDataSetChanged(); } - @Override - public void onUpdateAdditionalInfo() { - updateGraphData(); - refreshGraphTypesSelectionMenu(); - updateDataView(); - } - private void setupVisibleGraphType(GraphType type) { visibleGraphType = type; updateDataView(); @@ -163,7 +165,7 @@ public class MtGraphFragment extends BaseCard } private void updateDataView() { - if (mtf.isProgressBarVisible()) { + if (isRouteCalculating()) { showProgressMessage(); } else if (visibleGraphType.hasData()) { showGraph(); @@ -358,6 +360,10 @@ public class MtGraphFragment extends BaseCard defaultRender, currentSearchRequest, defaultSearchRequest); } + private boolean isRouteCalculating() { + return mtf.isProgressBarVisible(); + } + private static class GraphType { private String title; private boolean isCustom;