Fix TextInputLayout setErrorEnabled() NPE
Caused by the animation end listener referencing
the now-null error TextView.
BUG: 21991987
Change-Id: Iacba13fb6d3a5d3fcf9069a73d94c91431f13fd4
diff --git a/design/src/android/support/design/widget/TextInputLayout.java b/design/src/android/support/design/widget/TextInputLayout.java
index 15173cc..4332d10 100644
--- a/design/src/android/support/design/widget/TextInputLayout.java
+++ b/design/src/android/support/design/widget/TextInputLayout.java
@@ -277,6 +277,10 @@
*/
public void setErrorEnabled(boolean enabled) {
if (mErrorEnabled != enabled) {
+ if (mErrorView != null) {
+ ViewCompat.animate(mErrorView).cancel();
+ }
+
if (enabled) {
mErrorView = new TextView(getContext());
mErrorView.setTextAppearance(getContext(), mErrorTextAppearance);
@@ -334,8 +338,7 @@
.setListener(new ViewPropertyAnimatorListenerAdapter() {
@Override
public void onAnimationEnd(View view) {
- mErrorView.setText(null);
- mErrorView.setVisibility(INVISIBLE);
+ view.setVisibility(INVISIBLE);
}
}).start();
}