Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e52eb1f7 authored by Jean Chalard's avatar Jean Chalard Committed by Android Git Automerger
Browse files

am 776edcfe: Merge "[PB2] Small bugfix"

* commit '776edcfe':
  [PB2] Small bugfix
parents 617f99b2 776edcfe
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -203,19 +203,29 @@ public final class WordListPreference extends Preference {
        @Override
        public void onClick(final View v) {
            final Button button = (Button)v.findViewById(R.id.wordlist_button);
            animateButton(button, ANIMATION_IN);
            final ViewParent parent = v.getParent();
            // Just in case something changed in the framework, test for the concrete class
            if (!(parent instanceof ListView)) return;
            final ListView listView = (ListView)parent;
            final int myIndex = listView.indexOfChild(v) + listView.getFirstVisiblePosition();
            if (NOT_AN_INDEX != sLastClickedIndex) {
                // If another button is showing, hide it
                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;
                sLastClickedWordlistId = mWordlistId;
            }
        }
    }

    private Button getButtonForIndex(final ListView listView, final int index) {
        final int indexInChildren = index - listView.getFirstVisiblePosition();