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="choose_available_region">Choose region</string>
<string name="choose_intersected_street">Choose intersected street</string>
<string name="Closest_Anemities">Closest Anemities</string>
</resources>

View file

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

View file

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