Android View 触摸反馈原理浅析

news2024/12/26 13:52:24

重写OnTouchEvent() 然后在方法内部写触摸算法

返回true,表示消费事件,所有触摸反馈不再生效,返回事件所有权

if (event.actionMasked == MotionEvent.ACTION_UP){
    performClick()//抬起事件 执行performClick 触发点击
}
override fun onTouchEvent(event: MotionEvent): Boolean {
  //event 触摸事件
}

//所有的触摸事件都是一个序列,如Down-Up,Down-Up-Cancel,Down-Move

//实例1 

View TouchEvnet ->ViewGroup TouchEvent

//实例2

View1 TouchEvnet ->View2 TouchEvnet ->ViewGroup TouchEvent

 

event.action 和ActionMarked区别

ActionMarked属性:

ACTION_MASK
ACTION_DOWN
ACTION_UP
ACTION_MOVE
ACTION_CANCEL
ACTION_OUTSIDE
ACTION_POINTER_DOWN
ACTION_POINTER_UP
ACTION_HOVER_MOVE
ACTION_SCROLL
ACTION_HOVER_ENTER
ACTION_HOVER_EXIT
ACTION_BUTTON_PRESS
ACTION_BUTTON_RELEASE
ACTION_POINTER_INDEX_MASK
ACTION_POINTER_INDEX_SHIFT

....

ActionMarked相比Action,适用于多点触控 //ACTION_POINTER_UP 非第一根手指抬起

新版会根据事件和Pointer

event.Action会拿到多个事件 如down 可能会action-down - action-pointer-down,会融合多个事件

onTouchEvent

public boolean onTouchEvent(MotionEvent event) {
    final float x = event.getX(); //x坐标
    final float y = event.getY(); //y坐标
    final int viewFlags = mViewFlags;
    final int action = event.getAction(); //Action
    final boolean clickable = ((viewFlags & CLICKABLE) == CLICKABLE
        || (viewFlags & LONG_CLICKABLE) == LONG_CLICKABLE)
        || (viewFlags & CONTEXT_CLICKABLE) == CONTEXT_CLICKABLE;
       //符合点击 长按 上下文 都属于点击事件

if ((viewFlags & ENABLED_MASK) == DISABLED) {
    if (action == MotionEvent.ACTION_UP && (mPrivateFlags & PFLAG_PRESSED) != 0) {
        setPressed(false); //抬起 标记未点击
    }
    mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN;
    // A disabled view that is clickable still consumes the touch
    // events, it just doesn't respond to them.
    return clickable; //如果可点击但禁用 返回clickable 标记消费
}
if (mTouchDelegate != null) {
    if (mTouchDelegate.onTouchEvent(event)) {
        return true;
        //mTouchDelegate 增加点击区域
    }
}
if (clickable || (viewFlags & TOOLTIP) == TOOLTIP) {
//TOOLTIP API26以上新特性 解释工具 辅助工具
//可点击或者有辅助工具解释描述
    switch (action) {
        case MotionEvent.ACTION_UP:
            mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN;
            if ((viewFlags & TOOLTIP) == TOOLTIP) {
                //辅助提示 松开手指消失 1500ms
                handleTooltipUp();
            }
            if (!clickable) {
                //不可点击 取消所有事件
                removeTapCallback();
                removeLongPressCallback();
                mInContextButtonPress = false;
                mHasPerformedLongPress = false;
                mIgnoreNextUpEvent = false;
                break;
            }
        
        boolean prepressed = (mPrivateFlags & PFLAG_PREPRESSED) != 0;
        //按下或者预准备按下
        if ((mPrivateFlags & PFLAG_PRESSED) != 0 || prepressed) {
        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); //按下状态为true
            }

    if (!mHasPerformedLongPress && !mIgnoreNextUpEvent) {
        // This is a tap, so remove the longpress check
        removeLongPressCallback(); //移除长按操作

        // Only perform take click actions if we were in the pressed state
        if (!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();
            }
        }
    }

    if (mUnsetPressedState == null) {
        mUnsetPressedState = new UnsetPressedState();
    }
    //延迟操作置空 64ms 自动抬起
    if (prepressed) {
        postDelayed(mUnsetPressedState,
                ViewConfiguration.getPressedStateDuration());
    } else if (!post(mUnsetPressedState)) {
        // If the post failed, unpress right now
        mUnsetPressedState.run();
    }

    removeTapCallback();
}

