From 24184fa7cd75bd46ae8a8608daf06c259b7dcb44 Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Mon, 12 Aug 2024 11:49:19 -0700 Subject: [PATCH] [NPE] Skip all apps icon preinflatioino on bg thread if layout manager is set to null Fix: 355192472 Test: presubmit Flag: NONE - bug fix Change-Id: Icdac63c58983cd7bada5d75f0e257d45d48a8d2e --- .../launcher3/recyclerview/AllAppsRecyclerViewPool.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt index e317824f76..6ff51ca527 100644 --- a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt +++ b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt @@ -108,6 +108,11 @@ class AllAppsRecyclerViewPool : RecycledViewPool() { if (task?.canceled == true) { break } + // If activeRv's layout manager has been reset to null on main thread, skip + // the preinflation as we cannot generate correct LayoutParams + if (activeRv.layoutManager == null) { + break + } list.add( adapter.createViewHolder(activeRv, BaseAllAppsAdapter.VIEW_TYPE_ICON) )