Launcher3桌面开发-Launcher3 抽屉型桌面改造成横屏桌面

这篇教程介绍了如何将Google的Launcher3从抽屉型桌面改造成横屏桌面。通过在LauncherModel的加载流程中添加自定义逻辑,实现应用数据的横向绑定。主要涉及的应用数据处理、工作区绑定以及waitUntilResume方法的使用。
摘要由CSDN通过智能技术生成

Launcher3源码地址:Launcher3-master
[This tutorial was written by Ticoo]

Google Launcher3默认是抽屉型的桌面,到Android 8.0依然是没有这样的功能。这样的功能是手机厂商提供给我们的,不得不说,横向排列的桌面
更适合国人的使用习惯,可能是使用iphone的习惯吧。

好,那我们如何实现这样功能呢?其实并不会太难的。

在Launcher加载流程里,我们知道桌面的数据是在LauncherModel的 LoaderTask完成加载的

我们在loadAndBindAllApps()方法调用之后添加一个verifyApplications()方法调用,为什么在这里调用呢?
因为只用当应用数据加载完全后,我们才能讲所有的应用进行横向绑定到Workspace的操作


        @Override
        public void run() {
            AppTypeHelper.configSystemAppIcon(mContext);

            synchronized (mLock) {
                if (mStopped) {
                    return;
                }
                mIsLoaderTaskRunning = true;
            }
            // Optimize for end-user experience: if the Launcher is up and // running with the
            // All Apps interface in the foreground, load All Apps first. Otherwise, load the
            // workspace first (default).
            keep_running:
            {
                if (DEBUG_LOADERS) {
                    Log.d(TAG, "step 1: loading workspace");
                }
                loadAndBindWorkspace();

                if (mStopped) {
                    break keep_running;
                }

                waitForIdle();

                // second step
                if (DEBUG_LOADERS) {
                    Log.d(TAG, "step 2: loading all apps");
                }
                loadAndBindAllApps();
            }

            if (LauncherAppState.getInstance().getInvariantDeviceProfile()
                    .isDisableAllApps) {
                verifyApplications();
            }
            // Clear out this reference, otherwise we end up holding it until all of the
            // callback runnables are done.
            mContext = null;

            synchronized (mLock) {
                // If we are still the last one to be scheduled, remove ourselves.
                if (mLoaderTask == this) {
                    mLoaderTask = null;
                }
                mIsLoaderTaskRunning = false;
                mHasLoaderCompletedOnce = tru
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值