mIgnoreNextUpEvent = false;
break;


case MotionEvent.ACTION_DOWN:
    if (event.getSource() == InputDevice.SOURCE_TOUCHSCREEN) {
        mPrivateFlags3 |= PFLAG3_FINGER_DOWN;
         //是否触摸到View
    }
    mHasPerformedLongPress = false;

    if (!clickable) {
          //不可点击则检查长按 会有延迟执行
        checkForLongClick(
                ViewConfiguration.getLongPressTimeout(), x, y,
                TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS);
        break;
    }

    if (performButtonActionOnTouchDown(event)) {
           //鼠标右键点击 显示上下文菜单
        break;
    }

 
/*
如果在滑动控件 不停递归 返回状态
public boolean isInScrollingContainer() {
    ViewParent p = getParent();
    while (p != null && p instanceof ViewGroup) {
        if (((ViewGroup) p).shouldDelayChildPressedState()) {
//shouldDelayChildPressedState 是否延迟子View延迟状态
            return true;
        }
        p = p.getParent();
    }
    return false;
}
*/
    boolean isInScrollingContainer = isInScrollingContainer();
    //预按下 是否滑动或者按下 进行延迟判断
    if (isInScrollingContainer) {
        mPrivateFlags |= PFLAG_PREPRESSED; 
        if (mPendingCheckForTap == null) {
            mPendingCheckForTap = new CheckForTap();


/*

private final class CheckForTap implements Runnable {
    public float x;
    public float y;

    @Override
    public void run() {
        mPrivateFlags &= ~PFLAG_PREPRESSED; //置空预点击
        setPressed(true, x, y);
        final long delay = //检查长按
                ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout();
        checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS);
    }
}
*/
        }
        mPendingCheckForTap.x = event.getX();
        mPendingCheckForTap.y = event.getY();
        postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout() ); //100ms

    } else {
        // Not inside a scrolling container, so show the feedback right away

        setPressed(true, x, y); //不在滑动控件 设为按下状态
        checkForLongClick( //检查是否要长按,设置等待器
                ViewConfiguration.getLongPressTimeout(), //500ms
                x,
                y,
                TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS);
                //预按下 需要等待 getLongPressTimeout 500 -  getTapTimeout 100ms
    }
    break;




case MotionEvent.ACTION_CANCEL:
    //移除所有事件
    if (clickable) {
        setPressed(false);
    }
    removeTapCallback();
    removeLongPressCallback();
    mInContextButtonPress = false;
    mHasPerformedLongPress = false;
    mIgnoreNextUpEvent = false;
    mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN;
    break;

case MotionEvent.ACTION_MOVE:
    if (clickable) {
        //可点击 5.0后波纹效果
        drawableHotspotChanged(x, y);
    }

    final int motionClassification = event.getClassification();
    final boolean ambiguousGesture =
        //未规定手势 增加长按事件
            motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE;
    int touchSlop = mTouchSlop;
    if (ambiguousGesture && hasPendingLongPressCallback()) {
        final float ambiguousMultiplier =
                ViewConfiguration.getAmbiguousGestureMultiplier();
        if (!pointInView(x, y, touchSlop)) {
        //如果手指出界限 ,touchSlop 触摸边界 增加延长长按

            // The default action here is to cancel long press. But instead, we
            // just extend the timeout here, in case the classification
            // stays ambiguous.
            removeLongPressCallback();
            // 长按事件的两倍ms
            long delay = (long) (ViewConfiguration.getLongPressTimeout()
                    * ambiguousMultiplier);
            // Subtract the time already spent
              delay -= event.getEventTime() - event.getDownTime();
            //检查长按
            checkForLongClick(
                    delay,
                    x,
                    y,
                    TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS);
        }
        touchSlop *= ambiguousMultiplier;
    }

    // Be lenient about moving outside of buttons
    if (!pointInView(x, y, touchSlop)) {
       //取消事件
        removeTapCallback();
        removeLongPressCallback();
        if ((mPrivateFlags & PFLAG_PRESSED) != 0) {
            setPressed(false);
        }
        mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN;
    }

