[PB2] Small bugfix

The button would not display after it got hidden once.

Bug: 7600384
Change-Id: I57f9f1191be3b8fff55dde7a2781dbef68a2df62
This commit is contained in:
Jean Chalard 2013-04-23 20:39:54 +09:00
parent b40a8c060f
commit d98f406dd3

View file

@ -203,19 +203,29 @@ public final class WordListPreference extends Preference {
@Override @Override
public void onClick(final View v) { public void onClick(final View v) {
final Button button = (Button)v.findViewById(R.id.wordlist_button); final Button button = (Button)v.findViewById(R.id.wordlist_button);
animateButton(button, ANIMATION_IN);
final ViewParent parent = v.getParent(); final ViewParent parent = v.getParent();
// Just in case something changed in the framework, test for the concrete class // Just in case something changed in the framework, test for the concrete class
if (!(parent instanceof ListView)) return; if (!(parent instanceof ListView)) return;
final ListView listView = (ListView)parent; final ListView listView = (ListView)parent;
final int myIndex = listView.indexOfChild(v) + listView.getFirstVisiblePosition(); final int myIndex = listView.indexOfChild(v) + listView.getFirstVisiblePosition();
if (NOT_AN_INDEX != sLastClickedIndex) { if (NOT_AN_INDEX != sLastClickedIndex) {
// If another button is showing, hide it
animateButton(getButtonForIndex(listView, sLastClickedIndex), ANIMATION_OUT); animateButton(getButtonForIndex(listView, sLastClickedIndex), ANIMATION_OUT);
} }
if (sLastClickedWordlistId == mWordlistId) {
// This button was being shown. Clear last state to record that there isn't a
// displayed button any more.
sLastClickedIndex = NOT_AN_INDEX;
sLastClickedWordlistId = null;
} else {
// This button was not being shown. Show it and mark it as the latest selected
// button.
animateButton(button, ANIMATION_IN);
sLastClickedIndex = myIndex; sLastClickedIndex = myIndex;
sLastClickedWordlistId = mWordlistId; sLastClickedWordlistId = mWordlistId;
} }
} }
}
private Button getButtonForIndex(final ListView listView, final int index) { private Button getButtonForIndex(final ListView listView, final int index) {
final int indexInChildren = index - listView.getFirstVisiblePosition(); final int indexInChildren = index - listView.getFirstVisiblePosition();