LauncherApplication

 

http://blog.csdn.net/hu2839fdjsfdsan/article/details/6570036

1.LauncherApplication的作用意义分析

概括:LauncherApplication属于自定义的Application类,并在AndroidManifest.xml里指定了自定义Application类,如下:

    <application

        android:name="com.android.launcher2.LauncherApplication"

        android:process="@string/process"

        android:label="@string/application_name"

        android:icon="@drawable/ic_launcher_home">

    </application>

作用:

a.创建全局使用的应用程序快捷方式的缓存.

    IconCache,即在LauncherApplication中创建.

b.创建全局使用的数据库加载类LauncherModel.

 

c.为LauncherModel注册package remove,update相关的Boradcast.为LauncherModel 注册favorites 修改的observer.

 

        // Register intent receivers

        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);

        filter = new IntentFilter();

        filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);

        filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);

        registerReceiver(mModel, filter);

 

        // Register for changes to the favorites

        ContentResolver resolver = getContentResolver();

        resolver.registerContentObserver(LauncherSettings.Favorites.CONTENT_URI, true,

                mFavoritesObserver);

 

d.提供全局使用的LauncherModel的入口.

    LauncherModel getModel() {

        return mModel;

    }

 

e.(父类)提供获取PackageManager,Resource,相关资源的方法.

   LauncherModel.java

       app.getPackageManager().getDefaultActivityIcon();

       app.getResources().getInteger();

 

f.提供Context作用.

 

2.IconCache

概括:

    这个类是提供系统全局使用的应用程序基本信息(title,icon)的缓存信息.这样每次使用的时候都能够从系统里很快得到.

 

作用:

    a.声明内部类对应存储应用程序的基本信息,因为home的作用就是需要展现这些东西。

       private static class CacheEntry {

           public Bitmap icon;

           public String title;

           public Bitmap titleBitmap;

     }

    b.提供应用程序的默认图标.

           private Bitmap makeDefaultIcon();

    c.提供全局的缓存信息.

           private final HashMap<ComponentName, CacheEntry> mCache;

 

 

3.LauncherModel

概括:

    在程序包,以及程序的快捷方式更改,添加时,更新数据库的表。加载更新workspace,all apps view的程序及快捷方式.

 

作用:

    a.声明接口Callbacks,提供了一系列加载程序及快捷方式的抽象方法.

   public interface Callbacks {

       public boolean setLoadOnResume();

 

       public int getCurrentWorkspaceScreen();

 

       public void startBinding();

 

       public void bindItems(ArrayList<ItemInfo> shortcuts, int start, int end);

 

       public void bindFolders(HashMap<Long,FolderInfo> folders);

 

       public void finishBindingItems();

 

       public void bindAppWidget(LauncherAppWidgetInfo info);

 

       public void bindAllApplications(ArrayList<ApplicationInfo> apps);

 

       public void bindAppsAdded(ArrayList<ApplicationInfo> apps);

 

       public void bindAppsUpdated(ArrayList<ApplicationInfo> apps);

 

       public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);

        public boolean isAllAppsVisible();

   }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值