//Android 10 用力点击 触发长按
    final boolean deepPress =
            motionClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS;
    if (deepPress && hasPendingLongPressCallback()) {
        // process the long click action immediately
        removeLongPressCallback();
        checkForLongClick(
                0 /* send immediately */,
                x,
                y,
                TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS);
    }

    break;


        }
}

如果不是滑动Layout 可以重写sholdDelayChildPressedState false 关闭延迟点击事件

ViewGroup:

onIntercerceptTouchEvent

onTouchEvent

onIntercerceptTouchEvent 判断是否拦截

1.

ViewGroup onIntercerceptTouchEvent false ->View -> onTouchEvent false ->... ->ViewGroup ->onTouchEvent

2.

ViewGroup onIntercerceptTouchEvent false -> ViewGroup onIntercerceptTouchEvent false -> View -> onTouchEvent false ->... ->ViewGroup ->onTouchEvent  ->ViewGroup ->onTouchEvent

3.

ViewGroup onIntercerceptTouchEven true -> ViewGroup -> onTouchEvent true

 ViewGroup onInterceptTouchEvent 建议先返回false 放行,然后记录 事件/数据做准备

disparchTouchEvent 管理ViewGroup的onIntercerceptTouchEvent  / onTouchEvent

disparchTouchEvent 管理有View的 onTouchEvent

子View dispatchTouchEvent 返回true 消费事件不再传递

ViewGroup dispatchTouchEvent调用super.dispatchTouchEvent

View dispatchTouchEvnet:

  if (onFilterTouchEventForSecurity(event)) {
            if ((mViewFlags & ENABLED_MASK) == ENABLED && handleScrollBarDragging(event)) {
                result = true;
            }
            //noinspection SimplifiableIfStatement
            ListenerInfo li = mListenerInfo;
            //mOnTouchListener touch事件监听 有则不调用onTouchEvnet
            if (li != null && li.mOnTouchListener != null
                    && (mViewFlags & ENABLED_MASK) == ENABLED
                    && li.mOnTouchListener.onTouch(this, event)) {
                result = true;
            }

            if (!result && onTouchEvent(event)) {
                result = true;
            }
return TouchEvent
        }

ViewGroup.dispatchTouchEvent -> 核心

if(intercptTouchEvent)

{onTouchEvent}

