Skip to content

Commit

Permalink
[TextInputLayout] Fixed shouldAnimateCaptionView() returning true whe…
Browse files Browse the repository at this point in the history
…n captionText is null.

captionView.getText() doesn't ever return null (only "" if it's empty), so changed captionText parameter to be @nonnull

PiperOrigin-RevId: 406358148
  • Loading branch information
leticiarossi authored and veganafro committed Oct 29, 2021
1 parent b808484 commit c352dfd
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -146,7 +146,7 @@ void hideHelperText() {
captionToShow = CAPTION_STATE_NONE;
}
updateCaptionViewsVisibility(
captionDisplayed, captionToShow, shouldAnimateCaptionView(helperTextView, null));
captionDisplayed, captionToShow, shouldAnimateCaptionView(helperTextView, ""));
}

void showError(final CharSequence errorText) {
Expand Down Expand Up @@ -176,19 +176,19 @@ void hideError() {
}
}
updateCaptionViewsVisibility(
captionDisplayed, captionToShow, shouldAnimateCaptionView(errorView, null));
captionDisplayed, captionToShow, shouldAnimateCaptionView(errorView, ""));
}

/**
* Check if the caption view should animate. Only animate the caption view if we're enabled, laid
* out, and have a different caption message.
*
* @param captionView The view that contains text for the caption underneath the text input area
* @param captionText The text for the caption view
* @param captionText The text for the caption view, empty if none
* @return Whether the view should animate when setting the caption
*/
private boolean shouldAnimateCaptionView(
@Nullable TextView captionView, @Nullable final CharSequence captionText) {
@Nullable TextView captionView, @NonNull final CharSequence captionText) {
return ViewCompat.isLaidOut(textInputView)
&& textInputView.isEnabled()
&& (captionToShow != captionDisplayed
Expand Down

0 comments on commit c352dfd

Please sign in to comment.