From 3116dc918fa9b1a318596d1caaf40ece03bd00a1 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Mon, 9 Nov 2020 16:30:07 -0600 Subject: [PATCH] Resolve search scroll hightlight issue After getting the index of the first item that should be highlighted, Section decorator should not assume getChildAt(index) will return item at position. Instead use findViewHolderForAdapterPosition. Bug: 170665892 Change-Id: Id81d021bde8868184013e8d51e49af7842b64125 --- res/layout/search_result_settings_row.xml | 1 + src/com/android/launcher3/allapps/AllAppsGridAdapter.java | 3 +-- src/com/android/launcher3/allapps/AllAppsSectionDecorator.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/res/layout/search_result_settings_row.xml b/res/layout/search_result_settings_row.xml index 05f7561628..22c08bf58f 100644 --- a/res/layout/search_result_settings_row.xml +++ b/res/layout/search_result_settings_row.xml @@ -44,6 +44,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/search_line_spacing" + android:maxLines="1" android:textColor="?android:attr/textColorPrimary" android:textSize="@dimen/search_hero_title_size" /> diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index 5b4268111b..d04935223b 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -184,8 +184,7 @@ public class AllAppsGridAdapter extends || viewType == VIEW_TYPE_SEARCH_THUMBNAIL || viewType == VIEW_TYPE_SEARCH_ICON_ROW || viewType == VIEW_TYPE_SEARCH_ICON - || viewType == VIEW_TYPE_SEARCH_SUGGEST - || viewType == VIEW_TYPE_SEARCH_WIDGET_LIVE; + || viewType == VIEW_TYPE_SEARCH_SUGGEST; } } diff --git a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java index 3c81811e16..1d31975114 100644 --- a/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java +++ b/src/com/android/launcher3/allapps/AllAppsSectionDecorator.java @@ -98,7 +98,8 @@ public class AllAppsSectionDecorator extends RecyclerView.ItemDecoration { mAppsView.getActiveRecyclerView().getLayoutManager(); if (layoutManager.findFirstVisibleItemPosition() <= index && index < parent.getChildCount()) { - decorationHandler.onFocusDraw(c, parent.getChildAt(index)); + RecyclerView.ViewHolder vh = parent.findViewHolderForAdapterPosition(index); + if (vh != null) decorationHandler.onFocusDraw(c, vh.itemView); } } decorationHandler.reset();