Removed unused code. Moved waypointsdialoghelper to mapactivityactions

This commit is contained in:
Denis 2014-10-16 16:36:44 +03:00
parent d7ca432c32
commit 7fbda80bc5
3 changed files with 8 additions and 52 deletions

View file

@ -97,12 +97,15 @@ public class MapActivityActions implements DialogProvider {
DrawerLayout mDrawerLayout; DrawerLayout mDrawerLayout;
ListView mDrawerList; ListView mDrawerList;
private WaypointDialogHelper waypointDialogHelper;
public MapActivityActions(MapActivity mapActivity){ public MapActivityActions(MapActivity mapActivity){
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
settings = mapActivity.getMyApplication().getSettings(); settings = mapActivity.getMyApplication().getSettings();
routingHelper = mapActivity.getMyApplication().getRoutingHelper(); routingHelper = mapActivity.getMyApplication().getRoutingHelper();
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
waypointDialogHelper.init();
} }
protected void addFavouritePoint(final double latitude, final double longitude){ protected void addFavouritePoint(final double latitude, final double longitude){
@ -902,8 +905,7 @@ public class MapActivityActions implements DialogProvider {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) { if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>(); final List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
ArrayAdapter<Object> adapter = app.getMapActivity().getMapLayers(). ArrayAdapter<Object> adapter = waypointDialogHelper.getWaypointsAdapter(app.getMapActivity(), deletedPoints);
getMapControlsLayer().getWaypointDialogHelper().getWaypointsAdapter(app.getMapActivity(), deletedPoints);
mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer); mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer);
mDrawerList.setAdapter(adapter); mDrawerList.setAdapter(adapter);
return false; return false;

View file

@ -229,10 +229,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) { return createWaypointsDialogFlat(waypointHelper.getAllPoints());
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
}
return createWaypointsDialog();
} }
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points) { public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points) {
@ -288,43 +285,6 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
return builder.create(); return builder.create();
} }
public AlertDialog createWaypointsDialog() {
final FragmentActivity ctx = getActivity();
final ListView listView = new ListView(ctx);
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
final ArrayAdapter<Object> 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();
}
} }

View file

@ -65,12 +65,11 @@ public class MapControlsLayer extends OsmandMapLayer {
private LinearLayout transparencyBarLayout; private LinearLayout transparencyBarLayout;
private static CommonPreference<Integer> settingsToTransparency; private static CommonPreference<Integer> settingsToTransparency;
private OsmandSettings settings; private OsmandSettings settings;
private WaypointDialogHelper waypointDialogHelper;
public MapControlsLayer(MapActivity activity){ public MapControlsLayer(MapActivity activity){
this.mapActivity = activity; this.mapActivity = activity;
settings = activity.getMyApplication().getSettings(); settings = activity.getMyApplication().getSettings();
waypointDialogHelper = new WaypointDialogHelper(activity);
} }
@ -123,7 +122,6 @@ public class MapControlsLayer extends OsmandMapLayer {
mapInfoNavigationControl.setMargin(mapSmallMenuControls.getWidth() + mapCancelNavigationControl.getWidth()); mapInfoNavigationControl.setMargin(mapSmallMenuControls.getWidth() + mapCancelNavigationControl.getWidth());
mapAppModeControl.setMargin(mapNavigationControl.getWidth()); mapAppModeControl.setMargin(mapNavigationControl.getWidth());
waypointDialogHelper.init();
initTransparencyBar(view, parent); initTransparencyBar(view, parent);
} }
@ -150,7 +148,7 @@ public class MapControlsLayer extends OsmandMapLayer {
@Override @Override
public void destroyLayer() { public void destroyLayer() {
waypointDialogHelper.removeListener();
} }
@Override @Override
@ -337,10 +335,6 @@ public class MapControlsLayer extends OsmandMapLayer {
mapInfoNavigationControl.setShowDialog(); mapInfoNavigationControl.setShowDialog();
} }
public WaypointDialogHelper getWaypointDialogHelper() {
return waypointDialogHelper;
}
private int getScreenOrientation() { private int getScreenOrientation() {
int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation(); int rotation = mapActivity.getWindowManager().getDefaultDisplay().getRotation();
DisplayMetrics dm = new DisplayMetrics(); DisplayMetrics dm = new DisplayMetrics();