Use correct list index for search highlighting

BUG: 14974443
Change-Id: Iad3d3efb2449fc61636c221bde92169293bf5356
This commit is contained in:
Alan Viverette
2014-09-08 12:40:59 -07:00
parent b5cc01342e
commit 2fed4d4256

View File

@@ -230,12 +230,15 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
listView.postDelayed(new Runnable() {
@Override
public void run() {
final View v = listView.getChildAt(0);
final int centerX = v.getWidth() / 2;
final int centerY = v.getHeight() / 2;
highlight.setHotspot(centerX, centerY);
v.setPressed(true);
v.setPressed(false);
final int index = position - listView.getFirstVisiblePosition();
if (index >= 0 && index < listView.getChildCount()) {
final View v = listView.getChildAt(index);
final int centerX = v.getWidth() / 2;
final int centerY = v.getHeight() / 2;
highlight.setHotspot(centerX, centerY);
v.setPressed(true);
v.setPressed(false);
}
}
}, DELAY_HIGHLIGHT_DURATION_MILLIS);
}