From 608d93a8fa8000003d3579d3810cb5b651a94f56 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:23:35 -0500 Subject: [PATCH] Performance: Replace '.equals("")' with '.isEmpty' --- .../main/java/net/osmand/binary/RouteDataObject.java | 4 ++-- .../osmand/render/RenderingRulesStoragePrinter.java | 2 +- .../net/osmand/render/RenderingRulesTransformer.java | 2 +- .../java/net/osmand/util/GeoPointParserUtil.java | 2 +- OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java | 10 +++++----- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 12 ++++++------ .../src/net/osmand/plus/activities/HelpActivity.java | 2 +- .../plus/activities/actions/StartGPSStatus.java | 2 +- .../net/osmand/plus/dialogs/ConfigureMapMenu.java | 4 ++-- .../osmand/plus/helpers/MapMarkerDialogHelper.java | 2 +- .../net/osmand/plus/importfiles/ImportHelper.java | 2 +- .../plus/mapillary/MapillaryFiltersFragment.java | 10 +++++----- .../osmand/plus/mapillary/MapillaryVectorLayer.java | 2 +- ...SelectWptCategoriesBottomSheetDialogFragment.java | 2 +- .../mapmarkers/adapters/MapMarkersActiveAdapter.java | 2 +- .../mapmarkers/adapters/MapMarkersGroupsAdapter.java | 4 ++-- .../adapters/MapMarkersHistoryAdapter.java | 2 +- .../mapmarkers/adapters/MapMarkersListAdapter.java | 2 +- .../mapmarkers/adapters/TracksGroupsAdapter.java | 2 +- .../osmedit/dialogs/SendPoiBottomSheetFragment.java | 2 +- .../plus/osmedit/dialogs/SendPoiDialogFragment.java | 4 ++-- .../osmand/plus/render/MapRenderRepositories.java | 2 +- OsmAnd/src/net/osmand/plus/render/TextRenderer.java | 2 +- .../net/osmand/plus/resources/ResourceManager.java | 2 +- .../AddPointBottomSheetDialog.java | 2 +- .../bottomsheets/BooleanPreferenceBottomSheet.java | 4 ++-- .../bottomsheets/SelectFolderBottomSheet.java | 2 +- .../plus/settings/fragments/DataStorageFragment.java | 2 +- .../fragments/ProfileAppearanceFragment.java | 2 +- .../src/net/osmand/plus/srtmplugin/SRTMPlugin.java | 4 ++-- .../plus/views/AddGpxPointBottomSheetHelper.java | 2 +- 31 files changed, 50 insertions(+), 50 deletions(-) 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 bfe638d394..38fe091e89 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 = ("".equals(destRef)) ? "" : destRef + ", "; + String destRef1 = (destRef != null && destRef.isEmpty()) ? "" : destRef + ", "; if(names != null) { int[] kt = names.keys(); @@ -373,7 +373,7 @@ public class RouteDataObject { return destRef1 + ((transliterate) ? TransliterationHelper.transliterate(destinationDefault) : destinationDefault); } } - return "".equals(destRef) ? null : destRef; + return destRef != null && destRef.isEmpty() ? null : destRef; } public int getPoint31XTile(int i) { diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStoragePrinter.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStoragePrinter.java index 3e36ae4e71..3acdeade26 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStoragePrinter.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesStoragePrinter.java @@ -221,7 +221,7 @@ public class RenderingRulesStoragePrinter { mp+=", "; } } - if(mp.equals("")) { + if(mp.isEmpty()) { mp = "java.util.Collections.EMPTY_MAP"; } else { mp = "createMap(" +mp +")"; diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesTransformer.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesTransformer.java index b41a741909..cd18ad958f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesTransformer.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRulesTransformer.java @@ -80,7 +80,7 @@ public class RenderingRulesTransformer { for (int i = 0; i < nl.getLength();) { Element app = (Element) nl.item(i); String pt = app.getAttribute("pattern"); - if (!pt.equals("")) { + if (!pt.isEmpty()) { if (!patterns.containsKey(pt)) { throw new IllegalStateException("Pattern '" + pt + "' is not defined"); } diff --git a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java index 31605c33a2..951ae870e2 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java @@ -62,7 +62,7 @@ public class GeoPointParserUtil { private static Map getQueryParameters(String query) { final LinkedHashMap map = new LinkedHashMap(); - if (query != null && !query.equals("")) { + if (query != null && !query.isEmpty()) { String[] params = query.split("[&/]"); for (String p : params) { String[] keyValue = p.split("="); diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 2cd9a6ab4a..992a0e42c6 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -361,7 +361,7 @@ public class FavouritesDbHelper { } public boolean addFavourite(FavouritePoint p, boolean saveImmediately) { - if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) { + if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) { return true; } if (!p.isAddressSpecified()) { @@ -370,7 +370,7 @@ public class FavouritesDbHelper { context.getSettings().SHOW_FAVORITES.set(true); FavoriteGroup group = getOrCreateGroup(p, 0); - if (!p.getName().equals("")) { + if (!p.getName().isEmpty()) { p.setVisible(group.visible); if (FavouritePoint.SpecialPointType.PARKING.equals(p.getSpecialPointType())) { p.setColor(ContextCompat.getColor(context, R.color.parking_icon_background)); @@ -970,7 +970,7 @@ public class FavouritesDbHelper { p.setName(name); p.setCategory(cat); FavoriteGroup group = getOrCreateGroup(p, 0); - if (!name.equals("")) { + if (!name.isEmpty()) { p.setLatitude(query.getDouble(2)); p.setLongitude(query.getDouble(3)); group.points.add(p); @@ -1014,7 +1014,7 @@ public class FavouritesDbHelper { public boolean addFavouriteDB(FavouritePoint p) { - if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) { + if (p.getName().isEmpty() && flatGroups.containsKey(p.getCategory())) { return true; } SQLiteConnection db = openConnection(false); @@ -1024,7 +1024,7 @@ public class FavouritesDbHelper { "INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[]{p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$ FavoriteGroup group = getOrCreateGroup(p, 0); - if (!p.getName().equals("")) { + if (!p.getName().isEmpty()) { p.setVisible(group.visible); p.setColor(group.color); group.points.add(p); diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 97cfeb662a..1a80d43b1f 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 (!"".equals(lang)) { - if (!"".equals(country)) { + if (lang != null && !lang.isEmpty()) { + if (country != null && !country.isEmpty()) { preferredLocale = new Locale(lang, country); } else { preferredLocale = new Locale(lang); @@ -421,9 +421,9 @@ public class OsmandApplication extends MultiDexApplication { } Locale selectedLocale = null; - if (!"".equals(lang) && !config.locale.equals(preferredLocale)) { + if (lang != null && !lang.isEmpty() && !config.locale.equals(preferredLocale)) { selectedLocale = preferredLocale; - } else if ("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { + } else if (lang != null && lang.isEmpty() && defaultLocale != null && Locale.getDefault() != defaultLocale) { selectedLocale = defaultLocale; preferredLocale = null; } @@ -812,12 +812,12 @@ public class OsmandApplication extends MultiDexApplication { if (preferredLocale != null) { Configuration config = context.getResources().getConfiguration(); String lang = preferredLocale.getLanguage(); - if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) { + if (!lang.isEmpty() && !config.locale.getLanguage().equals(lang)) { preferredLocale = new Locale(lang); Locale.setDefault(preferredLocale); config.locale = preferredLocale; context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); - } else if("".equals(lang) && defaultLocale != null && Locale.getDefault() != defaultLocale) { + } else if(lang.isEmpty() && 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/HelpActivity.java b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java index b7b3044f97..7eb21d4ee8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java @@ -176,7 +176,7 @@ public class HelpActivity extends OsmandActionBarActivity implements AdapterView "feature_articles/osmand-3-8-released.html")); String releasedate = ""; - if (!this.getString(R.string.app_edition).equals("")) { + if (!this.getString(R.string.app_edition).isEmpty()) { releasedate = ", " + this.getString(R.string.shared_string_release).toLowerCase() + ": " + this.getString(R.string.app_edition); } String version = Version.getFullVersion(getMyApplication()) + releasedate; diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java index 0c64258825..79abd4190a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java @@ -165,7 +165,7 @@ public class StartGPSStatus extends OsmAndAction { // if (g.activity.length() == 0) { PackageManager pm = mapActivity.getPackageManager(); try { - String appName = !g.paidAppName.equals("") && + String appName = !g.paidAppName.isEmpty() && g.installed(mapActivity, g.paidAppName) ? g.paidAppName : g.appName; intent = pm.getLaunchIntentForPackage(appName); } catch (RuntimeException e) { diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 6e3b7fba8a..ca7382dd6e 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -481,7 +481,7 @@ public class ConfigureMapMenu { .createItem()); String localeDescr = activity.getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get(); - localeDescr = localeDescr == null || localeDescr.equals("") ? activity.getString(R.string.local_map_names) + localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity.getString(R.string.local_map_names) : localeDescr; adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_locale, activity) .setId(MAP_LANGUAGE_ID) @@ -570,7 +570,7 @@ public class ConfigureMapMenu { txtIds[index]); refreshMapComplete(activity); String localeDescr = txtIds[index]; - localeDescr = localeDescr == null || localeDescr.equals("") ? activity + localeDescr = localeDescr == null || localeDescr.isEmpty() ? activity .getString(R.string.local_map_names) : localeDescr; adapter.getItem(pos).setDescription(localeDescr); ad.notifyDataSetInvalidated(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java index a90247e644..ab40f14407 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/MapMarkerDialogHelper.java @@ -101,7 +101,7 @@ public class MapMarkerDialogHelper { String desc = OsmAndFormatter.getFormattedDate(app, marker.creationDate); String markerGroupName = marker.groupName; if (markerGroupName != null) { - if (markerGroupName.equals("")) { + if (markerGroupName.isEmpty()) { markerGroupName = app.getString(R.string.shared_string_favorites); } desc += " • " + markerGroupName; diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 16fb083f13..8190570c2a 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -513,7 +513,7 @@ public class ImportHelper { private File getFileToSave(final String fileName, final File importDir, final WptPt pt) { final StringBuilder builder = new StringBuilder(fileName); - if ("".equals(fileName)) { + if (fileName != null && fileName.isEmpty()) { 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)) { diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java index 60abf651ba..6b03cd3a6a 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java @@ -123,7 +123,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view); textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication())); String selectedUsername = settings.MAPILLARY_FILTER_USERNAME.get(); - if (!selectedUsername.equals("") && settings.USE_MAPILLARY_FILTER.get()) { + if (!selectedUsername.isEmpty() && settings.USE_MAPILLARY_FILTER.get()) { textView.setText(selectedUsername); textView.setSelection(selectedUsername.length()); } @@ -261,16 +261,16 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { String dateFrom = dateFromEt.getText().toString(); String dateTo = dateToEt.getText().toString(); - if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("") || settings.MAPILLARY_FILTER_PANO.get()) { + if (!settings.MAPILLARY_FILTER_USERNAME.get().isEmpty() || !dateFrom.isEmpty() || !dateTo.isEmpty() || settings.MAPILLARY_FILTER_PANO.get()) { settings.USE_MAPILLARY_FILTER.set(true); } - if (dateFrom.equals("")) { + if (dateFrom.isEmpty()) { settings.MAPILLARY_FILTER_FROM_DATE.set(0L); } - if (dateTo.equals("")) { + if (dateTo.isEmpty()) { settings.MAPILLARY_FILTER_TO_DATE.set(0L); } - if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) { + if (!username.isEmpty() && settings.MAPILLARY_FILTER_USERNAME.get().isEmpty()) { view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE); } else { mapActivity.getDashboard().hideDashboard(); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index 512281a079..51c12f07aa 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -205,7 +205,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont long to = settings.MAPILLARY_FILTER_TO_DATE.get(); boolean pano = settings.MAPILLARY_FILTER_PANO.get(); - if (!userKey.equals("")) { + if (!userKey.isEmpty()) { String key = (String) userData.get("userkey"); if (!userKey.equals(key)) { return true; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index 0c887488b7..08db4d40fc 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -99,7 +99,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee .setCompoundButtonColorId(activeColorResId) .setDescription(String.valueOf(entry.getValue().size())) .setIcon(getContentIcon(R.drawable.ic_action_folder)) - .setTitle(category.equals("") ? getString(R.string.shared_string_waypoints) : category) + .setTitle(category.isEmpty() ? getString(R.string.shared_string_waypoints) : category) .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_checkbox_56dp) .setTag(category) .setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index c1e85387b3..2fa206d08f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -131,7 +131,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter it = categories.iterator(); while (it.hasNext()) { String category = it.next(); - if (category.equals("")) { + if (category.isEmpty()) { category = app.getResources().getString(R.string.shared_string_waypoints); } sb.append(category); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java index 87d8e54303..ba407b23f9 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersHistoryAdapter.java @@ -145,7 +145,7 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter it = categories.iterator(); while (it.hasNext()) { String category = it.next(); - if (!category.equals("")) { + if (!category.isEmpty()) { sb.append(category); if (it.hasNext()) { sb.append(", "); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java index 748d9504f0..159f64fad4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiBottomSheetFragment.java @@ -234,7 +234,7 @@ public class SendPoiBottomSheetFragment extends MenuBottomSheetDialogFragment { if (modifiedItemsOutOfLimit != 0) { comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ") .concat(getString(R.string.items_modified)).concat("."); - } else if (!comment.equals("")) { + } else if (!comment.isEmpty()) { comment = comment.concat("."); } return comment; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java index d402cdfe49..adfb8a2b60 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/SendPoiDialogFragment.java @@ -84,7 +84,7 @@ public class SendPoiDialogFragment extends DialogFragment { messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE); messageEditText.setVisibility(hasPOI ? View.VISIBLE : View.GONE); closeChangeSetCheckBox.setVisibility(hasPOI ? View.VISIBLE : View.GONE); - closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.equals("")); + closeChangeSetCheckBox.setChecked(hasPOI && !defaultChangeSet.isEmpty()); view.findViewById(R.id.osm_note_header).setVisibility(hasPOI ? View.GONE : View.VISIBLE); uploadAnonymously.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override @@ -233,7 +233,7 @@ public class SendPoiDialogFragment extends DialogFragment { } if (modifiedItemsOutOfLimit != 0) { comment = comment.concat("; ").concat(modifiedItemsOutOfLimit + " ").concat(getString(R.string.items_modified)).concat("."); - } else if (!comment.equals("")){ + } else if (!comment.isEmpty()){ comment = comment.concat("."); } return comment; diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 26985faa0a..0b07a41c4f 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -728,7 +728,7 @@ public class MapRenderRepositories { currentRenderingContext.height = requestedBox.getPixHeight(); currentRenderingContext.nightMode = nightMode; if(requestedBox.getZoom() <= zoomToOverviewLocalNames && - "".equals(prefs.MAP_PREFERRED_LOCALE.get())) { + prefs.MAP_PREFERRED_LOCALE.get() != null && prefs.MAP_PREFERRED_LOCALE.get().isEmpty()) { currentRenderingContext.preferredLocale = app.getLanguage(); currentRenderingContext.transliterate = !languagesNotTransliterateOnBasemap.contains(app.getLanguage()); diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index 9e338d08ec..f7bb2cd349 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -438,7 +438,7 @@ public class TextRenderer { String nameTag = isName ? "" : obj.getMapIndex().decodeType(tag).tag; boolean skip = false; // not completely correct we should check "name"+rc.preferredLocale - if (isName && !rc.preferredLocale.equals("") && + if (isName && !rc.preferredLocale.isEmpty() && map.containsKey(obj.getMapIndex().nameEnEncodingType)) { skip = true; } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index b70ded655b..8e7857b33a 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -486,7 +486,7 @@ public class ResourceManager { try { progress.startTask(context.getString(R.string.installing_new_resources), -1); AssetManager assetManager = context.getAssets(); - boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().equals(""); + boolean isFirstInstall = context.getSettings().PREVIOUS_INSTALLED_VERSION.get().isEmpty(); unpackBundledAssets(assetManager, applicationDataDir, progress, isFirstInstall || forceUpdate); context.getSettings().PREVIOUS_INSTALLED_VERSION.set(fv); copyRegionsBoundaries(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index 7257e2ec00..7c70ba8dfb 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -651,7 +651,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { ((FavouritePoint) item).getSpecialPointType().getIconId(app), iconColor)); favoriteViewHolder.description.setText(point.getDescription()); } else { - if (point.getCategory().equals("")) { + if (point.getCategory().isEmpty()) { favoriteViewHolder.description.setText(R.string.shared_string_favorites); } else { favoriteViewHolder.description.setText(point.getCategory()); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index f34d6938fb..3730833d4d 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -59,9 +59,9 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { final BooleanPreference pref = (BooleanPreference) preference; CharSequence summaryOn = switchPreference.getSummaryOn(); CharSequence summaryOff = switchPreference.getSummaryOff(); - final String on = summaryOn == null || summaryOn.toString().equals("") + final String on = summaryOn == null || summaryOn.toString().isEmpty() ? getString(R.string.shared_string_enabled) : summaryOn.toString(); - final String off = summaryOff == null || summaryOff.toString().equals("") + final String off = summaryOff == null || summaryOff.toString().isEmpty() ? getString(R.string.shared_string_disabled) : summaryOff.toString(); final int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); final int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SelectFolderBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SelectFolderBottomSheet.java index 6a3cc193b2..10c09021b9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SelectFolderBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/SelectFolderBottomSheet.java @@ -158,7 +158,7 @@ public class SelectFolderBottomSheet extends BasePreferenceBottomSheet { Fragment fragment = getTargetFragment(); if (fragment instanceof BaseSettingsFragment) { String newPath = editText.getText().toString().trim(); - if (!newPath.equals("")) { + if (!newPath.isEmpty()) { boolean pathChanged = !newPath.equals(currentPath); Bundle bundle = new Bundle(); bundle.putBoolean(TAG, true); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java index 842b53e2fa..de95eaeade 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DataStorageFragment.java @@ -241,7 +241,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto divider.setVisibility(View.VISIBLE); secondPart.setVisibility(View.VISIBLE); String space = getSpaceDescription(item.getDirectory()); - if (!space.equals("")) { + if (!space.isEmpty()) { space = space.replaceAll(" • ", " • "); tvSummary.setText(space); tvSummary.setVisibility(View.VISIBLE); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index bc3092d963..8e4dfc14c0 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -897,7 +897,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment { } private boolean nameIsEmpty() { - return changedProfile.name.trim().equals(""); + return changedProfile.name.trim().isEmpty(); } private void disableSaveButtonWithErrorMessage(String errorMessage) { diff --git a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java index 9e66f72f74..a8dc02135b 100644 --- a/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java +++ b/OsmAnd/src/net/osmand/plus/srtmplugin/SRTMPlugin.java @@ -137,9 +137,9 @@ public class SRTMPlugin extends OsmandPlugin { public boolean init(@NonNull final OsmandApplication app, Activity activity) { OsmandSettings settings = app.getSettings(); CommonPreference pref = settings.getCustomRenderProperty("contourLines"); - if (pref.get().equals("")) { + if (pref.get().isEmpty()) { for (ApplicationMode m : ApplicationMode.allPossibleValues()) { - if (pref.getModeValue(m).equals("")) { + if (pref.getModeValue(m).isEmpty()) { pref.setModeValue(m, "13"); } } diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index b43cab4492..9408ec5537 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -86,7 +86,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { } public void setTitle(String title) { - if (title.equals("")) { + if (title.isEmpty()) { if (pointDescription.isWpt()) { title = mapActivity.getString(R.string.waypoint_one); } else if (pointDescription.isRte()) {