ViewGroup事件分发处理
来源:互联网 发布:淘宝新店第一天刷几单 编辑:程序博客网 时间:2024/05/24 06:49
https://www.processon.com/diagraming/56cd741de4b08c023484cedf
- public boolean dispatchTouchEvent(MotionEvent ev) {
- final int action = ev.getAction();
- final float xf = ev.getX();
- final float yf = ev.getY();
- final float scrolledXFloat = xf + mScrollX;
- final float scrolledYFloat = yf + mScrollY;
- final Rect frame = mTempRect;
- boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;
- if (action == MotionEvent.ACTION_DOWN) {
- if (mMotionTarget != null) {
- mMotionTarget = null;
- }
- if (disallowIntercept || !onInterceptTouchEvent(ev)) {
- ev.setAction(MotionEvent.ACTION_DOWN);
- final int scrolledXInt = (int) scrolledXFloat;
- final int scrolledYInt = (int) scrolledYFloat;
- final View[] children = mChildren;
- final int count = mChildrenCount;
- for (int i = count - 1; i >= 0; i--) {
- final View child = children[i];
- if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE
- || child.getAnimation() != null) {
- child.getHitRect(frame);
- if (frame.contains(scrolledXInt, scrolledYInt)) {
- final float xc = scrolledXFloat - child.mLeft;
- final float yc = scrolledYFloat - child.mTop;
- ev.setLocation(xc, yc);
- child.mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
- if (child.dispatchTouchEvent(ev)) {
- mMotionTarget = child;
- return true;
- }
- }
- }
- }
- }
- }
- boolean isUpOrCancel = (action == MotionEvent.ACTION_UP) ||
- (action == MotionEvent.ACTION_CANCEL);
- if (isUpOrCancel) {
- mGroupFlags &= ~FLAG_DISALLOW_INTERCEPT;
- }
- final View target = mMotionTarget;
- if (target == null) {
- ev.setLocation(xf, yf);
- if ((mPrivateFlags & CANCEL_NEXT_UP_EVENT) != 0) {
- ev.setAction(MotionEvent.ACTION_CANCEL);
- mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
- }
- return super.dispatchTouchEvent(ev);
- }
- if (!disallowIntercept && onInterceptTouchEvent(ev)) {
- final float xc = scrolledXFloat - (float) target.mLeft;
- final float yc = scrolledYFloat - (float) target.mTop;
- mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
- ev.setAction(MotionEvent.ACTION_CANCEL);
- ev.setLocation(xc, yc);
- if (!target.dispatchTouchEvent(ev)) {
- }
- mMotionTarget = null;
- return true;
- }
- if (isUpOrCancel) {
- mMotionTarget = null;
- }
- final float xc = scrolledXFloat - (float) target.mLeft;
- final float yc = scrolledYFloat - (float) target.mTop;
- ev.setLocation(xc, yc);
- if ((target.mPrivateFlags & CANCEL_NEXT_UP_EVENT) != 0) {
- ev.setAction(MotionEvent.ACTION_CANCEL);
- target.mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
- mMotionTarget = null;
- }
- return target.dispatchTouchEvent(ev);
- }
0 0
- ViewGroup事件分发处理
- ViewGroup的事件拦截、事件分发、事件处理
- android 事件分发 ViewGroup
- ViewGroup的事件分发
- ViewGroup事件分发机制
- ViewGroup事件分发
- ViewGroup事件分发
- ViewGroup事件分发
- ViewGroup的事件分发
- 事件分发(ViewGroup)
- viewGroup事件分发记录
- ViewGroup事件分发
- ViewGroup事件分发
- 事件分发机制---ViewGroup
- ViewGroup事件分发机制
- ViewGroup 事件分发
- android下ViewGroup的事件分发和处理
- ViewGroup的事件分发机制
- 分享: 语音识别Matlab源码免费下载-智慧石
- 【codevs1287】矩阵乘法(矩阵乘法)
- 数字图像处理 预处理 图像增强
- 别人java的博客。
- Fragment加viewpager+fragment viewpager中的fragment显示空白
- ViewGroup事件分发处理
- android学习网站
- Android为什么选择binder
- 无法定位程序输入点 于动态链接QtCore4.dll库上
- Alternating Current
- Android 6.0 fork Zygote时的存储权限管理
- 在release(发布app)中屏蔽NSLog输出语句
- C++学习笔记:虚析构函数
- Android4.4的zygote进程