杂乱的3.14

Launcher2: 一、 launcher.xml分析: DragLayer是整个屏幕。 对于Workspace,在Launcher.xml源码中,说 , 但是,我觉得应该是 . 应该是有5个cell的,就是通过左下脚和右下脚那些“点点”切换出来的那5个桌面。 对于源码中的那两个ClippedImageView就是左下脚和右下脚那些“点点”。 对于DeleteZone,应该是当用户在桌面上长按一个widget时,把手位置就会出现一个垃圾桶形状的控件,就是这个控件。 对于HandleView,就是phone与browser中间的那个,点击它可以出来所有的应用程序。 对于源码中的那两个ImageView 就分别是电话状(phone)、地球状(browser)的那两个图标。 二、 Launcher两个Activity切换时的动画效果(渐变),相关代码: Launcher.java public void onClick(View v) { Object tag = v.getTag(); //取得标签,即判断被click的对象是什么 if (tag instanceof ShortcutInfo) {//如果是快捷键 // Open shortcut final Intent intent = ((ShortcutInfo) tag).intent; int[] pos = new int[2]; v.getLocationOnScreen(pos); intent.setSourceBounds(new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1] + v.getHeight())); startActivitySafely(intent, tag); } else if (tag instanceof FolderInfo) {//如果是文件夹 handleFolderClick((FolderInfo) tag); } else if (v == mHandleView) {//如果是HandleView if (isAllAppsVisible()) { closeAllApps(true); //退出 fade out } else { showAllApps(true); } } } public boolean isAllAppsVisible() { return (mAllAppsGrid != null) ? mAllAppsGrid.isVisible() : false; } void showAllApps(boolean animated) { mAllAppsGrid.zoom(1.0f, animated); ((View) mAllAppsGrid).setFocusable(true); ((View) mAllAppsGrid).requestFocus(); // TODO: fade these two too mDeleteZone.setVisibility(View.GONE); } void closeAllApps(boolean animated) { if (mAllAppsGrid.isVisible()) { mWorkspace.setVisibility(View.VISIBLE); mAllAppsGrid.zoom(0.0f, animated); ((View)mAllAppsGrid).setFocusable(false); mWorkspace.getChildAt(mWorkspace.getCurrentScreen()).requestFocus(); } } AllApps2D.java /** * Zoom to the specifed level. * * @param zoom [0..1] 0 is hidden, 1 is open */ public void zoom(float zoom, boolean animate) { // Log.d(TAG, "zooming " + ((zoom == 1.0) ? "open" : "closed")); cancelLongPress(); mZoom = zoom; if (isVisible()) { getParent().bringChildToFront(this); setVisibility(View.VISIBLE); mGrid.setAdapter(mAppsAdapter); if (animate) { startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.all_apps_2d_fade_in)); } else { onAnimationEnd(); } } else { if (animate) { startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.all_apps_2d_fade_out)); } else { onAnimationEnd(); } } } protected void onAnimationEnd() { if (!isVisible()) { setVisibility(View.GONE); mGrid.setAdapter(null); mZoom = 0.0f; } else { mZoom = 1.0f; } mLauncher.zoomed(mZoom); } public boolean isVisible() { return mZoom > 0.001f; } config.xml 三、 Launcher启动流程: 1、LauncherApplication app = ((LauncherApplication)getApplication());//取得Launcher这个系统应用程序 2、设置Launcher的相关属性 3、loadHotseats();加载browser相关的信息。与arrays.xml有关 4、checkForLocaleChange();事件发生的地点的configration是否改变,如果改变了,则把之前的configration重新回写进去。 5、setWallpaperDimension();设置墙纸的位置、尺寸 6、setContentView(R.layout.launcher);把launcher.xml的内容展示出来 7、setupViews();Finds all the views we need and configure them properly. 8、registerContentObservers();?? 9、lockAllApps();这个函数什么也没干 10、restoreState(…);Restores the previous state, if it exists. 11、startLoader();//重新装载 这个函数在LauncherModel.java的Loader.startLoader中。 这个函数的具体过程: 1)、mLoaderThread = new LoaderThread(context, oldThread, isLaunching); mLoaderThread.start(); 创建一个LoaderThread,然后mLoaderThread.start()启动run函数(run()函数在class Loader Thread中) 2)、run(): step 1: loading workspace loadWorkspace():// 把数据库中Launcher上的所有app,shortcut,folder,livefolder,appwidget分类读出来 step 2: loading all apps bindWorkspace(): callbacks.startBinding();//yh:清空workspace中当前所有的view callbacks.bindItems(mItems, start, start+chunkSize);//yh:绑定或者说装载Items,显示到屏幕上 callbacks.bindFolders(mFolders);//yh:邦好与folder相关的 callbacks.bindAppWidget(widget);//yh:绑定widget,显示到屏幕 step3: callbacks.finishBindingItems();//yh:把所有的folder装载上,把要显示的folder用4*4个cell显示出来 其它问题: 1、 onActivityResult();什么时候会进到这个方法里呢? 2、 onRetainNonConfigurationInstance什么时候会进到这个方法里呢? 3、
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值