【源码剖析】Launcher 8.0 源码 (12) --- Launcher 启动流程 第五步之计算桌面各布局细节参数

  • 时间:2020-04-24 21:10 作者:lonamessi 来源: 阅读:1138
  • 扫一扫,手机访问
摘要:第四步主要讲解了桌面布局的创立与绑定,这篇主要是讲各布局的细节参数的计算。我们来看一下这一步的具体代码。 mDeviceProfile.layout(this, false /* notifyListeners */); loadExtractedColorsAndColorItem

第四步主要讲解了桌面布局的创立与绑定,这篇主要是讲各布局的细节参数的计算。

我们来看一下这一步的具体代码。

  mDeviceProfile.layout(this, false /* notifyListeners */);        loadExtractedColorsAndColorItems();        mPopupDataProvider = new PopupDataProvider(this);        ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE))                .addAccessibilityStateChangeListener(this);        restoreState(savedInstanceState);        // We only load the page synchronously if the user rotates (or triggers a        // configuration change) while launcher is in the foreground        int currentScreen = PagedView.INVALID_RESTORE_PAGE;        if (savedInstanceState != null) {            currentScreen = savedInstanceState.getInt(RUNTIME_STATE_CURRENT_SCREEN, currentScreen);        }
1.mDeviceProfile.layout(this, false /* notifyListeners */);

在该方法中有少量具体的注释,主要是桌面具体控件布局的位置放置,包括searchbar,allapps,workspace,hotseat,indicators,等等。
// Layout the search bar space
//Layout the all apps
// Layout the workspace
// Layout the hotseat
// Layout the page indicators
//layout the arrow tips
//// Layout the flat menu page indicators
// Layout the Overview Mode
// Layout the snack tips
// Layout the AllAppsRecyclerView

2.loadExtractedColorsAndColorItems();

此方法中是设置控件的颜色

private void loadExtractedColorsAndColorItems() {        // TODO: do this in pre-N as well, once the extraction part is complete.        if (Utilities.ATLEAST_NOUGAT) {            mExtractedColors.load(this);            mHotseat.updateColor(mExtractedColors, !mPaused);            mWorkspace.getPageIndicator().updateColor(mExtractedColors);        }    }

会根据壁纸的颜色,来调节Hotseat,pageIndicator的颜色。workspace图标文字的颜色。

3.mPopupDataProvider = new PopupDataProvider(this);

当你长按桌面图片,或者者allapps里面的图标的时候会弹出来一个窗口,窗口里面有几个选项可供选择。

4.((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE))
            .addAccessibilityStateChangeListener(this);

监听桌面的变化,进行事件分发,AccessibilityManager是系统级别的服务,用来管理AccessibilityService服务,比方分发事件,查询系统中服务的状态等等。

5.对界面,以及数据进行恢复
restoreState(savedInstanceState);        if (LauncherAppState.PROFILE_STARTUP) {            Trace.endSection();        }        // We only load the page synchronously if the user rotates (or triggers a        // configuration change) while launcher is in the foreground        int currentScreen = PagedView.INVALID_RESTORE_PAGE;        if (savedInstanceState != null) {            currentScreen = savedInstanceState.getInt(RUNTIME_STATE_CURRENT_SCREEN, currentScreen);        }

这里进行数据的保存与恢复。这里运用了安卓的数据储存恢复机制,对保存在savedInstanceState里面的数据进行恢复。

到这里整个Launcher 启动流程 第五步之计算桌面各布局细节参数,就分析完了。接下来继续讲解。

  • 全部评论(0)
最新发布的资讯信息
【系统环境|】2FA验证器 验证码如何登录(2024-04-01 20:18)
【系统环境|】怎么做才能建设好外贸网站?(2023-12-20 10:05)
【系统环境|数据库】 潮玩宇宙游戏道具收集方法(2023-12-12 16:13)
【系统环境|】遥遥领先!青否数字人直播系统5.0发布,支持真人接管实时驱动!(2023-10-12 17:31)
【系统环境|服务器应用】克隆自己的数字人形象需要几步?(2023-09-20 17:13)
【系统环境|】Tiktok登录教程(2023-02-13 14:17)
【系统环境|】ZORRO佐罗软件安装教程及一键新机使用方法详细简介(2023-02-10 21:56)
【系统环境|】阿里云 centos 云盘扩容命令(2023-01-10 16:35)
【系统环境|】补单系统搭建补单源码搭建(2022-05-18 11:35)
【系统环境|服务器应用】高端显卡再度登上热搜,竟然是因为“断崖式”的降价(2022-04-12 19:47)
手机二维码手机访问领取大礼包
返回顶部