Skip to content

Commit 6b35213

Browse files
pubiqqpekingme
authored andcommitted
[TabLayoutMediator] Don't try to detach an already detached TabLayout
Resolves #4547 GIT_ORIGIN_REV_ID=15c001c9fed1a70c0dc8adbe1477687c2b0a97ed PiperOrigin-RevId: 757914288
1 parent 8d044c4 commit 6b35213

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/java/com/google/android/material/tabs/TabLayoutMediator.java

+4
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ public void attach() {
147147
* called before {@link #attach()} when a ViewPager2's adapter is changed.
148148
*/
149149
public void detach() {
150+
if (!attached) {
151+
return;
152+
}
153+
150154
if (autoRefresh && adapter != null) {
151155
adapter.unregisterAdapterDataObserver(pagerAdapterObserver);
152156
pagerAdapterObserver = null;

0 commit comments

Comments
 (0)