From 7fbda80bc580a847d4150d640c03ce0691bf1c10 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 16 Oct 2014 16:36:44 +0300 Subject: [PATCH] Removed unused code. Moved waypointsdialoghelper to mapactivityactions --- .../plus/activities/MapActivityActions.java | 6 ++- .../plus/helpers/WaypointDialogHelper.java | 42 +------------------ .../osmand/plus/views/MapControlsLayer.java | 12 ++---- 3 files changed, 8 insertions(+), 52 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 76b8f3f6d1..93b6cf3b49 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -97,12 +97,15 @@ public class MapActivityActions implements DialogProvider { DrawerLayout mDrawerLayout; ListView mDrawerList; + private WaypointDialogHelper waypointDialogHelper; public MapActivityActions(MapActivity mapActivity){ this.mapActivity = mapActivity; settings = mapActivity.getMyApplication().getSettings(); routingHelper = mapActivity.getMyApplication().getRoutingHelper(); + waypointDialogHelper = new WaypointDialogHelper(mapActivity); + waypointDialogHelper.init(); } protected void addFavouritePoint(final double latitude, final double longitude){ @@ -902,8 +905,7 @@ public class MapActivityActions implements DialogProvider { if (getMyApplication().getWaypointHelper().isRouteCalculated()) { final List deletedPoints = new ArrayList(); - ArrayAdapter adapter = app.getMapActivity().getMapLayers(). - getMapControlsLayer().getWaypointDialogHelper().getWaypointsAdapter(app.getMapActivity(), deletedPoints); + ArrayAdapter adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints); mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer); mDrawerList.setAdapter(adapter); return false; diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index b6c410f88d..0446c1570d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -229,10 +229,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) { - return createWaypointsDialogFlat(waypointHelper.getAllPoints()); - } - return createWaypointsDialog(); + return createWaypointsDialogFlat(waypointHelper.getAllPoints()); } public AlertDialog createWaypointsDialogFlat(final List points) { @@ -288,43 +285,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener { return builder.create(); } - public AlertDialog createWaypointsDialog() { - final FragmentActivity ctx = getActivity(); - final ListView listView = new ListView(ctx); - final List deletedPoints = new ArrayList(); - final ArrayAdapter listAdapter = dialogHelper.getWaypointsAdapter(ctx, deletedPoints); - - listView.setAdapter(listAdapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int item, long l) { - if (listAdapter.getItem(item) instanceof LocationPointWrapper) { - LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item); - showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this); - } - } - }); - AlertDialog.Builder builder = new AlertDialog.Builder(ctx); - builder.setView(listView); - builder.setNeutralButton(R.string.flat_list_waypoints, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - showWaypointsDialogFlat(getActivity()); - } - - }); - builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - waypointHelper.removeVisibleLocationPoint(deletedPoints); - } - }); - builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null); - return builder.create(); - } - } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index d6f7645a0d..8d67a10bf2 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -65,12 +65,11 @@ public class MapControlsLayer extends OsmandMapLayer { private LinearLayout transparencyBarLayout; private static CommonPreference settingsToTransparency; private OsmandSettings settings; - private WaypointDialogHelper waypointDialogHelper; + public MapControlsLayer(MapActivity activity){ this.mapActivity = activity; settings = activity.getMyApplication().getSettings(); - waypointDialogHelper = new WaypointDialogHelper(activity); } @@ -122,8 +121,7 @@ public class MapControlsLayer extends OsmandMapLayer { mapCancelNavigationControl.setMargin(mapSmallMenuControls.getWidth()); mapInfoNavigationControl.setMargin(mapSmallMenuControls.getWidth() + mapCancelNavigationControl.getWidth()); mapAppModeControl.setMargin(mapNavigationControl.getWidth()); - - waypointDialogHelper.init(); + initTransparencyBar(view, parent); } @@ -150,7 +148,7 @@ public class MapControlsLayer extends OsmandMapLayer { @Override public void destroyLayer() { - waypointDialogHelper.removeListener(); + } @Override @@ -337,10 +335,6 @@ public class MapControlsLayer extends OsmandMapLayer { mapInfoNavigationControl.setShowDialog(); } - public WaypointDialogHelper getWaypointDialogHelper() { - return waypointDialogHelper; - } - private int getScreenOrientation() { int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics();