Codestyle: add braces in "if" and "for" statements, remove trailing whitespace

This commit is contained in:
Roman Inflianskas 2016-04-23 16:26:21 +03:00
parent 2390c95a1b
commit 6944f76748
8 changed files with 65 additions and 44 deletions

View file

@ -2328,8 +2328,9 @@ public class OsmandSettings {
public Set<String> getSelectedPoiFilters() { public Set<String> getSelectedPoiFilters() {
Set<String> result = new LinkedHashSet<>(); Set<String> result = new LinkedHashSet<>();
String filtersId = SELECTED_POI_FILTER_FOR_MAP.get(); String filtersId = SELECTED_POI_FILTER_FOR_MAP.get();
if (filtersId != null) if (filtersId != null) {
Collections.addAll(result, filtersId.split(",")); Collections.addAll(result, filtersId.split(","));
}
return result; return result;
} }

View file

@ -307,10 +307,11 @@ public class MapActivityLayers {
builder.setListener(new ContextMenuAdapter.ItemClickListener() { builder.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
if (isChecked) if (isChecked) {
getApplication().getPoiFilters().addSelectedPoiFilter(f); getApplication().getPoiFilters().addSelectedPoiFilter(f);
else } else {
getApplication().getPoiFilters().removeSelectedPoiFilter(f); getApplication().getPoiFilters().removeSelectedPoiFilter(f);
}
return true; return true;
} }
}); });

View file

