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
This commit is contained in:
Qi Ding
2016-09-18 17:03:47 +08:00
committed by Yoshinori Hirano
parent 00a2619a10
commit c4772636db

View File

@@ -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;
});
}
}
}