Android launcher3 – launcher3源码4

默认布局怎样加载到桌面显示,有兴趣可阅读【墨香带你学Launcher之(三)-绑定屏幕、图标、文件夹和Widget】,其中流程图不错。

图标加载开始

Launcher.java 调用startLoader,启动LoaderTask

public void startLoader(int synchronousBindPage) {    startLoader(synchronousBindPage, LOADER_FLAG_NONE);}public void startLoader(int synchronousBindPage, int loadFlags) {    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems    InstallShortcutReceiver.enableInstallQueue();    synchronized (mLock) {        // Clear any deferred bind-runnables from the synchronized load process        // We must do this before any loading/binding is scheduled below.        synchronized (mDeferredBindRunnables) {            mDeferredBindRunnables.clear();        }        // Don't bother to start the thread if we know it's not going to do anything        if (mCallbacks != null && mCallbacks.get() != null) {            // If there is already one running, tell it to stop.            stopLoaderLocked();            mLoaderTask = new LoaderTask(mApp.getContext(), loadFlags);            if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE                    && mAllAppsLoaded && mWorkspaceLoaded && !mIsLoaderTaskRunning) {                mLoaderTask.runBindSynchronousPage(synchronousBindPage);            } else {                sWorkerThread.setPriority(Thread.NORM_PRIORITY);                sWorker.post(mLoaderTask);            }        }    }}

LauncherModel.java:异步线程LoaderTask加载图标

public void run() {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 stepif (DEBUG_LOADERS) Log.d(TAG, "step 2: loading all apps");loadAndBindAllApps();}// 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 = true;}}

//step 1: loading workspace
loadAndBindWorkspace();
//step 2: loading all apps
loadAndBindAllApps();

绑定workspace

private void loadAndBindWorkspace() {    ......    // Load the workspace    if (!mWorkspaceLoaded) {        loadWorkspace();        ......    }    // Bind the workspace    bindWorkspace(-1);}

更多相关文章

  1. Android(安卓)7.0 Launcher3的启动和加载流程分析----转载
  2. Android(安卓)安卓WebView套壳H5网页 手机返回键问题(过滤二级页
  3. android之隐藏另一个应用的图标并且禁用这个应用,不再桌面和应用
  4. android 带清除功能的EditText
  5. android 状态栏(StatusBar)
  6. WebView的基本使用方法及 WebViewClient加载网页使用
  7. 25、从头学Android之多媒体--使用SoundPool播放音频
  8. Android(安卓)Launcher 如何去掉主菜单,所有应用摆在桌面,类似小米
  9. android MultiDex

随机推荐

  1. android 获取apn
  2. android handler 学习
  3. android 图文列表的实现方法
  4. Android常用的简单代码
  5. Android数据库操作
  6. 使用universal-image-loader中出现的EOFE
  7. AndroidOpenCv配置
  8. The specified Android(安卓)SDK Build T
  9. android图片裁剪
  10. Android(安卓)获取GPS速度