From c4772636db92a557dc7823c940258fc2cbb80139 Mon Sep 17 00:00:00 2001 From: Qi Ding Date: Sun, 18 Sep 2016 17:03:47 +0800 Subject: [PATCH] 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 --- .../android/settings/SettingsPreferenceFragment.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index 4796a9e997..d910825df9 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -757,14 +757,16 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF 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; + }); } } } -- 2.11.0