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

@ -217,10 +217,10 @@ public class AppInitializer implements IProgress {
private void checkMapUpdates() {
long diff = System.currentTimeMillis() - app.getSettings().LAST_CHECKED_UPDATES.get();
if(diff >= 2 * 24 * 60 * 60l && new Random().nextInt(5) == 0 &&
if (diff >= 2 * 24 * 60 * 60l && new Random().nextInt(5) == 0 &&
app.getSettings().isInternetConnectionAvailable()) {
app.getDownloadThread().runReloadIndexFiles();
} else if(Version.isDeveloperVersion(app)) {
} else if (Version.isDeveloperVersion(app)) {
// app.getDownloadThread().runReloadIndexFiles();
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -189,9 +189,11 @@ public class PoiFiltersHelper {
List<PoiUIFilter> result = new ArrayList<>();
List<PoiUIFilter> filters = Arrays.asList(getCustomPOIFilter(), // getShowAllPOIFilter(),
getSearchByNamePOIFilter(), getNominatimPOIFilter(), getNominatimAddressFilter());
for (PoiUIFilter f : filters)
if (f != null && !f.isEmpty())
for (PoiUIFilter f : filters) {
if (f != null && !f.isEmpty()) {
result.add(f);
}
}
return result;
}
@ -226,17 +228,17 @@ public class PoiFiltersHelper {
}
public boolean removePoiFilter(PoiUIFilter filter){
if(filter.getFilterId().equals(PoiUIFilter.CUSTOM_FILTER_ID) ||
if (filter.getFilterId().equals(PoiUIFilter.CUSTOM_FILTER_ID) ||
filter.getFilterId().equals(PoiUIFilter.BY_NAME_FILTER_ID) ||
filter.getFilterId().startsWith(PoiUIFilter.STD_PREFIX)){
filter.getFilterId().startsWith(PoiUIFilter.STD_PREFIX)) {
return false;
}
PoiFilterDbHelper helper = openDbHelper();
if(helper == null){
if (helper == null) {
return false;
}
boolean res = helper.deleteFilter(helper.getWritableDatabase(), filter);
if(res){
if (res) {
ArrayList<PoiUIFilter> copy = new ArrayList<>(cacheTopStandardFilters);
copy.remove(filter);
cacheTopStandardFilters = copy;
@ -309,11 +311,11 @@ public class PoiFiltersHelper {
public String getFiltersName(Set<PoiUIFilter> filters) {
if (filters.isEmpty()) {
return application.getResources().getString(R.string.shared_string_none);
}
else {
} else {
List<String> names = new ArrayList<>();
for (PoiUIFilter filter : filters)
for (PoiUIFilter filter : filters) {
names.add(filter.getName());
}
return android.text.TextUtils.join(", ", names);
}
}
@ -327,22 +329,26 @@ public class PoiFiltersHelper {
}
public boolean isPoiFilterSelected(String filterId) {
for (PoiUIFilter filter: selectedPoiFilters)
if (filter.filterId.equals(filterId))
for (PoiUIFilter filter: selectedPoiFilters) {
if (filter.filterId.equals(filterId)) {
return true;
}
}
return false;
}
public void loadSelectedPoiFilters() {
Set<String> filters = application.getSettings().getSelectedPoiFilters();
for (String f: filters)
for (String f: filters) {
selectedPoiFilters.add(getFilterById(f));
}
}
public void saveSelectedPoiFilters() {
Set<String> filters = new HashSet<>();
for (PoiUIFilter f: selectedPoiFilters)
for (PoiUIFilter f: selectedPoiFilters) {
filters.add(f.filterId);
}
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) {
Set<PoiUIFilter> standardFilters = new TreeSet<>();
for (PoiUIFilter filter : filters)
if (filter.isStandardFilter() && filter.filterId.startsWith(PoiUIFilter.STD_PREFIX))
for (PoiUIFilter filter : filters) {
if (filter.isStandardFilter() && filter.filterId.startsWith(PoiUIFilter.STD_PREFIX)) {
standardFilters.add(filter);
}
}
if (!standardFilters.isEmpty()) {
PoiUIFilter standardFiltersCombined = new PoiUIFilter(
null, app, app.getPoiFilters().getFiltersName(standardFilters));
for (PoiUIFilter f : standardFilters)
for (PoiUIFilter f : standardFilters) {
standardFiltersCombined.combineWithPoiFilter(f);
}
filters.removeAll(standardFilters);
filters.add(standardFiltersCombined);
}
@ -587,10 +590,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
@Override
public int compareTo(@NonNull PoiUIFilter another) {
if (another.filterId.equals(this.filterId))
if (another.filterId.equals(this.filterId)) {
return 0;
else
} else {
return this.name.compareTo(another.name);
}
}
public interface AmenityNameFilter {

View file

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