diff options
| author | 2019-01-23 14:23:27 -0800 | |
|---|---|---|
| committer | 2019-01-23 14:25:22 -0800 | |
| commit | bacad701091563e3cde35d556752dbfc54875f13 (patch) | |
| tree | 74a37f76a1bff9262d614c7e7db36d65defa83b8 | |
| parent | 6c14b389efd93b19a28d797e89a1ebb3ffcde846 (diff) | |
Explicit delay in View.java
Currently, the checkForLongClick function receives an argument that
later gets subtracted from some default value, but it is confusing to
use such a function. The natural computation is to provide the time
delay directly.
Minor refactor of View.java here to simplify the math.
Bug: none
Test: none
Change-Id: Ic237e8edac5bd2c7608215f20706a4a67a194b4b
| -rw-r--r-- | core/java/android/view/View.java | 15 | 
1 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2014ec2417ac..edf3a25d6107 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -13994,7 +13994,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,                      if (clickable) {                          setPressed(true, x, y);                      } -                    checkForLongClick(0, x, y); +                    checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y);                      return true;                  }              } @@ -14735,7 +14735,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,                      mHasPerformedLongPress = false;                      if (!clickable) { -                        checkForLongClick(0, x, y); +                        checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y);                          break;                      } @@ -14759,7 +14759,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,                      } else {                          // Not inside a scrolling container, so show the feedback right away                          setPressed(true, x, y); -                        checkForLongClick(0, x, y); +                        checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y);                      }                      break; @@ -25434,7 +25434,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,          }      } -    private void checkForLongClick(int delayOffset, float x, float y) { +    private void checkForLongClick(long delay, float x, float y) {          if ((mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE || (mViewFlags & TOOLTIP) == TOOLTIP) {              mHasPerformedLongPress = false; @@ -25444,8 +25444,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,              mPendingCheckForLongPress.setAnchor(x, y);              mPendingCheckForLongPress.rememberWindowAttachCount();              mPendingCheckForLongPress.rememberPressedState(); -            postDelayed(mPendingCheckForLongPress, -                    ViewConfiguration.getLongPressTimeout() - delayOffset); +            postDelayed(mPendingCheckForLongPress, delay);          }      } @@ -27035,7 +27034,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,          public void run() {              mPrivateFlags &= ~PFLAG_PREPRESSED;              setPressed(true, x, y); -            checkForLongClick(ViewConfiguration.getTapTimeout(), x, y); +            final long delay = +                    ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout(); +            checkForLongClick(delay, x, y);          }      }  |