当前位置: 首页 > news >正文

成都网站开发哪家好网站开发流程图 最

成都网站开发哪家好,网站开发流程图 最,西安不动产查询房产信息网,学做预算网站这篇主要是第一篇回顾之后#xff0c;补充一些上一篇没写到的两个点。 第一个的切入点是这个。【处理层叠的view#xff0c;想要执行下一层的view的点击事件】其背后的原理。 处理层叠的view#xff0c;要执行下一层的view的点击事件 我们知道#xff0c;方法是将上一层的…这篇主要是第一篇回顾之后补充一些上一篇没写到的两个点。 第一个的切入点是这个。【处理层叠的view想要执行下一层的view的点击事件】其背后的原理。 处理层叠的view要执行下一层的view的点击事件 我们知道方法是将上一层的view设置setOnTouchListener的onTouch() return false; iv_right.setOnTouchListener { _, _ -false }那么原理是啥其实看源码就可以了解。 首先viewGroup的 dispatchTouchEvent 在 onInterceptTouchEvent不拦截的情况下 传递Event到 view的 dispatchTouchEvent然后在 其方法体中实现原理如一下源代码 if (onFilterTouchEventForSecurity(event)) {if ((mViewFlags ENABLED_MASK) ENABLED handleScrollBarDragging(event)) {result true;}//noinspection SimplifiableIfStatementListenerInfo li mListenerInfo;if (li ! null li.mOnTouchListener ! null (mViewFlags ENABLED_MASK) ENABLED li.mOnTouchListener.onTouch(this, event)) {result true;}if (!result onTouchEvent(event)) {result true;}}//...return result;而onTouchEvent默认是false。因此最后的result就是返回了false。这个时候会回到ViewGroup层。再回过来看其 dispatchTouchEvent的这段代码 //...(此处省略部分源码) final int childrenCount mChildrenCount;if (newTouchTarget null childrenCount ! 0) {final float x isMouseEvent ? ev.getXCursorPosition() : ev.getX(actionIndex);final float y isMouseEvent ? ev.getYCursorPosition() : ev.getY(actionIndex);// Find a child that can receive the event.// Scan children from front to back.final ArrayListView preorderedList buildTouchDispatchChildList();final boolean customOrder preorderedList null isChildrenDrawingOrderEnabled();final View[] children mChildren;for (int i childrenCount - 1; i 0; i--) {final int childIndex getAndVerifyPreorderedIndex(childrenCount, i, customOrder);final View child getAndVerifyPreorderedView(preorderedList, children, childIndex);if (!child.canReceivePointerEvents()|| !isTransformedTouchPointInView(x, y, child, null)) {continue;}newTouchTarget getTouchTarget(child);if (newTouchTarget ! null) {// Child is already receiving touch within its bounds.// Give it the new pointer in addition to the ones it is handling.newTouchTarget.pointerIdBits | idBitsToAssign;break;}resetCancelNextUpFlag(child);if (dispatchTransformedTouchEvent(ev, false, child, idBitsToAssign)) {// Child wants to receive touch within its bounds.mLastTouchDownTime ev.getDownTime();if (preorderedList ! null) {// childIndex points into presorted list, find original indexfor (int j 0; j childrenCount; j) {if (children[childIndex] mChildren[j]) {mLastTouchDownIndex j;break;}}} else {mLastTouchDownIndex childIndex;}mLastTouchDownX ev.getX();mLastTouchDownY ev.getY();newTouchTarget addTouchTarget(child, idBitsToAssign);alreadyDispatchedToNewTouchTarget true;break;}// The accessibility focus didnt handle the event, so clear// the flag and do a normal dispatch to all children.ev.setTargetAccessibilityFocus(false);}由此可知viewgroup会在这个方法中遍历对应区域下的所有view。如果所有view都没消费掉这个Event的时候dispatchTouchEvent会继续执行接下来的代码 // Dispatch to touch targets.if (mFirstTouchTarget null) {// No touch targets so treat this as an ordinary view.handled dispatchTransformedTouchEvent(ev, canceled, null,TouchTarget.ALL_POINTER_IDS);这这段代码中可以看到进入了if语句语句中执行了dispatchTransformedTouchEvent()方法。可以看到它的源码中它会在这个场景下回调super.dispatchTouchEvent(event);最终执行了viewGroup自身的onTouchEvent方法。 private boolean dispatchTransformedTouchEvent(MotionEvent event, boolean cancel,View child, int desiredPointerIdBits) {final boolean handled;// Canceling motions is a special case. We dont need to perform any transformations// or filtering. The important part is the action, not the contents.final int oldAction event.getAction();if (cancel || oldAction MotionEvent.ACTION_CANCEL) {event.setAction(MotionEvent.ACTION_CANCEL);if (child null) {handled super.dispatchTouchEvent(event);} else {handled child.dispatchTouchEvent(event);}event.setAction(oldAction);return handled;}//...(此处省略部分源码) }这样最终形成闭环。也就是上一篇文章所画的流程了。第一篇在这Android事件分发机制 click在整体流程中的哪个节点上 这个其实在第一篇的4.3节有提到过。但是没说得很多在这里补充一下。 这个问题的切入点我们从最常见的设置点击事件开始说起。 mTv.setOnClickListener(v - {});这里设置给了View的mOnClickListener。然后这个回调会在performClick中被调用。 public boolean performClick() {// We still need to call this method to handle the cases where performClick() was called// externally, instead of through performClickInternal()notifyAutofillManagerOnClick();final boolean result;final ListenerInfo li mListenerInfo;if (li ! null li.mOnClickListener ! null) {playSoundEffect(SoundEffectConstants.CLICK);li.mOnClickListener.onClick(this);result true;} else {result false;}sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);notifyEnterOrExitForAutoFillIfNeeded(true);return result;}然后它会在onTouchEvent中被调用。具体是在MotionEvent.ACTION_UP中执行了performClickInternal()。 看部分源码如下 //...(此处省略部分源码) if (clickable || (viewFlags TOOLTIP) TOOLTIP) {switch (action) {case MotionEvent.ACTION_UP:mPrivateFlags3 ~PFLAG3_FINGER_DOWN;if ((viewFlags TOOLTIP) TOOLTIP) {handleTooltipUp();}if (!clickable) {removeTapCallback();removeLongPressCallback();mInContextButtonPress false;mHasPerformedLongPress false;mIgnoreNextUpEvent false;break;}boolean prepressed (mPrivateFlags PFLAG_PREPRESSED) ! 0;if ((mPrivateFlags PFLAG_PRESSED) ! 0 || prepressed) {// take focus if we dont have it already and we should in// touch mode.boolean focusTaken false;if (isFocusable() isFocusableInTouchMode() !isFocused()) {focusTaken requestFocus();}if (prepressed) {// The button is being released before we actually// showed it as pressed. Make it show the pressed// state now (before scheduling the click) to ensure// the user sees it.setPressed(true, x, y);}if (!mHasPerformedLongPress !mIgnoreNextUpEvent) {// This is a tap, so remove the longpress checkremoveLongPressCallback();// Only perform take click actions if we were in the pressed stateif (!focusTaken) {// Use a Runnable and post this rather than calling// performClick directly. This lets other visual state// of the view update before click actions start.if (mPerformClick null) {mPerformClick new PerformClick();}if (!post(mPerformClick)) {performClickInternal();}}}//...(此处省略部分源码)
http://www.w-s-a.com/news/392611/

