• 【系统之音】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>;


  • 相关阅读:
    env文件的作用
    Ubuntu 卸载wine
    Linux配置yaf3.x.x环境
    yaf中使用Cli模式,也就是定时器
    Yaf 在Bootstrap中注册变量,然后在其他地方进行使用!
    yaf 查看配置
    yaf配置通用函数
    一个严谨的接口调用
    后台基础表
    tensorflow环境搭建
  • 原文地址:https://www.cnblogs.com/andy-songwei/p/13295396.html
Copyright © 2020-2023  润新知