zoukankan      html  css  js  c++  java
  • 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();

       }

  • 相关阅读:
    一文快速入门分库分表(必修课)
    MySql分库分表与分区的区别和思考
    常用分库分表方案汇总
    分区分表分库
    MySQL分区和分表
    MySQL的聚集索引和非聚集索引
    PHP大文件上传支持断点上传组件
    PHP大文件上传支持断点上传工具
    Nginx大文件上传支持断点上传
    百度WebUploader大文件上传支持断点上传
  • 原文地址:https://www.cnblogs.com/greywolf/p/2831267.html
Copyright © 2011-2022 走看看