Skip to content
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

Improve KDoc on ActivityLifecycleEvent by explaining ordering semantics. #586

Merged
merged 1 commit into from
May 16, 2023

Conversation

psteiger
Copy link
Contributor

@psteiger psteiger commented May 16, 2023

Also, a couple of minor fixes:

  • A small warning on RibActivity against importing android.R.
  • Replaces deprecated String.toLowerCase() and String.capitalize() with the equivalent String.lowercase() and String.replaceFirstChar(Char::titlecase).

@psteiger psteiger force-pushed the android-docs branch 2 times, most recently from bfcb313 to 5d21e2c Compare May 16, 2023 01:12
Also, a couple of minor fixes:
- A small warning on `RibActivity` against importing `android.R`.
- Replaces deprecated `String.toLowerCase()` and `String.capitalize()` with the equivalent `String.lowercase()` and `String.replaceFirstChar(Char::titlecase)`.
@psteiger psteiger changed the title Add KDoc on ActivityLifecycleEvent explaining ordering semantics. Improve KDoc on ActivityLifecycleEvent by explaining ordering semantics. May 16, 2023
@psteiger psteiger added the Android Android related tickets label May 16, 2023
*
* The equality does not hold:
* ```
* assertThat(a == b).isFalse()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should they be?

Copy link
Contributor Author

@psteiger psteiger May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, no, because Android bundles also do not implement equals. From its Javadoc:

Warning: Note that [Bundle](https://developer.android.com/reference/android/os/Bundle) is a lazy container 
and as such it does NOT implement 
[Object.equals(java.lang.Object)](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)) 
or [Object.hashCode()](https://developer.android.com/reference/java/lang/Object#hashCode()).

@@ -79,7 +109,7 @@ private constructor(
Type.DESTROY -> DESTROY_EVENT
else ->
throw IllegalArgumentException(
"Use the createOn${type.name.toLowerCase().capitalize()}Event() method for this type!",
"Use the createOn${type.name.lowercase().replaceFirstChar(Char::titlecase)}Event() method for this type!",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of surprised they replaced capitalize with this, it's much more verbose and less obvious for folks.

Copy link
Contributor Author

@psteiger psteiger May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the drop in replacement is even more verbose (suggested by ReplaceWith):

replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }

From googling It, it seems the original deprecated capitalize function had issues with

  1. Not taking a locale (deprecated in favor of capitalize(Locale)
  2. capitalize(Locale) is also deprecated, because of surprising behavior on characters that are one char in Unicode, but actually two chars in the natural language.

Both of which don't matter at this particular call site of ours

@psteiger psteiger merged commit b0e4155 into uber:main May 16, 2023
@psteiger psteiger deleted the android-docs branch May 18, 2023 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android related tickets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants