您的位置:首页 > 教育 > 培训 > Android U 多任务启动分屏——Launcher流程(下分屏 更新中)

Android U 多任务启动分屏——Launcher流程(下分屏 更新中)

2025/2/23 19:07:52 来源:https://blog.csdn.net/yimelancholy/article/details/142167325  浏览:    关键词:Android U 多任务启动分屏——Launcher流程(下分屏 更新中)

前文

Android U 多任务启动分屏——Launcher流程(上分屏)

最近任务onClick事件的监听

在最近任务中每个任务都是一个TaskView,对TaskView操作,就是每个任务的操作。
在这里插入图片描述

代码路径:packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskView.java

    public TaskView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);//从给定的context获取当前的StatefulActivity实例//绑定TaskView和Activity之间的关系mActivity = StatefulActivity.fromContext(context);//监听当前TaskView的点击事件setOnClickListener(this::onClick);//初始化绘制相关参数mCurrentFullscreenParams = new FullscreenDrawParams(context);//把当前的Activity以及其对应的TaskView传递给DigitalWellBeingToastmDigitalWellBeingToast = new DigitalWellBeingToast(mActivity, this);//判断是否需要启用键盘焦点高亮boolean keyboardFocusHighlightEnabled = FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH.get()|| DesktopTaskView.DESKTOP_MODE_SUPPORTED;//如果不需要启用键盘焦点高亮,则setWillNotDraw(true),表示这个视图不需要绘制setWillNotDraw(!keyboardFocusHighlightEnabled);//使用TypedArray从XML属性中读取TaskView的自定义属性TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TaskView, defStyleAttr, defStyleRes);//如果启用了键盘焦点高亮,则创建一个BorderAnimator实例。mBorderAnimator = !keyboardFocusHighlightEnabled? null: new BorderAnimator(/* borderRadiusPx= */ (int) mCurrentFullscreenParams.mCornerRadius,/* borderColor= */ ta.getColor(R.styleable.TaskView_borderColor, DEFAULT_BORDER_COLOR),/* borderAnimationParams= */ new BorderAnimator.SimpleParams(/* borderWidthPx= */ context.getResources().getDimensionPixelSize(R.dimen.keyboard_quick_switch_border_width),/* boundsBuilder= */ this::updateBorderBounds,/* targetView= */ this));//回收TypedArray对象以避免内存泄漏。ta.recycle();}

选择下分屏

确定选择下分屏,播放相关动画,调用SytemUI接口进入到真正分屏

代码路径:packages/apps/Launcher3/quickstep/src/com/android/quickstep/views/TaskView.java

    private void onClick(View view) {if (getTask() == null) {return;}if (confirmSecondSplitSelectApp()) {return;}launchTasks();mActivity.getStatsLogManager().logger().withItemInfo(getItemInfo()).log(LAUNCHER_TASK_LAUNCH_TAP);}/*** @return {@code true} if user is already in split select mode and this tap was to choose the*         second app. {@code false} otherwise*/protected boolean confirmSecondSplitSelectApp() {int index = getLastSelectedChildTaskIndex();TaskIdAttributeContainer container = mTaskIdAttributeContainer[index];if (container != null) {return getRecentsView().confirmSplitSelect(this, container.getTask(),container.getIconView().getDrawable(), container.getThumbnailView(),container.getThumbnailView().getThumbnail(), /* intent */ null,/* user */ null);}return false;}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com