Launcher 类及类关系分析

1.

MVC模式(Model模型-View视图-Controller控制器)

 

  • (控制器Controller)- 负责转发请求,对请求进行处理。
  • (视图View) - 界面设计人员进行图形界面设计。
  • (模型Model) - 程序员编写程序应有的功能(实现算法等等)、数据库专家进行数据管理和数据库设计(可以实现具体的功能)。

 

Model模型---LauncherModel

View视图---DragLayer

Controller控制器---launcher

 

2.生成Javadoc协助分析

 

3.LauncherModel

 

3.1 BroadcastReceiver
public class LauncherModel
   
   
    
    extends 
    
    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(拖动控制窗口)。 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值