Android 触摸事件分发流程

需要整理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
private boolean clickOutsideOf(View v, MotionEvent ev) {
if (v.isShown()) {
Rect rect = new Rect();
v.getGlobalVisibleRect(rect);
if (!rect.contains((int) ev.getRawX(), (int) ev.getRawY())) {
return true;
}
}
return false;
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if (clickOutsideOf(filterListScrollView, ev)) {
mFilterSelectedPresenter.handlerFilterContainer();
return true;

} else if (clickOutsideOf(effectListRecyclerView, ev)) {
viewModel.setEffectVideoMode(false);
return true;
}
}
return super.dispatchTouchEvent(ev);
}