From 26c31292012868d7e9889f6ecee7559c61caa5b2 Mon Sep 17 00:00:00 2001 From: hunterstich Date: Mon, 16 Oct 2023 09:52:58 -0700 Subject: [PATCH] [Carousel] Fixed crash when recyclerview has a size of zero. Resolves https://github.com/material-components/material-components-android/issues/3634 PiperOrigin-RevId: 573843130 --- .../google/android/material/carousel/CarouselLayoutManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/java/com/google/android/material/carousel/CarouselLayoutManager.java b/lib/java/com/google/android/material/carousel/CarouselLayoutManager.java index 962e46681b5..afc8819430b 100644 --- a/lib/java/com/google/android/material/carousel/CarouselLayoutManager.java +++ b/lib/java/com/google/android/material/carousel/CarouselLayoutManager.java @@ -254,7 +254,7 @@ public void onDetachedFromWindow(RecyclerView view, Recycler recycler) { @Override public void onLayoutChildren(Recycler recycler, State state) { - if (state.getItemCount() <= 0) { + if (state.getItemCount() <= 0 || getContainerSize() <= 0f) { removeAndRecycleAllViews(recycler); currentFillStartPosition = 0; return;