diff options
| author | Alan Viverette <alanv@google.com> | 2015-02-04 00:54:13 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-02-04 00:54:14 +0000 |
| commit | d7596cff0b61a58e089f76bee3c626486bcbaec7 (patch) | |
| tree | da8664b15cff7ec9b0d6aab0387501d6ad7630e9 | |
| parent | 1cfec7c3de7ea2e154ea5f2d04fd8c36df3ab19e (diff) | |
| parent | f723c83fe56a41ca316b0c2c0e70c42af6cd5b1d (diff) | |
| download | frameworks_base-d7596cff0b61a58e089f76bee3c626486bcbaec7.zip frameworks_base-d7596cff0b61a58e089f76bee3c626486bcbaec7.tar.gz frameworks_base-d7596cff0b61a58e089f76bee3c626486bcbaec7.tar.bz2 | |
Merge "Ensure AbsListView's drawable state reflects its actual state"
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 7ea3265..897749f 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -578,6 +578,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te private boolean mIsChildViewEnabled; /** + * The cached drawable state for the selector. Accounts for child enabled + * state, but otherwise identical to the view's own drawable state. + */ + private int[] mSelectorState; + + /** * The last scroll state reported to clients through {@link OnScrollListener}. */ private int mLastScrollState = OnScrollListener.SCROLL_STATE_IDLE; @@ -2789,7 +2795,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te void updateSelectorState() { if (mSelector != null) { if (shouldShowSelector()) { - mSelector.setState(getDrawableState()); + mSelector.setState(getDrawableStateForSelector()); } else { mSelector.setState(StateSet.NOTHING); } @@ -2802,12 +2808,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te updateSelectorState(); } - @Override - protected int[] onCreateDrawableState(int extraSpace) { + private int[] getDrawableStateForSelector() { // If the child view is enabled then do the default behavior. if (mIsChildViewEnabled) { // Common case - return super.onCreateDrawableState(extraSpace); + return super.getDrawableState(); } // The selector uses this View's drawable state. The selected child view @@ -2815,10 +2820,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te // states. final int enabledState = ENABLED_STATE_SET[0]; - // If we don't have any extra space, it will return one of the static state arrays, - // and clearing the enabled state on those arrays is a bad thing! If we specify - // we need extra space, it will create+copy into a new array that safely mutable. - int[] state = super.onCreateDrawableState(extraSpace + 1); + // If we don't have any extra space, it will return one of the static + // state arrays, and clearing the enabled state on those arrays is a + // bad thing! If we specify we need extra space, it will create+copy + // into a new array that is safely mutable. + final int[] state = onCreateDrawableState(1); + int enabledPos = -1; for (int i = state.length - 1; i >= 0; i--) { if (state[i] == enabledState) { |