else{子View.dispatchTouchEvent}

  @Override
    public boolean dispatchTouchEvent(MotionEvent ev){
        if (mInputEventConsistencyVerifier != null) {
            mInputEventConsistencyVerifier.onTouchEvent(ev, 1);
        }

        //障碍相关
        // If the event targets the accessibility focused view and this is it, start
        // normal event dispatch. Maybe a descendant is what will handle the click.
        if (ev.isTargetAccessibilityFocus() && isAccessibilityFocusedViewOrHost()) {
            ev.setTargetAccessibilityFocus(false);
        }

        boolean handled = false;
        if (onFilterTouchEventForSecurity(ev)) {
            final int action = ev.getAction();
            final int actionMasked = action & MotionEvent.ACTION_MASK;

            // Handle an initial down.
   
            if (actionMasked == MotionEvent.ACTION_DOWN) {
                // Throw away all previous state when starting a new touch gesture.
                // The framework may have dropped the up or cancel event for the previous gesture
                // due to an app switch, ANR, or some other state change.
                cancelAndClearTouchTargets(ev); //清空状态,确保view没有按下, 是全新的一个序列 down  
                resetTouchState();//拦截子View
            }

            // Check for interception.
            final boolean intercepted;
            if (actionMasked == MotionEvent.ACTION_DOWN // 按下事件判断子View的是否拦截
                    || mFirstTouchTarget != null) {
                //mFirstTouchTarget 有子View被按下
                final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;
                if (!disallowIntercept) {
                    intercepted = onInterceptTouchEvent(ev);
                    ev.setAction(action); // restore action in case it was changed
                } else {
                    //不拦截
                    intercepted = false;
                }
            } else {
                // There are no touch targets and this action is not an initial down
                // so this view group continues to intercept touches.
                //拦截
                intercepted = true;
            }

            // If intercepted, start normal event dispatch. Also if there is already
            // a view that is handling the gesture, do normal event dispatch.
            if (intercepted || mFirstTouchTarget != null) {
                ev.setTargetAccessibilityFocus(false);
            }

            // Check for cancelation.
            final boolean canceled = resetCancelNextUpFlag(this)
                    || actionMasked == MotionEvent.ACTION_CANCEL;

            // Update list of touch targets for pointer down, if needed.
            final boolean split = (mGroupFlags & FLAG_SPLIT_MOTION_EVENTS) != 0;
            TouchTarget newTouchTarget = null;
            boolean alreadyDispatchedToNewTouchTarget = false;
            //非取消和拦截状态
            if (!canceled && !intercepted) {

                // If the event is targeting accessibility focus we give it to the
                // view that has accessibility focus and if it does not handle it
                // we clear the flag and dispatch the event to all children as usual.
                // We are looking up the accessibility focused host to avoid keeping
                // state since these events are very rare.
                View childWithAccessibilityFocus = ev.isTargetAccessibilityFocus()
                        ? findChildWithAccessibilityFocus() : null;

                //split 多点触控,
                if (actionMasked == MotionEvent.ACTION_DOWN
                        || (split && actionMasked == MotionEvent.ACTION_POINTER_DOWN)
                        || actionMasked == MotionEvent.ACTION_HOVER_MOVE) {
                    final int actionIndex = ev.getActionIndex(); // always 0 for down
                    final int idBitsToAssign = split ? 1 << ev.getPointerId(actionIndex)
                            : TouchTarget.ALL_POINTER_IDS;

                    // Clean up earlier touch targets for this pointer id in case they
                    // have become out of sync.
                    removePointersFromTouchTargets(idBitsToAssign);

                    final int childrenCount = mChildrenCount;
                    if (newTouchTarget == null && childrenCount != 0) {
                        final float x = ev.getX(actionIndex);
                        final float y = ev.getY(actionIndex);
                        // Find a child that can receive the event.
                        // Scan children from front to back.
                        final ArrayList<View> 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 there is a view that has accessibility focus we want it
                            // to get the event first and if not handled we will perform a
                            // normal dispatch. We may do a double iteration but this is
                            // safer given the timeframe.
                            if (childWithAccessibilityFocus != null) {
                                if (childWithAccessibilityFocus != child) {
                                    continue;
                                }
                                childWithAccessibilityFocus = null;
                                i = childrenCount - 1;
                            }

                            if (!child.canReceivePointerEvents()
                                    || !isTransformedTouchPointInView(x, y, child, null)) {
                                ev.setTargetAccessibilityFocus(false);
                                continue;
                            }

                            //获取有没有在触摸的子View可以接收
                            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.
                                //pointerIdBits 添加进去
                                newTouchTarget.pointerIdBits |= idBitsToAssign;
                                break;
                            }

                            resetCancelNextUpFlag(child);

                               //没有在触摸的子View可以接收,尝试能都找到新的子View接收事件
                            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 index
                                    for (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 didn't handle the event, so clear
                            // the flag and do a normal dispatch to all children.
                            ev.setTargetAccessibilityFocus(false);
                        }
                        if (preorderedList != null) preorderedList.clear();
                    }

                    if (newTouchTarget == null && mFirstTouchTarget != null) {
                        // Did not find a child to receive the event.
                        // Assign the pointer to the least recently added target.
                        newTouchTarget = mFirstTouchTarget;
                        while (newTouchTarget.next != null) {
                            newTouchTarget = newTouchTarget.next;
                        }
                        newTouchTarget.pointerIdBits |= idBitsToAssign;
                    }
                }
            }

            // Dispatch to touch targets.
            //子View不接收事件
            if (mFirstTouchTarget == null) {
                // No touch targets so treat this as an ordinary view.
                //调用自己的TouchEvent
                handled = dispatchTransformedTouchEvent(ev, canceled, null,
                        TouchTarget.ALL_POINTER_IDS);
            } else {
                // Dispatch to touch targets, excluding the new touch target if we already
                // dispatched to it.  Cancel touch targets if necessary.
                TouchTarget predecessor = null;
                TouchTarget target = mFirstTouchTarget; //内部被触摸到的子View
                while (target != null) {
                    final TouchTarget next = target.next;
                    if (alreadyDispatchedToNewTouchTarget && target == newTouchTarget) {
                        handled = true;
                    } else {
                        final boolean cancelChild = resetCancelNextUpFlag(target.child)
                                || intercepted;
                        //处理子View偏移
                        if (dispatchTransformedTouchEvent(ev, cancelChild,
                                target.child, target.pointerIdBits)) {
                            handled = true;
                        }
                        if (cancelChild) {
                            if (predecessor == null) {
                                mFirstTouchTarget = next;
                            } else {
                                predecessor.next = next;
                            }
                            target.recycle();
                            target = next;
                            continue;
                        }
                    }
                    predecessor = target;
                    target = next;
                }
            }

            // Update list of touch targets for pointer up or cancel, if needed.
            if (canceled
                    || actionMasked == MotionEvent.ACTION_UP
                    || actionMasked == MotionEvent.ACTION_HOVER_MOVE) {
                resetTouchState();
            } else if (split && actionMasked == MotionEvent.ACTION_POINTER_UP) {
                final int actionIndex = ev.getActionIndex();
                final int idBitsToRemove = 1 << ev.getPointerId(actionIndex);
                removePointersFromTouchTargets(idBitsToRemove);
            }
        }

        if (!handled && mInputEventConsistencyVerifier != null) {
            mInputEventConsistencyVerifier.onUnhandledEvent(ev, 1);
        }
        return handled;
    }







 @Override
    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {

//在down之后 和 up之前 ,在父View ViewGroup 调用,同一事件不拦截
        if (disallowIntercept == ((mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0)) {
            // We're already in this state, assume our ancestors are too
            return;
        }

        if (disallowIntercept) {
            mGroupFlags |= FLAG_DISALLOW_INTERCEPT;
        } else {
            mGroupFlags &= ~FLAG_DISALLOW_INTERCEPT;
        }

        // Pass it up to our parent
        if (mParent != null) {
            mParent.requestDisallowInterceptTouchEvent(disallowIntercept);
        }
    }


dispatchTransformedTouchEvent () ViewGroup 偏移计算 处理子View 进行转换

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1176403.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

办公套件全家桶 Office2019 mac中文版新功能

office 2019 mac是 Microsoft office 应用程序套件的最新版本。它包括流行的软件&#xff0c;例如 Microsoft Word、Excel、PowerPoint 和 Outlook&#xff0c;office 2019 比其前身有许多新功能和改进&#xff0c;包括增强的协作工具、与 OneDrive 和 SharePoint 等云服务的更…

Figma 怎么切图?新手入门教程详解

Figma 是一个基于浏览器的协作的UI设计工具&#xff0c;其以轻量、便捷、跨平台使用、协同便捷的特点&#xff0c;迅速吸引了广大UI/UX 设计师们的喜欢。但是设计师经常遇到反复切图、交付开发等问题&#xff0c;所以借此机会分享一篇关于 Figma 切图的必要知识点和交付经验。 …

基于 VTable 的多维数据展示的原理与实践

多维表格介绍 多维表格又名透视表、交叉表、Pivot Table&#xff0c;指的是可以在行维度和列维度放入一个或多个维度&#xff0c;显示维度之间相互关系的一种表格。用户可以一目了然地分析出各种场景指标以及对比&#xff0c;旨在帮助业务分析推动决策。 假设需要分析如下表格…

微信支付更换证书最详细方法

6、在【商户平台】&#xff0c;输入操作密码&#xff0c;安全验证后生成证书串 7、在【商户平台】&#xff0c;复制证书串 8、在【证书工具】&#xff0c;粘贴证书串&#xff0c;点击下一步&#xff0c;申请证书成功 &#xff08;若提示"证书与本地公私钥不匹配&qu…

window10 定时任务

window10 定时任务 1、背景2、目标3、思路4、实操4.1、设置定时任务4.2、配置策略4.3、验证 1、背景 项目上由于业务调试需要&#xff0c;开具了一台window10系统&#xff0c;此台window10为项目组公共使用&#xff0c;为防止误操作分配了不通的账号&#xff0c;日常使用各自账…

互联网校园洗衣洗鞋小程序;

互联网校园洗衣洗鞋小程序打造哪足不出户&#xff0c;线上下单上门取货&#xff0c;通过它不仅可以让用户快速便捷的找到小程序下单&#xff0c;在手机上准确的下发洗衣命令&#xff0c;还能洗好后提供取衣服务等&#xff0c;因此受到了广泛用户的喜爱。截止目前&#xff0c;软…

山西电力市场日前价格预测【2023-11-06】

日前价格预测 预测说明&#xff1a; 如上图所示&#xff0c;预测明日&#xff08;2023-11-06&#xff09;山西电力市场全天平均日前电价为126.17元/MWh。其中&#xff0c;最高日前电价为405.20元/MWh&#xff0c;预计出现在18: 15。最低日前电价为0.00元/MWh&#xff0c;预计出…

深入了解Jedis:Java操作Redis的常见类型数据存储

目录 前言 一、Jedis介绍 1.Jedis在各方面的功能 2.特点 二、Java连接Redis 1.导入pom依赖 2.建立连接 三、Java操作Redis的常见类型数据存储 1.字符串 2.哈希表 3.列表 4.集合 5.有序集合 四、Redis的实际应用场景实例 1.会议信息实体 2.自定义注解 3.创建切面…

应用场景 | 中小河流治理监测系统,提升流域智能感知能力

当前&#xff0c;受全球气候变化和人类活动影响&#xff0c;我国中小河流洪涝灾害呈多发、频发趋势&#xff0c;中小河流洪水已成为严重威胁人民群众生命财产安全的重大风险隐患。中小河流治理作为一项重要的民生水利任务&#xff0c;近十年来国家不断加大以防洪为主的治理投入…

初始JVM虚拟机

JVM组成 图解 程序计数器 在JVM线程私有的内存区域中。每个线程都有自己独立的程序计数器。 程序计数器用于存储当前线程正在执行的字节码指令的地址。指示着当前线程执行到了哪一条字节码指令。 堆 是线程共享的区域&#xff0c;用于存储对象的实例和数组对象&#xff1b; …

使用OkHttp库爬取百度云视频详细步骤

目录 摘要 一、OkHttp库简介 二、爬虫基本概念 三、使用OkHttp库爬取百度云视频 1、发送HTTP请求 2、处理响应 3、下载文件 四、可能遇到的问题及解决方案 五、注意事项 总结与建议 摘要 本文将详细介绍如何使用OkHttp库爬取百度云视频。文章首先简要介绍OkHttp库和…

三国志14信息查询小程序(历史武将信息一览)制作更新过程03-主要页面的设计

1&#xff0c;小程序的默认显示 分为三部分&#xff0c;头部的标题、中间的内容区和底部的标签栏。点击标签可以切换不同页面&#xff0c;这是在app.json文件中配置的。代码如下&#xff1a; //所有用到的页面都需要在 pages 数组中列出&#xff0c;否则小程序可能会出现错误或…

YOLO v2(2016.12)

文章目录 AbstractIntroduction当前存在的困境基于此&#xff0c;我们给出了方法 BetterBatch NormalizationHigh Resolution ClassifierConvolutional With Anchor BoxesDimension ClustersDirect location predictionFine-Grained FeaturesMulti-Scale TrainingFurther Exper…

Python教程:随机函数,开始猜英文单词的游戏

开始猜英文单词的游戏… 总计生命次数&#xff1a;3次 -----------游戏开始中…----------- &#xff1f;&#xff1f;&#xff1f;&#xff1f;请猜一个&#xff0c;4位数的单词:mafr 猜错了&#xff0c;再努力一下 -----------你还有2次生命------------ ma&#xff1f;&…

如何防范AI诈骗

如何防范AI诈骗 &#x1f607;博主简介&#xff1a;我是一名正在攻读研究生学位的人工智能专业学生&#xff0c;我可以为计算机、人工智能相关本科生和研究生提供排忧解惑的服务。如果您有任何问题或困惑&#xff0c;欢迎随时来交流哦&#xff01;&#x1f604; ✨座右铭&#…

这款AI-3D模型实现了无数人的建模梦

hi&#xff0c;同学们&#xff0c;本期是第25期AI生产力工具教程 别说各位&#xff0c;连我也不敢信&#xff0c;现在制作3D模型比泡杯奶茶的时间还要快&#xff01; 最近发现了一个天花板级的图片生成3D模型的AI工具——Artefacts.Ai&#xff0c;喂1张图片&#xff0c;就能创…

《持续交付:发布可靠软件的系统方法》- 读书笔记(十一)

持续交付&#xff1a;发布可靠软件的系统方法&#xff08;十一&#xff09; 第三部分——交付生态圈第 11 章 基础设施和环境管理11.1 引言11.2 理解运维团队的需要11.2.1 文档与审计11.2.2 异常事件的告警11.2.3 保障 IT 服务持续性的计划11.2.4 使用运维团队熟悉的技术 11.3 …

11.4-GPT4AllTools版本已开始对小部分GPT3.5用户内测推送

OpenAI已经开始小规模推送GPT4 AllTools功能&#xff0c;部分GPT博主已经第一时间体验了此功能&#xff0c;此功能特色是整合目前的多模态功能以及文件上传和联网模块&#xff0c;无需切换&#xff0c;更要全面综合 可上传包括 PDF、数据文件在内的任意文档&#xff0c;并进行分…

idea使用lombok编译问题

idea编译报错问题如下&#xff1a; java: You arent using a compiler supported by lombok, so lombok will not work and has been disabled.Your processor is: com.sun.proxy.$Proxy26Lombok supports: OpenJDK javac, ECJ解决方案&#xff1a;在idea配置中File->Setti…

Java_类和对象详解

文章目录 前言简单认识类类定义和使用类的实例化引用的一些注意事项 类和对象的说明及关系this引用为什么要有this引用this应用this特性 构造方法构造特性及应用用this简化用idea编译器快捷创建构造 封装封装的概念访问限定符 封装的扩展-包包的概念导入包中的类自定义包常见的…