Fix access destination, confirmation dest point, remove duplicate POI.

This commit is contained in:
Victor Shcherb 2013-01-11 14:33:39 +01:00
parent 79142e3249
commit d75ca69db8
3 changed files with 72 additions and 23 deletions

View file

@ -9,6 +9,8 @@
1. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="stop_routing_confirm">Are you sure you want to stop the navigation?</string>
<string name="clear_dest_confirm">Are you sure you want to clear your destination point?</string>
<string name="precise_routing_mode_descr">Enable precise routing to calculate precise routes without glitches. It is very limited by distance and doesn\'t use native library.</string>
<string name="precise_routing_mode">Precise routing (alpha)</string>
<string name="recording_context_menu_show">Show</string>

View file

@ -1041,17 +1041,7 @@ public class MapActivityActions implements DialogProvider {
}
@Override
public boolean onClick(MenuItem item) {
if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) {
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), mapActivity.getLastKnownLocation(),
routingHelper.getCurrentGPXRoute());
// restore default mode
boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get());
mapActivity.updateApplicationModeSettings();
mapView.refreshMap(changed);
} else {
mapActivity.getTargetPoints().clearPointToNavigate(mapActivity, true);
}
mapView.refreshMap();
stopNavigationActionConfirm(mapView);
return true;
}
});
@ -1164,6 +1154,55 @@ public class MapActivityActions implements DialogProvider {
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity);
}
public void stopNavigationAction(final OsmandMapTileView mapView) {
if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) {
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), mapActivity.getLastKnownLocation(),
routingHelper.getCurrentGPXRoute());
// restore default mode
boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get());
mapActivity.updateApplicationModeSettings();
mapView.refreshMap(changed);
} else {
mapActivity.getTargetPoints().clearPointToNavigate(mapActivity, true);
mapView.refreshMap();
}
}
public void stopNavigationActionConfirm(final OsmandMapTileView mapView){
Builder builder = new AlertDialog.Builder(mapActivity);
if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) {
// Stop the navigation
builder.setTitle(getString(R.string.stop_routing));
builder.setMessage(getString(R.string.stop_routing_confirm));
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), mapActivity.getLastKnownLocation(),
routingHelper.getCurrentGPXRoute());
// restore default mode
boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get());
mapActivity.updateApplicationModeSettings();
mapView.refreshMap(changed);
}
});
} else {
// Clear the destination point
builder.setTitle(getString(R.string.stop_navigation));
builder.setMessage(getString(R.string.clear_dest_confirm));
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mapActivity.getTargetPoints().clearPointToNavigate(mapActivity, true);
mapView.refreshMap();
}
});
}
builder.setNegativeButton(R.string.default_buttons_no, null);
builder.show();
}
private void startGpsStatusIntent() {

View file

@ -588,7 +588,7 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent
private SearchAmenityRequest request;
private TLongHashSet existingObjects = null;
private final static int LIMIT_TO_LIVE_SEARCH = 150;
private TLongHashSet updateExisting;
public SearchAmenityTask(SearchAmenityRequest request){
this.request = request;
@ -604,18 +604,20 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent
findViewById(R.id.ProgressBar).setVisibility(View.VISIBLE);
findViewById(R.id.SearchAreaText).setVisibility(View.GONE);
searchPOILevel.setEnabled(false);
existingObjects = new TLongHashSet();
updateExisting = new TLongHashSet();
if(request.type == SearchAmenityRequest.NEW_SEARCH_INIT){
amenityAdapter.clear();
} else if (request.type == SearchAmenityRequest.SEARCH_FURTHER) {
List<Amenity> list = amenityAdapter.getOriginalAmenityList();
if (list.size() < LIMIT_TO_LIVE_SEARCH) {
existingObjects = new TLongHashSet();
for (Amenity a : list) {
existingObjects.add(a.getId());
}
for (Amenity a : list) {
updateExisting.add(getAmenityId(a));
}
}
}
private long getAmenityId(Amenity a){
return (a.getId() << 8) + a.getType().ordinal();
}
@Override
protected void onPostExecute(List<Amenity> result) {
@ -662,15 +664,19 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent
@Override
public boolean publish(Amenity object) {
if(request.type == SearchAmenityRequest.NEW_SEARCH_INIT){
publishProgress(object);
} else if (request.type == SearchAmenityRequest.SEARCH_FURTHER) {
if(existingObjects != null && !existingObjects.contains(object.getId())){
long id = getAmenityId(object);
if (existingObjects != null && !existingObjects.contains(id)) {
existingObjects.add(id);
if (request.type == SearchAmenityRequest.NEW_SEARCH_INIT) {
publishProgress(object);
} else if (request.type == SearchAmenityRequest.SEARCH_FURTHER) {
if(!updateExisting.contains(id)){
publishProgress(object);
}
}
return true;
}
return true;
return false;
}
}
@ -685,10 +691,12 @@ public class SearchPOIActivity extends OsmandListActivity implements SensorEvent
this.setNotifyOnChange(false);
}
public List<Amenity> getOriginalAmenityList() {
return originalAmenityList;
}
public void setNewModel(List<Amenity> amenityList, String filter) {
setNotifyOnChange(false);
originalAmenityList = new ArrayList<Amenity>(amenityList);