From 776fe08a46d79d76b6e2693902ba1b17c33c4cc2 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 22 Oct 2015 01:29:58 +0200 Subject: [PATCH] Recreate drawer every time in case plugins installed --- .../osmand/plus/activities/MapActivity.java | 22 +++------------- .../plus/activities/MapActivityActions.java | 25 +++++++++++++++++-- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index bc5626328c..7f84f0e50b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -235,29 +235,12 @@ public class MapActivity extends AccessibleActivity { .add(R.id.fragmentContainer, new FirstUsageFragment(), FirstUsageFragment.TAG).commit(); } - final ListView menuItemsListView = (ListView) findViewById(R.id.menuItems); - menuItemsListView.setDivider(null); - final ContextMenuAdapter contextMenuAdapter = mapActions.createMainOptionsMenu(); - contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item); - final ArrayAdapter simpleListAdapter = contextMenuAdapter.createListAdapter(this, - settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME); - menuItemsListView.setAdapter(simpleListAdapter); - menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - ContextMenuAdapter.OnContextMenuClick click = - contextMenuAdapter.getClickAdapter(position); - if (click.onContextMenuClick(simpleListAdapter, - contextMenuAdapter.getElementId(position), position, false)) { - closeDrawer(); - } - } - }); - + mapActions.updateDrawerMenu(); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); } + private void checkAppInitialization() { if (app.isApplicationInitializing()) { findViewById(R.id.init_progress).setVisibility(View.VISIBLE); @@ -1002,6 +985,7 @@ public class MapActivity extends AccessibleActivity { } public void openDrawer() { + mapActions.updateDrawerMenu(); drawerLayout.openDrawer(Gravity.LEFT); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index b59d60e30e..717477096f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -13,7 +13,6 @@ import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.access.AccessibleAlertBuilder; import net.osmand.access.AccessibleToast; -import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; @@ -58,9 +57,11 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.WindowManager; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; +import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -899,6 +900,26 @@ public class MapActivityActions implements DialogProvider { view.show(); } } - + + protected void updateDrawerMenu() { + final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems); + menuItemsListView.setDivider(null); + final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu(); + contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item); + final ArrayAdapter simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity, + settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME); + menuItemsListView.setAdapter(simpleListAdapter); + menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + ContextMenuAdapter.OnContextMenuClick click = + contextMenuAdapter.getClickAdapter(position); + if (click.onContextMenuClick(simpleListAdapter, + contextMenuAdapter.getElementId(position), position, false)) { + mapActivity.closeDrawer(); + } + } + }); + } }