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;
}
@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;