diff options
| author | 2011-01-20 15:24:28 -0800 | |
|---|---|---|
| committer | 2011-01-20 15:24:28 -0800 | |
| commit | be1f62260ae4798cd80404dc595e1146f346cfe9 (patch) | |
| tree | 0c905ff769236d54054731dd03fdf89f8c734c97 | |
| parent | 2cb866b948c38923b31331a9b2f031eb9d791e6e (diff) | |
Fix issue #3374356: Buttons sometimes don't highlight
On touch up, View would move itself to the pressed state if it
hadn't already shown as pressed. However, it did this *after*
scheduling the message to deliver the onClick(). Thus if the
app took a little too long to execute inside of onClick(), the
invalidate to draw the highlight state would be executed right
before the following message to remove the highlight state,
causing it to basically not be shown.
This change just does the invalidate before scheduling the
onClick, so we can be sure it gets done first.
Change-Id: I6a4d1742a3aab60969c38b44bb3e163f48de62d4
| -rw-r--r-- | core/java/android/view/View.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2447f8cd986f..811a633920de 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5027,6 +5027,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility focusTaken = requestFocus(); } + if (prepressed) { + // The button is being released before we actually + // showed it as pressed. Make it show the pressed + // state now (before scheduling the click) to ensure + // the user sees it. + mPrivateFlags |= PRESSED; + refreshDrawableState(); + } + if (!mHasPerformedLongPress) { // This is a tap, so remove the longpress check removeLongPressCallback(); @@ -5050,8 +5059,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } if (prepressed) { - mPrivateFlags |= PRESSED; - refreshDrawableState(); postDelayed(mUnsetPressedState, ViewConfiguration.getPressedStateDuration()); } else if (!post(mUnsetPressedState)) { |