InstaMaterial
InstaMaterial copied to clipboard
hide FeedContextMenu when click outside of FeedContextMenu
For completeness:
public void hideContextMenu(MotionEvent ev) {
if(contextMenuView == null)
return;
int[] contentLocation = new int[2];
contextMenuView.getLocationOnScreen(contentLocation);
Rect rect = new Rect(contentLocation[0],
contentLocation[1],
contentLocation[0] + contextMenuView.getWidth(),
contentLocation[1] + contextMenuView.getHeight());
if (!(rect.contains((int) ev.getX(), (int) ev.getY())))
hideContextMenu();
}