fix small issues
git-svn-id: https://osmand.googlecode.com/svn/trunk@113 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
5a7c221e17
commit
12f5d23bc1
6 changed files with 38 additions and 18 deletions
|
@ -165,11 +165,15 @@ public class Amenity extends MapObject {
|
||||||
|
|
||||||
public String getSimpleFormat(boolean en){
|
public String getSimpleFormat(boolean en){
|
||||||
return Algoritms.capitalizeFirstLetterAndLowercase(getType().toString()) +
|
return Algoritms.capitalizeFirstLetterAndLowercase(getType().toString()) +
|
||||||
" : " + getSubType() + " " +getName(en);
|
" : " + getStringWithoutType(en);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStringWithoutType(boolean en){
|
public String getStringWithoutType(boolean en){
|
||||||
return getSubType() + " " +getName(en);
|
String n = getName(en);
|
||||||
|
if(n.length() == 0){
|
||||||
|
return getSubType();
|
||||||
|
}
|
||||||
|
return getSubType() + " " + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,19 +54,18 @@ public abstract class MapObject implements Comparable<MapObject> {
|
||||||
if (this.name != null) {
|
if (this.name != null) {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
if (id != null) {
|
|
||||||
return id + "";
|
|
||||||
} else {
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEnName() {
|
public String getEnName() {
|
||||||
return enName;
|
if(this.enName != null){
|
||||||
|
return this.enName;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnName(String enName) {
|
public void setEnName(String enName) {
|
||||||
|
|
|
@ -23,9 +23,9 @@ public class SearchActivity extends TabActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
TabHost host = getTabHost();
|
TabHost host = getTabHost();
|
||||||
host.addTab(host.newTabSpec("Search_POI").setIndicator("Search POI").setContent(new Intent(this, SearchPOIListActivity.class)));
|
host.addTab(host.newTabSpec("Search_POI").setIndicator("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_Address").setIndicator("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_Location").setIndicator("Location").setContent(new Intent(this, NavigatePointActivity.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,10 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFilterableByDefault(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public Editable getFilter(){
|
public Editable getFilter(){
|
||||||
return searchText.getText();
|
return searchText.getText();
|
||||||
}
|
}
|
||||||
|
@ -65,14 +69,20 @@ public abstract class SearchByNameAbstractActivity<T> extends ListActivity {
|
||||||
runOnUiThread(new Runnable(){
|
runOnUiThread(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
((NamesAdapter)getListAdapter()).setNotifyOnChange(false);
|
||||||
for(T o : objects){
|
for(T o : objects){
|
||||||
((NamesAdapter)getListAdapter()).add(o);
|
((NamesAdapter)getListAdapter()).add(o);
|
||||||
}
|
}
|
||||||
|
((NamesAdapter)getListAdapter()).notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(final String filter) {
|
public void setText(final String filter) {
|
||||||
|
if(isFilterableByDefault()){
|
||||||
|
((NamesAdapter) getListAdapter()).getFilter().filter(filter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
((NamesAdapter) getListAdapter()).clear();
|
((NamesAdapter) getListAdapter()).clear();
|
||||||
|
|
||||||
if(handlerToLoop == null){
|
if(handlerToLoop == null){
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
package com.osmand.activities.search;
|
package com.osmand.activities.search;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -38,13 +37,12 @@ public class SearchPOIActivity extends ListActivity {
|
||||||
|
|
||||||
public static final String ANENITY_TYPE = "amenity_type";
|
public static final String ANENITY_TYPE = "amenity_type";
|
||||||
|
|
||||||
Map<AmenityType, List<Amenity>> filter;
|
|
||||||
|
|
||||||
private List<Amenity> amenityList;
|
private List<Amenity> amenityList;
|
||||||
|
|
||||||
private Button searchPOILevel;
|
private Button searchPOILevel;
|
||||||
private int zoom = 12;
|
private final static int maxCount = 100;
|
||||||
private int maxCount = 100;
|
private final static int finalZoom = 8;
|
||||||
|
private int zoom = 13;
|
||||||
|
|
||||||
private AmenityType amenityType;
|
private AmenityType amenityType;
|
||||||
|
|
||||||
|
@ -61,14 +59,16 @@ 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 > 7) {
|
if ( zoom > finalZoom) {
|
||||||
--zoom;
|
--zoom;
|
||||||
}
|
}
|
||||||
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
|
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
|
||||||
.getLongitude(), zoom, -1);
|
.getLongitude(), zoom, -1);
|
||||||
if (amenityList != null) {
|
if (amenityList != null) {
|
||||||
|
MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude());
|
||||||
amenityAdapter.setNewModel(amenityList);
|
amenityAdapter.setNewModel(amenityList);
|
||||||
}
|
}
|
||||||
|
searchPOILevel.setEnabled(zoom > finalZoom);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -80,7 +80,9 @@ public class SearchPOIActivity extends ListActivity {
|
||||||
amenityType = findAmenityType(anemity);
|
amenityType = findAmenityType(anemity);
|
||||||
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
|
amenityList = resourceManager.searchAmenities(amenityType, lastKnownMapLocation.getLatitude(), lastKnownMapLocation
|
||||||
.getLongitude(), zoom, maxCount);
|
.getLongitude(), zoom, maxCount);
|
||||||
|
|
||||||
if (amenityList != null) {
|
if (amenityList != null) {
|
||||||
|
MapUtils.sortListOfMapObject(amenityList, lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude());
|
||||||
amenityAdapter = new AmenityAdapter(amenityList);
|
amenityAdapter = new AmenityAdapter(amenityList);
|
||||||
setListAdapter(amenityAdapter);
|
setListAdapter(amenityAdapter);
|
||||||
}
|
}
|
||||||
|
@ -115,6 +117,7 @@ public class SearchPOIActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNewModel(List<?> amenityList) {
|
public void setNewModel(List<?> amenityList) {
|
||||||
|
setNotifyOnChange(false);
|
||||||
((AmenityAdapter) getListAdapter()).clear();
|
((AmenityAdapter) getListAdapter()).clear();
|
||||||
for(Object obj: amenityList){
|
for(Object obj: amenityList){
|
||||||
this.add(obj);
|
this.add(obj);
|
||||||
|
|
|
@ -33,6 +33,10 @@ public class SearchRegionByNameActivity extends SearchByNameAbstractActivity<Reg
|
||||||
public void itemSelected(RegionAddressRepository obj) {
|
public void itemSelected(RegionAddressRepository obj) {
|
||||||
OsmandSettings.setLastSearchedRegion(this, obj.getName());
|
OsmandSettings.setLastSearchedRegion(this, obj.getName());
|
||||||
finish();
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFilterableByDefault() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue