openharmony launcher 调研笔记(03)UI 数据装配

本文详细描述了在Launcher中,GridSwiper组件如何处理PageDesktopLayout的数据,包括父子逻辑,AppList的获取、过滤、新增和存储,以及与LauncherAbilityManager和数据库的交互过程。
摘要由CSDN通过智能技术生成

最近在看launcher,把自己调研的点做个笔记,持续修改更新中个人笔记酌情参考

=========================================================================

桌面上半部分包含父子逻辑:

Column() {
        PageDesktopLayout();
}

PageDesktopLayout->GridSwiper->Swiper->SwiperPage

1.PageDesktopLayout

        此类没有需要特别注意的,只是多定一个dialogController传递给了 GridSwiper 用于长按显示设置,显示内容为settingDialog控件

2.GridSwiper

        Swiper(this.swiperController) {
            ForEach(this.pageList, (item: number, index: number) => {

                    pageList 

                    // 此数据来源于 SMARTDOCK_INIT_FINISHED 事件触发的 (上一章有提及)

                   // PageDesktopViewModelget 的 getGridList() 函数内的getAppList() 及一些列计算

                    // 最终调用 AppStorage.setOrCreate(KEY_APP_LIST, appInfo);

                   //(const KEY_APP_LIST = 'appListInfo';)

                   // 触发 updatePageList  @Watch('updatePageList'),此函数完成数据的最终加工

                      getGridList()   

                          const appInfoList = await this.getAppList();

                                1.this.mAppModel.getAppList()  //(AppModel类)

                                        this.getAppListAsync();  //(AppModel类)

                                                launcherAbilityManager.getLauncherAbilityList();                

                                                //(LauncherAbilityManager )

                                                        launcherBundleMgr.getAllLauncherAbilityInfos(

                                                                LauncherAbilityManager.CURRENT_USER_ID

                                                        )

                                                        // (innerBundleManager) 

                                                        // function getAllLauncherAbilityInfos(userId:number)

                                                           :Promise<Array<LauncherAbilityInfo>>;

                                  abilityList[i].applicationInfo.name 

                                  //(abilityList : Array<LauncherAbilityInfo>)

                                 获取数据如下 (原版有19个其中一个 为 系统应用被剔除)

                                // 系统应用 定义总字符串为 SystemApplication.SystemApplicationName

                                

                                2.this.mSettingsModel.getAppListInfo();

                                //此处数据为空时,将数据填入  (pageDesktopInfo.push(appInfo);)

                                //此处不为空时,过滤数据,删除卸载的app (pageDesktopInfo.filter)

                                3.this.addNewInstalledInfo(totalAppInfoList, pageDesktopInfo);

                                //新安装的app填入数组

                                4.this.removeBottomBarInfo(pageDesktopInfo);

                                //删除存在于dock栏的app(页面显示app和dock的app不重复)

                                5.this.removeFolderInfo(pageDesktopInfo);

                                // 删除在文件夹内的app,文件夹中的不在外部显示

                                6.this.mSettingsModel.setAppListInfo(pageDesktopInfo);

                                // 更新数据到this.mAppListInfo =appListInfo;( PageDesktopAppModeConfig )

                                // 和数据库(先删除再在insert)

                                7.AppStorage.setOrCreate('isDesktopLoadFinished', true);

                                // 设置isDesktopLoadFinished为true

                                // if (this.desktopLoadFinished) 可继续向下执行 (GridSwiper)

                        this.appendAppData(appInfoList, bundleInfoListTemp);

                                // 将app 列表里面不是隐藏app 的 添加到 bundleInfoListTemp 中

                                // 将类别设置为 appInfoList[i].typeId = CommonConstants.TYPE_APP; 

                                // 将区域设置为 appInfoList[i].area = [1, 1];

                        const folderInfoList = await this.mFolderModel.getFolderList();

                                // 获取文件夹列表

                                this.appendFolderData(folderInfoList, bundleInfoListTemp);

                                // 此处为添加,实际是从bundleInfoListTemp去除文件夹的数据 ???

                        formInfoList = await this.mFormModel.getAllFormsInfoFromRdb()

                                // 读取服务卡片数据

                        this.appendFormData(formInfoList, bundleInfoListTemp);

                                // 将卡片数据 添加到 bundleInfoListTemp 中

                        this.pagingFiltering();

                               const info = this.getAndSetLayoutInfo();

                                // 获取 Layout 显示数据 显示位置 第几页 几行 几列      

                                (

                               layoutInfo[i].typeId == CommonConstants.TYPE_FOLDER

                               layoutInfo[i].typeId == CommonConstants.TYPE_CARD        

                                appListInfo.push(this.mBundleInfoList[j]);

                                )           

                                // 分三类将数据填入 总的 appListInfo (app folder card)

                        AppStorage.setOrCreate(KEY_APP_LIST, appInfo);

                              // 触发 updatePageList 函数    (GridSwiper)

                        总的页面显示数据(pageList)装配完成

  • 14
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值