Skip to content

Instantly share code, notes, and snippets.

@hiking93
Created March 15, 2018 03:20
Show Gist options
  • Save hiking93/503e923fe227504bb7124f6bce268bda to your computer and use it in GitHub Desktop.
Save hiking93/503e923fe227504bb7124f6bce268bda to your computer and use it in GitHub Desktop.
Perform long click internal.
private boolean performLongClickInternal(float x, float y) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
boolean handled = false;
final ListenerInfo li = mListenerInfo;
if (li != null && li.mOnLongClickListener != null) {
handled = li.mOnLongClickListener.onLongClick(View.this);
}
if (!handled) {
final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y);
handled = isAnchored ? showContextMenu(x, y) : showContextMenu();
}
if ((mViewFlags & TOOLTIP) == TOOLTIP) {
if (!handled) {
handled = showLongClickTooltip((int) x, (int) y);
}
}
if (handled) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
return handled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment