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

@ -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);
if (amenityType != null) {
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), zoom, maxCount); .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());

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,15 +48,17 @@ 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 {
bundle.putString(SearchPOIActivity.ANENITY_TYPE, "Closest_Anenities");
}
newIntent.putExtras(bundle); newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0); startActivityForResult(newIntent, 0);
} }
}
private AmenityType findAmenityType(String string) { private AmenityType findAmenityType(String string) {
for (AmenityType type : AmenityType.values()) { for (AmenityType type : AmenityType.values()) {