Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-06-05 17:49:05 +02:00
commit 99b49c7dca
2 changed files with 19 additions and 17 deletions

View file

@ -179,7 +179,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
}
}
updateButtonState();
updateButtonState(false);
return true;
}
@ -296,7 +296,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
@Override
protected void onResume() {
super.onResume();
updateButtonState();
updateButtonState(false);
if (filter != null) {
String text = filter.getFilterByName() != null ? filter.getFilterByName() : "";
searchFilter.setText(text);
@ -325,7 +325,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
filter.setFilterByName(queue.toString());
runNewSearchQuery(location, SEARCH_AGAIN);
}
updateButtonState();
updateButtonState(false);
}
@ -417,7 +417,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}
}
private void updateButtonState() {
private void updateButtonState(boolean next) {
if (showFilterItem != null) {
showFilterItem.setVisible(filter != null && !isNameSearch());
}
@ -430,7 +430,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
if(filter instanceof NominatimPoiFilter && !((NominatimPoiFilter) filter).isPlacesQuery()) {
// nothing to add
} else {
name += " " + filter.getSearchArea();
name += " " + filter.getSearchArea(next);
}
getSupportActionBar().setTitle(name);
}
@ -497,7 +497,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
final int top = (v == null) ? 0 : v.getTop();
amenityAdapter.notifyDataSetChanged();
lv.setSelectionFromTop(index, top);
updateButtonState();
updateButtonState(false);
navigationInfo.updateLocation(location);
}
@ -615,6 +615,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
updateExisting.add(getAmenityId(a));
}
}
updateButtonState(requestType == SEARCH_FURTHER);
}
private long getAmenityId(Amenity a) {
@ -625,7 +626,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
protected void onPostExecute(List<Amenity> result) {
setSupportProgressBarIndeterminateVisibility(false);
currentSearchTask = null;
updateButtonState();
updateButtonState(false);
if (isNameSearch()) {
if (isNominatimFilter() && !Algorithms.isEmpty(((NominatimPoiFilter) filter).getLastError())) {
Toast.makeText(SearchPOIActivity.this, ((NominatimPoiFilter) filter).getLastError(),

View file

@ -57,7 +57,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
protected int distanceInd = 1;
// in kilometers
protected double[] distanceToSearchValues = new double[] {1, 2, 5, 10, 20, 50, 100, 200, 500 };
protected double[] distanceToSearchValues = new double[] {1, 2, 5, 10, 20, 50, 100, 200, 500};
private final MapPoiTypes poiTypes;
@ -173,24 +173,25 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
MapUtils.sortListOfMapObject(amenityList, latitude, longitude);
return amenityList;
}
private void initSearchAll(){
for(PoiCategory t : poiTypes.getCategories(false)){
acceptedTypes.put(t, null);
}
distanceToSearchValues = new double[] {0.5, 1, 2, 5, 10, 20, 50, 100};
}
public boolean isSearchFurtherAvailable(){
return distanceInd < distanceToSearchValues.length - 1;
}
public String getSearchArea(){
double val = distanceToSearchValues[distanceInd];
public String getSearchArea(boolean next) {
int distInd = distanceInd;
if (next && (distanceInd < distanceToSearchValues.length - 1)) {
//This is workaround for the SearchAmenityTask.onPreExecute() case
distInd = distanceInd + 1;
}
double val = distanceToSearchValues[distInd];
if(val >= 1){
return " < " + OsmAndFormatter.getFormattedDistance(((int)val * 1000), app); //$NON-NLS-1$//$NON-NLS-2$
} else {