Fix context menu crash and bottom lines hiding

This commit is contained in:
Alexey Kulish 2015-11-27 15:26:37 +03:00
parent 41c33c13ed
commit fd80843baf

View file

@ -142,6 +142,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
menu = getMapActivity().getContextMenu(); menu = getMapActivity().getContextMenu();
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
if (!menu.isActive()) {
return view;
}
mainView = view.findViewById(R.id.context_menu_main);
leftTitleButtonController = menu.getLeftTitleButtonController(); leftTitleButtonController = menu.getLeftTitleButtonController();
rightTitleButtonController = menu.getRightTitleButtonController(); rightTitleButtonController = menu.getRightTitleButtonController();
topRightTitleButtonController = menu.getTopRightTitleButtonController(); topRightTitleButtonController = menu.getTopRightTitleButtonController();
@ -166,9 +172,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent(); boolean light = getMyApplication().getSettings().isLightContent();
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
mainView = view.findViewById(R.id.context_menu_main);
// Left title button // Left title button
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button); final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
if (leftTitleButtonController != null) { if (leftTitleButtonController != null) {
@ -453,20 +456,17 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
.setDuration(200) .setDuration(200)
.setInterpolator(new DecelerateInterpolator()) .setInterpolator(new DecelerateInterpolator())
.setListener(new AnimatorListenerAdapter() { .setListener(new AnimatorListenerAdapter() {
boolean canceled = false;
@Override @Override
public void onAnimationCancel(Animator animation) { public void onAnimationCancel(Animator animation) {
if (needCloseMenu) { canceled = true;
menu.close();
} else {
updateMainViewLayout(posY);
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
doAfterMenuStateChange(previousMenuState, newMenuState);
}
}
} }
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
if (!canceled) {
if (needCloseMenu) { if (needCloseMenu) {
menu.close(); menu.close();
} else { } else {
@ -476,6 +476,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
} }
} }
} }
}
}) })
.start(); .start();
@ -626,6 +627,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (!menu.isActive()) {
dismissMenu();
return;
}
screenOrientation = DashLocationFragment.getScreenOrientation(getActivity()); screenOrientation = DashLocationFragment.getScreenOrientation(getActivity());
if (menu.displayDistanceDirection()) { if (menu.displayDistanceDirection()) {
getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu); getMapActivity().getMapViewTrackingUtilities().setContextMenu(menu);
@ -641,7 +646,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
@Override @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
if (mapCenter != null) {
map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
}
menu.setMapCenter(null); menu.setMapCenter(null);
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true); getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(true);
} }