-
-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[android] Remove Android Studio warnings #8073
Conversation
@@ -406,11 +406,10 @@ void bind(@NonNull SectionPosition position, | |||
final long trackId = sectionsDataSource.getTrackId(position); | |||
Track track = BookmarkManager.INSTANCE.getTrack(trackId); | |||
mName.setText(track.getName()); | |||
mDistance.setText(new StringBuilder().append(mDistance.getContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Was it done deliberately to speed up the code? Is there any comment in git blame?
- Does it make sense to cache .getString(R.string.length) result here and maybe in some other places, where it is called repeatedly for many objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing in git blame
It's the only place using .getString(R.string.length)
@@ -105,17 +105,15 @@ public String getDescription() | |||
@Override | |||
public String toString() | |||
{ | |||
final StringBuilder sb = new StringBuilder("BookmarkCategory{"); | |||
sb.append("mId=").append(mId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that the nee code is faster? Is there any documentation or benchmark about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right
In the most of case, StringBuilder is more efficient -> https://dip-mazumder.medium.com/stringbuilder-vs-string-in-java-a-guide-for-optimal-memory-usage-4a284d8243ea
I have reverted changes about StringBuilder
@@ -102,8 +103,7 @@ private FeatureCategory[] makeFeatureCategoriesFromTypes(@NonNull String[] creat | |||
categories[i] = new FeatureCategory(creatableTypes[i], localizedType); | |||
} | |||
|
|||
Arrays.sort(categories, (lhs, rhs) -> | |||
lhs.getLocalizedTypeName().compareTo(rhs.getLocalizedTypeName())); | |||
Arrays.sort(categories, Comparator.comparing(FeatureCategory::getLocalizedTypeName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, why is it better?
android/app/src/main/java/app/organicmaps/util/log/LogsManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jean-BaptisteC <jeanbaptiste.charron@outlook.fr>
a5c394f
to
40a711a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
final DialogInterface.OnClickListener navigateToLoginHandler = (DialogInterface dialog, int which) -> { | ||
startActivity(new Intent(MwmActivity.this, OsmLoginActivity.class)); | ||
}; | ||
final DialogInterface.OnClickListener navigateToLoginHandler = (DialogInterface dialog, int which) -> startActivity(new Intent(MwmActivity.this, OsmLoginActivity.class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final DialogInterface.OnClickListener navigateToLoginHandler = (dialog, which) -> startActivity(new Intent(MwmActivity.this, OsmLoginActivity.class));
or
final DialogInterface.OnClickListener navigateToLoginHandler = (_, _) -> startActivity(new Intent(MwmActivity.this, OsmLoginActivity.class));
This PR fixes some Android Studio warnings:
.size == 0
byisEmpty()