@ -828,8 +828,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
List<String> attributes = new ArrayList<String>(); List<String> attributes = new ArrayList<String>();
NavigationInfo navigationInfo = app.getLocationProvider().getNavigationInfo(); NavigationInfo navigationInfo = app.getLocationProvider().getNavigationInfo();
String direction = navigationInfo.getDirectionString(amenity.getLocation(), heading); String direction = navigationInfo.getDirectionString(amenity.getLocation(), heading);
if (direction != null) if (direction != null) {
attributes.add(direction); attributes.add(direction);
}
String[] as = OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity, false).split("\n"); String[] as = OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity, false).split("\n");
for (String s : as) { for (String s : as) {
attributes.add(s.replace(':', ' ')); attributes.add(s.replace(':', ' '));

View file

@ -542,8 +542,9 @@ public class WaypointHelper {
if (app.getPoiFilters().isShowingAnyPoi()) { if (app.getPoiFilters().isShowingAnyPoi()) {
final List<Location> locs = route.getImmutableAllLocations(); final List<Location> locs = route.getImmutableAllLocations();
List<Amenity> amenities = new ArrayList<>(); List<Amenity> amenities = new ArrayList<>();
for (PoiUIFilter pf : app.getPoiFilters().getSelectedPoiFilters()) for (PoiUIFilter pf : app.getPoiFilters().getSelectedPoiFilters()) {
amenities.addAll(pf.searchAmenitiesOnThePath(locs, poiSearchDeviationRadius)); amenities.addAll(pf.searchAmenitiesOnThePath(locs, poiSearchDeviationRadius));
}
for (Amenity a : amenities) { for (Amenity a : amenities) {
AmenityRoutePoint rp = a.getRoutePoint(); AmenityRoutePoint rp = a.getRoutePoint();
int i = locs.indexOf(rp.pointA); int i = locs.indexOf(rp.pointA);
@ -760,18 +761,23 @@ public class WaypointHelper {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj) {
return true; return true;
if (obj == null) }
if (obj == null) {
return false; return false;
if (getClass() != obj.getClass()) }
if (getClass() != obj.getClass()) {
return false; return false;
}
LocationPointWrapper other = (LocationPointWrapper) obj; LocationPointWrapper other = (LocationPointWrapper) obj;
if (point == null) { if (point == null) {
if (other.point != null) if (other.point != null) {
return false; return false;
} else if (!point.equals(other.point)) }
} else if (!point.equals(other.point)) {
return false; return false;
}
return true; return true;
} }

View file

@ -189,9 +189,11 @@ public class PoiFiltersHelper {
List<PoiUIFilter> result = new ArrayList<>(); List<PoiUIFilter> result = new ArrayList<>();
List<PoiUIFilter> filters = Arrays.asList(getCustomPOIFilter(), // getShowAllPOIFilter(), List<PoiUIFilter> filters = Arrays.asList(getCustomPOIFilter(), // getShowAllPOIFilter(),
getSearchByNamePOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter()); getSearchByNamePOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
for (PoiUIFilter f : filters) for (PoiUIFilter f : filters) {
if (f != null && !f.isEmpty()) if (f != null && !f.isEmpty()) {
result.add(f); result.add(f);
}
}
return result; return result;
} }
@ -309,11 +311,11 @@ public class PoiFiltersHelper {
public String getFiltersName(Set<PoiUIFilter> filters) { public String getFiltersName(Set<PoiUIFilter> filters) {
if (filters.isEmpty()) { if (filters.isEmpty()) {
return application.getResources().getString(R.string.shared_string_none); return application.getResources().getString(R.string.shared_string_none);
} } else {
else {
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
for (PoiUIFilter filter : filters) for (PoiUIFilter filter : filters) {
names.add(filter.getName()); names.add(filter.getName());
}
return android.text.TextUtils.join(", ", names); return android.text.TextUtils.join(", ", names);
} }
} }
@ -327,22 +329,26 @@ public class PoiFiltersHelper {
} }
public boolean isPoiFilterSelected(String filterId) { public boolean isPoiFilterSelected(String filterId) {
for (PoiUIFilter filter: selectedPoiFilters) for (PoiUIFilter filter: selectedPoiFilters) {
if (filter.filterId.equals(filterId)) if (filter.filterId.equals(filterId)) {
return true; return true;
}
}
return false; return false;
} }
public void loadSelectedPoiFilters() { public void loadSelectedPoiFilters() {
Set<String> filters = application.getSettings().getSelectedPoiFilters(); Set<String> filters = application.getSettings().getSelectedPoiFilters();
for (String f: filters) for (String f: filters) {
selectedPoiFilters.add(getFilterById(f)); selectedPoiFilters.add(getFilterById(f));
} }
}
public void saveSelectedPoiFilters() { public void saveSelectedPoiFilters() {
Set<String> filters = new HashSet<>(); Set<String> filters = new HashSet<>();
for (PoiUIFilter f: selectedPoiFilters) for (PoiUIFilter f: selectedPoiFilters) {
filters.add(f.filterId); filters.add(f.filterId);
}
application.getSettings().setSelectedPoiFilters(filters); application.getSettings().setSelectedPoiFilters(filters);
} }

View file

@ -496,14 +496,17 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
public static void combineStandardPoiFilters(Set<PoiUIFilter> filters, OsmandApplication app) { public static void combineStandardPoiFilters(Set<PoiUIFilter> filters, OsmandApplication app) {
Set<PoiUIFilter> standardFilters = new TreeSet<>(); Set<PoiUIFilter> standardFilters = new TreeSet<>();
for (PoiUIFilter filter : filters) for (PoiUIFilter filter : filters) {
if (filter.isStandardFilter() && filter.filterId.startsWith(PoiUIFilter.STD_PREFIX)) if (filter.isStandardFilter() && filter.filterId.startsWith(PoiUIFilter.STD_PREFIX)) {
standardFilters.add(filter); standardFilters.add(filter);
}
}
if (!standardFilters.isEmpty()) { if (!standardFilters.isEmpty()) {
PoiUIFilter standardFiltersCombined = new PoiUIFilter( PoiUIFilter standardFiltersCombined = new PoiUIFilter(
null, app, app.getPoiFilters().getFiltersName(standardFilters)); null, app, app.getPoiFilters().getFiltersName(standardFilters));
for (PoiUIFilter f : standardFilters) for (PoiUIFilter f : standardFilters) {
standardFiltersCombined.combineWithPoiFilter(f); standardFiltersCombined.combineWithPoiFilter(f);
}
filters.removeAll(standardFilters); filters.removeAll(standardFilters);
filters.add(standardFiltersCombined); filters.add(standardFiltersCombined);
} }
@ -587,11 +590,12 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
@Override @Override
public int compareTo(@NonNull PoiUIFilter another) { public int compareTo(@NonNull PoiUIFilter another) {
if (another.filterId.equals(this.filterId)) if (another.filterId.equals(this.filterId)) {
return 0; return 0;
else } else {
return this.name.compareTo(another.name); return this.name.compareTo(another.name);
} }
}
public interface AmenityNameFilter { public interface AmenityNameFilter {

View file

@ -123,7 +123,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
List<Amenity> res = new ArrayList<>(); List<Amenity> res = new ArrayList<>();
PoiUIFilter.combineStandardPoiFilters(filters, app); PoiUIFilter.combineStandardPoiFilters(filters, app);
for (PoiUIFilter filter : filters) for (PoiUIFilter filter : filters) {
res.addAll(filter.searchAmenities(latLonBounds.top, latLonBounds.left, res.addAll(filter.searchAmenities(latLonBounds.top, latLonBounds.left,
latLonBounds.bottom, latLonBounds.right, z, new ResultMatcher<Amenity>() { latLonBounds.bottom, latLonBounds.right, z, new ResultMatcher<Amenity>() {
@ -137,6 +137,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
return isInterrupted(); return isInterrupted();
} }
})); }));
}
Collections.sort(res, new Comparator<Amenity>() { Collections.sort(res, new Comparator<Amenity>() {
@Override @Override
@ -309,8 +310,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
} }
static int getResIdFromAttribute(final Context ctx, final int attr) { static int getResIdFromAttribute(final Context ctx, final int attr) {
if (attr == 0) if (attr == 0) {
return 0; return 0;
}
final TypedValue typedvalueattr = new TypedValue(); final TypedValue typedvalueattr = new TypedValue();
ctx.getTheme().resolveAttribute(attr, typedvalueattr, true); ctx.getTheme().resolveAttribute(attr, typedvalueattr, true);
return typedvalueattr.resourceId; return typedvalueattr.resourceId;