本文主要是介绍Launcher 类及类关系分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.
MVC模式(Model模型-View视图-Controller控制器)
- (控制器Controller)- 负责转发请求,对请求进行处理。
- (视图View) - 界面设计人员进行图形界面设计。
- (模型Model) - 程序员编写程序应有的功能(实现算法等等)、数据库专家进行数据管理和数据库设计(可以实现具体的功能)。
Model模型---LauncherModel
View视图---DragLayer
Controller控制器---launcher
2.生成Javadoc协助分析
3.LauncherModel
3.1 BroadcastReceiver
public class LauncherModelextends BroadcastReceiver
Maintains in-memory state of the Launcher. It is expected that there should be only one LauncherModel object held in a static. Also provide APIs for updating the database state for the Launcher.
注册BroadcastReceiver
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
registerReceiver(mModel, filter);
实现OnReceive方法
onReceive(Context context, Intent intent)
Call from the handler for ACTION_PACKAGE_ADDED, ACTION_PACKAGE_REMOVED and ACTION_PACKAGE_CHANGED.
3.2 异步加载allapps的内容
/**
* Runnable for the thread that loads the contents of the launcher:
* - workspace icons
* - widgets
* - all apps icons
*/
private class LoaderThread extends Thread
4 DragLayer
它是整个launcher的父节点,继承FrameLayout, 实现接口DrayController(拖动控制窗口)。
这篇关于Launcher 类及类关系分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!