diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index 38fe091e89..bc81ca667e 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -329,7 +329,7 @@ public class RouteDataObject { public String getDestinationName(String lang, boolean transliterate, boolean direction){ //Issue #3289: Treat destination:ref like a destination, not like a ref String destRef = ((getDestinationRef(direction) == null) || getDestinationRef(direction).equals(getRef(lang, transliterate, direction))) ? "" : getDestinationRef(direction); - String destRef1 = (destRef != null && destRef.isEmpty()) ? "" : destRef + ", "; + String destRef1 = Algorithms.isEmpty(destRef) ? "" : destRef + ", "; if(names != null) { int[] kt = names.keys(); @@ -373,7 +373,7 @@ public class RouteDataObject { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault); } } - return destRef != null && destRef.isEmpty() ? null : destRef; + return Algorithms.isEmpty(destRef) ? null : destRef; } public int getPoint31XTile(int i) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 1a80d43b1f..00bdd97e2d 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -412,8 +412,8 @@ public class OsmandApplication extends MultiDexApplication { if (defaultLocale == null) { defaultLocale = Locale.getDefault(); } - if (lang != null && !lang.isEmpty()) { - if (country != null && !country.isEmpty()) { + if (!Algorithms.isEmpty(lang)) { + if (!Algorithms.isEmpty(country)) { preferredLocale = new Locale(lang, country); } else { preferredLocale = new Locale(lang); @@ -421,9 +421,9 @@ public class OsmandApplication extends MultiDexApplication { } Locale selectedLocale = null; - if (lang != null && !lang.isEmpty() && !config.locale.equals(preferredLocale)) { + if (!Algorithms.isEmpty(lang) && !config.locale.equals(preferredLocale)) { selectedLocale = preferredLocale; - } else if (lang != null && lang.isEmpty() && defaultLocale != null && Locale.getDefault() != defaultLocale) { + } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { selectedLocale = defaultLocale; preferredLocale = null; } @@ -807,17 +807,17 @@ public class OsmandApplication extends MultiDexApplication { } return s; } - + public void setLanguage(Context context) { if (preferredLocale != null) { Configuration config = context.getResources().getConfiguration(); String lang = preferredLocale.getLanguage(); - if (!lang.isEmpty() && !config.locale.getLanguage().equals(lang)) { + if (!Algorithms.isEmpty(lang) && !config.locale.getLanguage().equals(lang)) { preferredLocale = new Locale(lang); Locale.setDefault(preferredLocale); config.locale = preferredLocale; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); - } else if(lang.isEmpty() && defaultLocale != null && Locale.getDefault() != defaultLocale) { + } else if (Algorithms.isEmpty(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { Locale.setDefault(defaultLocale); config.locale = defaultLocale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 8b57c68e49..ff7039702e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -210,10 +210,11 @@ public class SavingTrackHelper extends SQLiteOpenHelper { // save file for (final Map.Entry entry : data.entrySet()) { final String f = entry.getKey(); + GPXFile gpx = entry.getValue(); log.debug("Filename: " + f); File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT); - if (!entry.getValue().isEmpty()) { - WptPt pt = entry.getValue().findPointToShow(); + if (!gpx.isEmpty()) { + WptPt pt = gpx.findPointToShow(); String fileName = f + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time)); //$NON-NLS-1$ Integer trackStorageDirectory = ctx.getSettings().TRACK_STORAGE_DIRECTORY.get(); if (!OsmandSettings.REC_DIRECTORY.equals(trackStorageDirectory)) { @@ -236,13 +237,12 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } } - Exception warn = GPXUtilities.writeGpxFile(fout, entry.getValue()); + Exception warn = GPXUtilities.writeGpxFile(fout, gpx); if (warn != null) { warnings.add(warn.getMessage()); return new SaveGpxResult(warnings, new ArrayList()); } - GPXFile gpx = entry.getValue(); GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified()); GpxDataItem item = new GpxDataItem(fout, analysis); ctx.getGpxDbHelper().add(item); diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 8190570c2a..09d2064284 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -513,10 +513,9 @@ public class ImportHelper { private File getFileToSave(final String fileName, final File importDir, final WptPt pt) { final StringBuilder builder = new StringBuilder(fileName); - if (fileName != null && fileName.isEmpty()) { + if (Algorithms.isEmpty(fileName)) { builder.append("import_").append(new SimpleDateFormat("HH-mm_EEE", Locale.US).format(new Date(pt.time))).append(GPX_FILE_EXT); //$NON-NLS-1$ - } - if (fileName.endsWith(KML_SUFFIX)) { + } else if (fileName.endsWith(KML_SUFFIX)) { builder.replace(builder.length() - KML_SUFFIX.length(), builder.length(), GPX_FILE_EXT); } else if (fileName.endsWith(KMZ_SUFFIX)) { builder.replace(builder.length() - KMZ_SUFFIX.length(), builder.length(), GPX_FILE_EXT); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index fbf1ae9b96..55b24b7ed4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -427,7 +427,6 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { f.setArguments(args); f.show(getChildFragmentManager(), "exceedDialog"); } else if (TextUtils.isEmpty(poiTypeEditText.getText())) { - new HashSet<>(editPoiData.getTagValues().keySet()); if (Algorithms.isEmpty(editPoiData.getTag(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()))) { SaveExtraValidationDialogFragment f = new SaveExtraValidationDialogFragment(); Bundle args = new Bundle();