相关文章:

  • 绿色农产品网站景区网站建设策划方案
  • 服务器做ssr后还可以做网站吗品牌形象设计公司
  • 太原网站制作计划wordpress创建文章
  • 网站优化要怎么做seo网站关键词优化报价
  • 公司网站友情链接怎么做副链华为荣耀手机官网
  • 一条龙做网站旅游网页设计模板图凡科
  • 中山网站建设哪家便宜在中国做外国网站怎么收钱
  • 网站优化大计孝感注册公司
  • 设计接单app平台有哪些在线网站seo诊断
  • 兰州网站建设推广现代营销手段有哪些
  • 郴州网站seo优化网络安全哪个培训班比较好
  • 做网站需要记哪些代码企业网站建设思路
  • 重庆自助建站模板网络服务器配置与管理
  • 外贸网站怎样做小程序买量平台
  • 中山精品网站建设机构海外留学网站建设方案
  • 长春网站建设工作如何取消wordpress页脚
  • 忻府网站建设排名网络管理系统官网
  • 张家港外贸网站建设国医堂网站平台建设
  • 水冶那里有做网站的对于网站链接优化有哪些建议
  • 宝安中心地铁站是几号线化妆品网站做的好的
  • 海宁营销型网站设计企业融资是什么意思
  • 淘宝客做网站要钱吗网站开发试题库
  • 10g空间网站做视频网站网站建设找超速云
  • 一元购网站怎么做企业网站源码cms
  • 域名不变 网站改版临沂企业网站建站模板
  • 天河网站建设信科网络外包公司和公司直招哪个好
  • 网站制作哈尔滨聊天系统源码
  • 网站建设朋友圈素材青白江建设网站
  • 红酒网站设计软件设计文档
  • 如何创建网站目录网站申请支付宝接口