zoukankan      html  css  js  c++  java
  • 【系统之音】window

    window

         flag:设置window的属性,控制其显示特性

         type:表示Window的类型,有三种类型

                    应用Window:对应着一个Activity。层级范围:1~99

                    子Window:不能独立存在,需要依附于特定的父Window。比如Dialog,PopWindow。层级范围:1000~1999

                    系统Window:需要声明权限才能创建的Window。比如Toast,系统状态栏。层级范围:2000~2999

         interface ViewManager

                addView(view,params);

                updateViewLayout(view,params);

                removeView(view);

           interface WindowManager extends ViewManager

           final class WindowManagerImpl implements WindowManager {

                 //典型的桥接模式

                 WindowManagerGlobal mGlobal = WindowManagerGlobal.getInstance(); 

                 @override

                 addView(view,params){

                      mGlobal.addView(...);

                 }

                 updateViewLayout(view,params){

                      mGlobal.updateViewLayout(...);

                 }

                 remove(view){

                      mGlobal.remove(...);

                 }

           }

        WindowManagerGlobal.getInstance()的单例实现

    private static WindowManagerGlobal sDefaultWindowManager;
    public static WindowManagerGlobal getInstance() {
    synchronized (WindowManagerGlobal.class) {
    if (sDefaultWindowManager == null) {
    sDefaultWindowManager = new WindowManagerGlobal();
    }
    return sDefaultWindowManager;
    }
    }
    如果对单例模式比较了解的话,就能看出这种实现方式是有问题的(对比DCL方式),但不明白系统源码为什么要这样实现。

    WindowMangerGlobal.java中的四个非常重要的list
    private final ArrayList<View> mViews = new ArrayList<View>();
    private final ArrayList<ViewRootImpl> mRoots = new ArrayList<ViewRootImpl>();
    private final ArrayList<WindowManager.LayoutParams> mParams = new ArrayList<WindowManager.LayoutParams>;
    private final ArraySet<View> mDyingViews = new ArraySet<View>;


  • 相关阅读:
    标签最低高度设置minheight不兼容
    字体综合属性(font)写法顺序为
    让IE6、IE7、IE8支持CSS3的圆角、阴影样式
    微信小程序3D轮播图
    微信小程序左滑删除
    android ble 蓝牙4.0开发日志(四)
    Windows邮件服务器hMailServer,网页前端访问平台Webmail搭建
    邮件服务器hMailServer管理工具hMailServer Administrator汉化
    蓝牙设计
    Windows下搭建免费、开源的邮件服务器hMailServer
  • 原文地址:https://www.cnblogs.com/andy-songwei/p/13295396.html
Copyright © 2011-2022 走看看