Android(安卓)launcher3 -- launcher3源码4
16lz
2021-01-26
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);}
更多相关文章
- Android(安卓)7.0 Launcher3的启动和加载流程分析----转载
- Android(安卓)安卓WebView套壳H5网页 手机返回键问题(过滤二级页
- android之隐藏另一个应用的图标并且禁用这个应用,不再桌面和应用
- android 带清除功能的EditText
- android 状态栏(StatusBar)
- WebView的基本使用方法及 WebViewClient加载网页使用
- 25、从头学Android之多媒体--使用SoundPool播放音频
- Android(安卓)Launcher 如何去掉主菜单,所有应用摆在桌面,类似小米
- android MultiDex