Merge "Use correct list index for search highlighting" into lmp-dev

This commit is contained in:
Alan Viverette
2014-09-08 19:47:53 +00:00
committed by Android (Google) Code Review

View File

@@ -230,13 +230,16 @@ 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();
if (index >= 0 && index < listView.getChildCount()) {
final View v = listView.getChildAt(index);
final int centerX = v.getWidth() / 2; final int centerX = v.getWidth() / 2;
final int centerY = v.getHeight() / 2; final int centerY = v.getHeight() / 2;
highlight.setHotspot(centerX, centerY); highlight.setHotspot(centerX, centerY);
v.setPressed(true); v.setPressed(true);
v.setPressed(false); v.setPressed(false);
} }
}
}, DELAY_HIGHLIGHT_DURATION_MILLIS); }, DELAY_HIGHLIGHT_DURATION_MILLIS);
} }
}); });