add closest amenity

git-svn-id: https://osmand.googlecode.com/svn/trunk@115 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
frolovmo 2010-06-02 13:26:19 +00:00
parent 85d16a6bf9
commit 409f31bfcc
3 changed files with 20 additions and 12 deletions

View file

@ -48,4 +48,5 @@
<string name="incremental_search_building">Search building incrementally</string> <string name="incremental_search_building">Search building incrementally</string>
<string name="choose_available_region">Choose region</string> <string name="choose_available_region">Choose region</string>
<string name="choose_intersected_street">Choose intersected street</string> <string name="choose_intersected_street">Choose intersected street</string>
<string name="Closest_Anemities">Closest Anemities</string>
</resources> </resources>

View file

@ -59,7 +59,7 @@ public class SearchPOIActivity extends ListActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
ResourceManager resourceManager = ResourceManager.getResourceManager(); ResourceManager resourceManager = ResourceManager.getResourceManager();
if ( zoom > finalZoom) { if (zoom > finalZoom) {
--zoom; --zoom;
} }
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
@ -78,8 +78,13 @@ public class SearchPOIActivity extends ListActivity {
ResourceManager resourceManager = ResourceManager.getResourceManager(); ResourceManager resourceManager = ResourceManager.getResourceManager();
lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(this); lastKnownMapLocation = OsmandSettings.getLastKnownMapLocation(this);
amenityType = findAmenityType(anemity); amenityType = findAmenityType(anemity);
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation if (amenityType != null) {
.getLongitude(), zoom, maxCount); amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), zoom, maxCount);
} else {
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), zoom, 15);
}
if (amenityList != null) { if (amenityList != null) {
MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()); MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude());
@ -119,7 +124,7 @@ public class SearchPOIActivity extends ListActivity {
public void setNewModel(List<?> amenityList) { public void setNewModel(List<?> amenityList) {
setNotifyOnChange(false); setNotifyOnChange(false);
((AmenityAdapter) getListAdapter()).clear(); ((AmenityAdapter) getListAdapter()).clear();
for(Object obj: amenityList){ for (Object obj : amenityList) {
this.add(obj); this.add(obj);
} }
this.notifyDataSetChanged(); this.notifyDataSetChanged();

View file

@ -27,7 +27,6 @@ import com.osmand.data.Amenity.AmenityType;
*/ */
public class SearchPOIListActivity extends ListActivity { public class SearchPOIListActivity extends ListActivity {
List<String> amenityList = new ArrayList<String>(); List<String> amenityList = new ArrayList<String>();
@Override @Override
@ -40,6 +39,7 @@ public class SearchPOIListActivity extends ListActivity {
} }
private void createAmenityTypeList() { private void createAmenityTypeList() {
amenityList.add(getResources().getString(R.string.Closest_Anemities));
for (AmenityType type : AmenityType.values()) { for (AmenityType type : AmenityType.values()) {
amenityList.add(Algoritms.capitalizeFirstLetterAndLowercase(type.toString())); amenityList.add(Algoritms.capitalizeFirstLetterAndLowercase(type.toString()));
} }
@ -48,14 +48,16 @@ public class SearchPOIListActivity extends ListActivity {
public void onListItemClick(ListView parent, View v, int position, long id) { public void onListItemClick(ListView parent, View v, int position, long id) {
AmenityType amenityType = findAmenityType(amenityList.get(position)); AmenityType amenityType = findAmenityType(amenityList.get(position));
Bundle bundle = new Bundle();
Intent newIntent = new Intent(SearchPOIListActivity.this, SearchPOIActivity.class);
// folder selected // folder selected
if (amenityType != null) { if (amenityType != null) {
Bundle bundle = new Bundle();
bundle.putString(SearchPOIActivity.ANENITY_TYPE, amenityList.get(position)); bundle.putString(SearchPOIActivity.ANENITY_TYPE, amenityList.get(position));
Intent newIntent = new Intent(SearchPOIListActivity.this, SearchPOIActivity.class); } else {
newIntent.putExtras(bundle); bundle.putString(SearchPOIActivity.ANENITY_TYPE, "Closest_Anenities");
startActivityForResult(newIntent, 0);
} }
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
} }
private AmenityType findAmenityType(String string) { private AmenityType findAmenityType(String string) {