fix "selected graph changed after recalculation"

This commit is contained in:
Nazar-Kutz 2020-10-13 13:26:02 +03:00
parent f158381f5f
commit c75aa594ea

View file

@ -101,6 +101,15 @@ public class MtGraphFragment extends BaseCard
return R.layout.fragment_measurement_tool_graph; return R.layout.fragment_measurement_tool_graph;
} }
@Override
public void onUpdateAdditionalInfo() {
if (!isRouteCalculating()) {
updateGraphData();
refreshGraphTypesSelectionMenu();
}
updateDataView();
}
private void refreshGraphTypesSelectionMenu() { private void refreshGraphTypesSelectionMenu() {
rvGraphTypesMenu.removeAllViews(); rvGraphTypesMenu.removeAllViews();
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
@ -112,7 +121,7 @@ public class MtGraphFragment extends BaseCard
if (type.isCustom()) { if (type.isCustom()) {
item.setTitleColorId(activeColorId); item.setTitleColorId(activeColorId);
} }
if (type.hasData() || type.canBeCalculated) { if (type.isAvailable()) {
items.add(item); items.add(item);
} }
} }
@ -134,13 +143,6 @@ public class MtGraphFragment extends BaseCard
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
@Override
public void onUpdateAdditionalInfo() {
updateGraphData();
refreshGraphTypesSelectionMenu();
updateDataView();
}
private void setupVisibleGraphType(GraphType type) { private void setupVisibleGraphType(GraphType type) {
visibleGraphType = type; visibleGraphType = type;
updateDataView(); updateDataView();
@ -163,7 +165,7 @@ public class MtGraphFragment extends BaseCard
} }
private void updateDataView() { private void updateDataView() {
if (mtf.isProgressBarVisible()) { if (isRouteCalculating()) {
showProgressMessage(); showProgressMessage();
} else if (visibleGraphType.hasData()) { } else if (visibleGraphType.hasData()) {
showGraph(); showGraph();
@ -358,6 +360,10 @@ public class MtGraphFragment extends BaseCard
defaultRender, currentSearchRequest, defaultSearchRequest); defaultRender, currentSearchRequest, defaultSearchRequest);
} }
private boolean isRouteCalculating() {
return mtf.isProgressBarVisible();
}
private static class GraphType { private static class GraphType {
private String title; private String title;
private boolean isCustom; private boolean isCustom;