Fix searched item isn't highlighted
The searched item isn't highlighted.
To fix this issue, the highlight process should be posted
as Runnable object.
Bug: 31983855
Test: manual - search a item in Settings app
Change-Id: I0dcc5bb52b2faa0a23991459885d8dfcaed0f226
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index 4796a9e..d910825 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -757,14 +757,16 @@
super.onBindViewHolder(holder, position);
if (position == mHighlightPosition) {
View v = holder.itemView;
- if (v.getBackground() != null) {
- final int centerX = v.getWidth() / 2;
- final int centerY = v.getHeight() / 2;
- v.getBackground().setHotspot(centerX, centerY);
- }
- v.setPressed(true);
- v.setPressed(false);
- mHighlightPosition = -1;
+ v.post(() -> {
+ if (v.getBackground() != null) {
+ final int centerX = v.getWidth() / 2;
+ final int centerY = v.getHeight() / 2;
+ v.getBackground().setHotspot(centerX, centerY);
+ }
+ v.setPressed(true);
+ v.setPressed(false);
+ mHighlightPosition = -1;
+ });
}
}
}