@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View settingsView = activity.getLayoutInflater().inflate(R.layout.place_settings, null); builder.setTitle("Place Settings:"); builder.setView(settingsView); final EditText view = (EditText) settingsView.findViewById(R.id.placeName); final CheckBox ignored = (CheckBox) settingsView.findViewById(R.id.ignorePlace); if (place != null) { view.setText(place.getName()); ignored.setChecked(place.getIgnored()); } builder.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton( "Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Place.Builder newPlace; if (place != null) { newPlace = Place.newBuilder(place); } else { newPlace = Place.newBuilder(); newPlace.setTime(System.currentTimeMillis()); RoutePoint routePoint = route.getRoutePoint(route.getRoutePointCount() - 1); newPlace.setLatitude(routePoint.getLatitude()); newPlace.setLongitude(routePoint.getLongitude()); } newPlace.setName(view.getText().toString()); newPlace.setIgnored(ignored.isChecked()); storage.savePlace(newPlace.build(), place != null); dialog.dismiss(); } }); return builder.create(); }
private void showRoute() { PolylineOptions rectOptions = new PolylineOptions(); LatLng latLng = null; for (RoutePoint point : route.getRoutePointList()) { latLng = new LatLng(point.getLatitude(), point.getLongitude()); rectOptions.add(latLng); } rectOptions.color(0xA00080FF); map.addPolyline(rectOptions); MarkerOptions endMarker = new MarkerOptions(); endMarker.position(latLng); String label = place != null ? place.getName() : "Parking Spot"; endMarker.title(label + " @ " + RouteCursorAdapter.getRouteTimeAgo(this, route)); endMarker.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)); endMarker.anchor(0.5f, 0.5f); map.addMarker(endMarker); }