android Launcher:AllApps的更新分析

(1)在LauncherApplecation中注册应用的addremoveupdate的监听

mModel是一个LauncherModel的实例

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


(2)在LauncherModel.javaonReceive()方法中,当接收到应用改变的广  播时new一个PackageUpdateTask,mAllAppList更改成功后调用  Callbacks接口中的bindAppsAdded()等等方法,(Launcher.java类实  现了Callbacks接口)。在bindAppsAdded()方法中调用AllApps2D.java  中的addApps()方法,在addApps方法中更新UI

enqueuePackageUpdated(newPackageUpdatedTask(op,newString[]{ packageName}));


Launcher.java中对bindAppsAdded方法的实现如下:

public void bindAppsAdded(ArrayList apps) {
setLoadOnResume();
removeDialog(DIALOG_CREATE_SHORTCUT);
mAllAppsGrid.addApps(apps);
}


你可能感兴趣的:(android,launcher,启动器)