ViewConfiguration.getScaledTouchSlop () 用法

博客提到一个距离概念,在滑动操作时,手的移动距离需大于该距离,控件才会开始移动,这与信息技术中界面交互相关。

是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件。

2025-07-06 16:25:10.644 936-936 ViewConfiguration com.android.launcher3 E Tried to access UI constants from a non-visual Context:com.android.quickstep.inputconsumers.OtherActivityInputConsumer@d0ca171UI constants, such as display metrics or window metrics, must be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen java.lang.IllegalArgumentException: Tried to access UI constants from a non-visual Context:com.android.quickstep.inputconsumers.OtherActivityInputConsumer@d0ca171 at android.view.ViewConfiguration.get(ViewConfiguration.java:510) at com.android.quickstep.inputconsumers.OtherActivityInputConsumer.<init>(OtherActivityInputConsumer.java:163) at com.android.quickstep.TouchInteractionService.createOtherActivityInputConsumer(TouchInteractionService.java:709) at com.android.quickstep.TouchInteractionService.newBaseConsumer(TouchInteractionService.java:692) at com.android.quickstep.TouchInteractionService.newConsumer(TouchInteractionService.java:587) at com.android.quickstep.TouchInteractionService.onInputEvent(TouchInteractionService.java:493) at com.android.quickstep.TouchInteractionService.lambda$5N8OpQhfWV7_tkhenf8Ys3ECXWs(Unknown Source:0) at com.android.quickstep.-$$Lambda$TouchInteractionService$5N8OpQhfWV7_tkhenf8Ys3ECXWs.onInputEvent(Unknown Source:2) at com.android.systemui.shared.system.InputChannelCompat$InputEventReceiver$1.onInputEvent(InputChannelCompat.java:81) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:220) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:335) at android.os.Looper.loop(Looper.java:183) at android.app.ActivityThread.main(ActivityThread.java:7660) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
最新发布
07-07
protected TouchHandler createTouchHandler() { return new TouchHandler() { private long mLastTouchDownTime = -1L; @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (SPEW_LOGCAT) { Log.v(TAG, "NPVC onInterceptTouchEvent (" + event.getId() + "): (" + event.getX() + "," + event.getY() + ")"); } Log.e("lyt---->","---notificatio----11"); if (mBlockTouches || mQs.disallowPanelTouches()) { return false; } initDownStates(event); Log.e("lyt---->","----notifica---22->"); final ViewConfiguration configuration = ViewConfiguration.get(mView.getContext()); int mTouchSlop = configuration.getScaledTouchSlop(); if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) { Log.e("lyt---->","---触摸拦截->"+event.getActionMasked()); switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: mInitialTouchX = event.getX(); mInitialTouchY = event.getY(); break; case MotionEvent.ACTION_MOVE: Log.e("lyt---->","触摸滑动---"); float dx = event.getX() - mInitialTouchX; float dy = event.getY() - mInitialTouchY; // 判断是向上滑动 & 垂直方向为主 if (dy < -mTouchSlop && Math.abs(dy) > Math.abs(dx)) { Log.d("lyt---->", "拦截上滑解锁,交给 LockIconView"); return true; // 拦截该事件序列(会走到 onTouch) } Log.e("lyt---->","插拦截---》"+dx+"---->"+dy+"---->"+(mTouchSlop)); return false; } return false; } // Do not let touches go to shade or QS if the bouncer is visible, // but still let user swipe down to expand the panel, dismissing the bouncer. if (mCentralSurfaces.isBouncerShowing()) { return true; } if (mCommandQueue.panelsEnabled() && !mNotificationStackScrollLayoutController.isLongPressInProgress() && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { mMetricsLogger.count(COUNTER_PANEL_OPEN, 1); mMetricsLogger.count(COUNTER_PANEL_OPEN_PEEK, 1); return true; } if (!shouldQuickSettingsIntercept(mDownX, mDownY, 0) && mPulseExpansionHandler.onInterceptTouchEvent(event)) { return true; } if (!isFullyCollapsed() && onQsIntercept(event)) { if (DEBUG_LOGCAT) Log.d(TAG, "onQsIntercept true"); return true; } return super.onInterceptTouchEvent(event); } @Override public boolean onTouch(View v, MotionEvent event) { Log.e("lyt---->","--noto---touh--111-->"); if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getDownTime() == mLastTouchDownTime) { // An issue can occur when swiping down after unlock, where multiple down // events are received in this handler with identical downTimes. Until the // source of the issue can be located, detect this case and ignore. // see b/193350347 Log.w(TAG, "Duplicate down event detected... ignoring"); return true; } mLastTouchDownTime = event.getDownTime(); } if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) { Log.e("lyt---->","---触摸拦截->"+event.getActionMasked()); if(mLockIconView != null){ mLockIconView.dispatchTouchEvent(event); } return true; } if (mBlockTouches || (mQsFullyExpanded && mQs != null && mQs.disallowPanelTouches())) { return false; } // Do not allow panel expansion if bouncer is scrimmed or showing over a dream, // otherwise user would be able to pull down QS or expand the shade. if (mCentralSurfaces.isBouncerShowingScrimmed() || mCentralSurfaces.isBouncerShowingOverDream()) { return false; } // Make sure the next touch won't the blocked after the current ends. if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { mBlockingExpansionForCurrentTouch = false; } // When touch focus transfer happens, ACTION_DOWN->ACTION_UP may happen immediately // without any ACTION_MOVE event. // In such case, simply expand the panel instead of being stuck at the bottom bar. if (mLastEventSynthesizedDown && event.getAction() == MotionEvent.ACTION_UP) { expand(true /* animate */); } initDownStates(event); // If pulse is expanding already, let's give it the touch. There are situations // where the panel starts expanding even though we're also pulsing boolean pulseShouldGetTouch = (!mIsExpanding && !shouldQuickSettingsIntercept(mDownX, mDownY, 0)) || mPulseExpansionHandler.isExpanding(); if (pulseShouldGetTouch && mPulseExpansionHandler.onTouchEvent(event)) { // We're expanding all the other ones shouldn't get this anymore return true; } if (mListenForHeadsUp && !mHeadsUpTouchHelper.isTrackingHeadsUp() && !mNotificationStackScrollLayoutController.isLongPressInProgress() && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { mMetricsLogger.count(COUNTER_PANEL_OPEN_PEEK, 1); } boolean handled = false; if ((!mIsExpanding || mHintAnimationRunning) && !mQsExpanded && mBarState != StatusBarState.SHADE && !mDozing) { Log.e("lyt---->","----111----"); handled |= mAffordanceHelper.onTouchEvent(event); } if (mOnlyAffordanceInThisMotion) { return true; } handled |= mHeadsUpTouchHelper.onTouchEvent(event); if (!mHeadsUpTouchHelper.isTrackingHeadsUp() && handleQsTouch(event)) { if (DEBUG_LOGCAT) Log.d(TAG, "handleQsTouch true"); return true; } if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyCollapsed()) { mMetricsLogger.count(COUNTER_PANEL_OPEN, 1); handled = true; } if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyExpanded() && mStatusBarKeyguardViewManager.isShowing()) { mStatusBarKeyguardViewManager.updateKeyguardPosition(event.getX()); } handled |= super.onTouch(v, event); Log.e("lyt----->","---->"+(!mDozing || mPulsing || handled)); return !mDozing || mPulsing || handled; } }; }
05-11
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值