Synchronize main chart and info charts at route details

This commit is contained in:
crimean 2019-04-19 12:40:10 +03:00
parent a976dcfde6
commit f2f5511f58

View file

@ -314,11 +314,12 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
statisticCard = new RouteStatisticCard(mapActivity, gpx, new OnTouchListener() { statisticCard = new RouteStatisticCard(mapActivity, gpx, new OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent ev) {
InterceptorLinearLayout mainView = getMainView(); InterceptorLinearLayout mainView = getMainView();
if (mainView != null) { if (mainView != null) {
mainView.requestDisallowInterceptTouchEvent(true); mainView.requestDisallowInterceptTouchEvent(true);
} }
dispatchEventToInfoCards(v, ev);
return false; return false;
} }
}, new OnClickListener() { }, new OnClickListener() {
@ -394,21 +395,33 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent ev) { public boolean onTouch(View v, MotionEvent ev) {
if (ev.getSource() != 0) { if (ev.getSource() != 0 && v instanceof HorizontalBarChart) {
for (RouteInfoCard card : routeInfoCards) { if (statisticCard != null) {
final HorizontalBarChart ch = card.getChart(); LineChart ch = statisticCard.getChart();
if (ch != null && v instanceof HorizontalBarChart && ch != v) { if (ch != null) {
final MotionEvent event = MotionEvent.obtainNoHistory(ev); final MotionEvent event = MotionEvent.obtainNoHistory(ev);
event.setSource(0); event.setSource(0);
ch.dispatchTouchEvent(event); ch.dispatchTouchEvent(event);
} }
} }
dispatchEventToInfoCards(v, ev);
} }
return false; return false;
} }
}; };
} }
private void dispatchEventToInfoCards(View v, MotionEvent ev) {
for (RouteInfoCard card : routeInfoCards) {
final HorizontalBarChart ch = card.getChart();
if (ch != null && ch != v) {
final MotionEvent event = MotionEvent.obtainNoHistory(ev);
event.setSource(0);
ch.dispatchTouchEvent(event);
}
}
}
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
private void addRouteCard(final LinearLayout cardsContainer, RouteInfoCard routeInfoCard) { private void addRouteCard(final LinearLayout cardsContainer, RouteInfoCard routeInfoCard) {
OsmandApplication app = requireMyApplication(); OsmandApplication app = requireMyApplication();