From 01fab4e8567fdda48ca9b6a22a49a0c7b735e042 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 31 Oct 2014 11:07:37 +0200 Subject: [PATCH] Waypoints will now be updated when user reopens drawer with finger --- .../plus/activities/MapActivityActions.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 6113251430..57361916dd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -91,7 +91,14 @@ public class MapActivityActions implements DialogProvider { DrawerLayout mDrawerLayout; ListView mDrawerList; private WaypointDialogHelper waypointDialogHelper; - + + private enum DrawerType{ + WAYPOINTS, + CONFIGURE_MAP, + MAIN_MENU + } + + private DrawerType currentDrawer; public MapActivityActions(MapActivity mapActivity){ this.mapActivity = mapActivity; @@ -571,7 +578,11 @@ public class MapActivityActions implements DialogProvider { //need to refresh drawer if it //was opened with slide, not button if (mDrawerList != null && refreshDrawer){ - mDrawerList.invalidateViews(); + if (currentDrawer == DrawerType.WAYPOINTS){ + showWaypointsInDrawer(false); + } else { + mDrawerList.invalidateViews(); + } } } @@ -591,10 +602,10 @@ public class MapActivityActions implements DialogProvider { } public void prepareOptionsMenu(final ContextMenuAdapter cm) { + refreshDrawer = false; final ArrayAdapter listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings().isLightContentMenu()); mDrawerList.setAdapter(listAdapter); - refreshDrawer = false; mDrawerList.setDivider(mapActivity.getResources().getDrawable(R.drawable.drawer_divider)); mDrawerList.setBackgroundColor(cm.getBackgroundColor(mapActivity, getMyApplication().getSettings().isLightContentMenu())); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -640,6 +651,7 @@ public class MapActivityActions implements DialogProvider { final OsmandMapTileView mapView = mapActivity.getMapView(); final OsmandApplication app = mapActivity.getMyApplication(); ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app); + currentDrawer = DrawerType.MAIN_MENU; // 1. Where am I optionsMenuHelper.item(R.string.where_am_i). @@ -796,6 +808,7 @@ public class MapActivityActions implements DialogProvider { .listen(new OnContextMenuClick() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { + currentDrawer = DrawerType.CONFIGURE_MAP; ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter(); prepareOptionsMenu(cm); return false; @@ -881,6 +894,7 @@ public class MapActivityActions implements DialogProvider { } public void showWaypointsInDrawer(boolean flat) { + currentDrawer = DrawerType.WAYPOINTS; final int[] running = new int[] { -1 }; ArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(mapActivity, running, flat); mDrawerList.setAdapter(listAdapter);