conradchen 58ceeab63c [SnackBar] Handle anchor view properly so no memory leak will happen
The anchor view can be detached even when the snack bar (or any
transient bottom bar) is showing. If this situation happens the
global layout listener it registers with the anchor view will
become not removable due to a bug/intended behavior of Android View's
implementation.

We need to remove the listener when the anchor view is detached to
fix the issue.

This CL also refactors the whole implementation of anchor view and consolidates
the anchoring/unanchoring logic to improve readability and robustness of it.

Resolves https://github.com/material-components/material-components-android/issues/2042

PiperOrigin-RevId: 382603130
2021-07-02 08:15:03 -04:00
..