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() { listView.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
final View v = listView.getChildAt(0); final int index = position - listView.getFirstVisiblePosition();
final int centerX = v.getWidth() / 2; if (index >= 0 && index < listView.getChildCount()) {
final int centerY = v.getHeight() / 2; final View v = listView.getChildAt(index);
highlight.setHotspot(centerX, centerY); final int centerX = v.getWidth() / 2;
v.setPressed(true); final int centerY = v.getHeight() / 2;
v.setPressed(false); highlight.setHotspot(centerX, centerY);
v.setPressed(true);
v.setPressed(false);
}
} }
}, DELAY_HIGHLIGHT_DURATION_MILLIS); }, DELAY_HIGHLIGHT_DURATION_MILLIS);
} }