fix small issues

git-svn-id: https://osmand.googlecode.com/svn/trunk@113 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-06-01 22:15:19 +00:00
parent 5a7c221e17
commit 12f5d23bc1
6 changed files with 38 additions and 18 deletions

View file

@ -165,11 +165,15 @@ public class Amenity extends MapObject {
public String getSimpleFormat(boolean en){
return Algoritms.capitalizeFirstLetterAndLowercase(getType().toString()) +
" : " + getSubType() + " " +getName(en);
" : " + getStringWithoutType(en);
}
public String getStringWithoutType(boolean en){
return getSubType() + " " +getName(en);
String n = getName(en);
if(n.length() == 0){
return getSubType();
}
return getSubType() + " " + n;
}
@Override

View file

@ -54,19 +54,18 @@ public abstract class MapObject implements Comparable<MapObject> {
if (this.name != null) {
return this.name;
}
if (id != null) {
return id + "";
} else {
return "";
}
}
public void setName(String name) {
this.name = name;
}
public String getEnName() {
return enName;
if(this.enName != null){
return this.enName;
}
return "";
}
public void setEnName(String enName) {

View file

@ -23,9 +23,9 @@ public class SearchActivity extends TabActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost host = getTabHost();
host.addTab(host.newTabSpec("Search_POI").setIndicator("Search POI").setContent(new Intent(this, SearchPOIListActivity.class)));
host.addTab(host.newTabSpec("Search_Address").setIndicator("Search Address").setContent(new Intent(this, SearchAddressActivity.class)));
host.addTab(host.newTabSpec("Search_Location").setIndicator("Search Location").setContent(new Intent(this, NavigatePointActivity.class)));
host.addTab(host.newTabSpec("Search_POI").setIndicator("POI").setContent(new Intent(this, SearchPOIListActivity.class)));
host.addTab(host.newTabSpec("Search_Address").setIndicator("Address").setContent(new Intent(this, SearchAddressActivity.class)));
host.addTab(host.newTabSpec("Search_Location").setIndicator("Location").setContent(new Intent(this, NavigatePointActivity.class)));
}
}

View file

@ -57,6 +57,10 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
});
}
public boolean isFilterableByDefault(){
return false;
}
public Editable getFilter(){
return searchText.getText();
}
@ -65,14 +69,20 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
runOnUiThread(new Runnable(){
@Override
public void run() {
((NamesAdapter)getListAdapter()).setNotifyOnChange(false);
for(T o : objects){
((NamesAdapter)getListAdapter()).add(o);
}
((NamesAdapter)getListAdapter()).notifyDataSetChanged();
}
});
}
public void setText(final String filter) {
if(isFilterableByDefault()){
((NamesAdapter) getListAdapter()).getFilter().filter(filter);
return;
}
((NamesAdapter) getListAdapter()).clear();
if(handlerToLoop == null){

View file

@ -4,7 +4,6 @@
package com.osmand.activities.search;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.content.Intent;
@ -38,13 +37,12 @@ public class SearchPOIActivity extends ListActivity {
public static final String ANENITY_TYPE = "amenity_type";
Map<AmenityType, List<Amenity>> filter;
private List<Amenity> amenityList;
private Button searchPOILevel;
private int zoom = 12;
private int maxCount = 100;
private final static int maxCount = 100;
private final static int finalZoom = 8;
private int zoom = 13;
private AmenityType amenityType;
@ -61,14 +59,16 @@ public class SearchPOIActivity extends ListActivity {
@Override
public void onClick(View v) {
ResourceManager resourceManager = ResourceManager.getResourceManager();
if ( zoom > 7) {
if ( zoom > finalZoom) {
--zoom;
}
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), zoom, -1);
if (amenityList != null) {
MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude());
amenityAdapter.setNewModel(amenityList);
}
searchPOILevel.setEnabled(zoom > finalZoom);
}
});
@ -80,7 +80,9 @@ public class SearchPOIActivity extends ListActivity {
amenityType = findAmenityType(anemity);
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
.getLongitude(), zoom, maxCount);
if (amenityList != null) {
MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude());
amenityAdapter = new AmenityAdapter(amenityList);
setListAdapter(amenityAdapter);
}
@ -115,6 +117,7 @@ public class SearchPOIActivity extends ListActivity {
}
public void setNewModel(List<?> amenityList) {
setNotifyOnChange(false);
((AmenityAdapter) getListAdapter()).clear();
for(Object obj: amenityList){
this.add(obj);

View file

@ -33,6 +33,10 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
public void itemSelected(RegionAddressRepository obj) {
OsmandSettings.setLastSearchedRegion(this, obj.getName());
finish();
}
@Override
public boolean isFilterableByDefault() {
return true;
}
}