ContextImpl和ContextWrapper都是繼承自Context淫僻,在ContextWrapper中依賴了ContextImpl對象(mBase)勤婚。這里使用了裝飾者模式菱父,ContextWrapper是裝飾類零抬,對ContextImpl進(jìn)行包裝反砌,通過使用ContextImpl實(shí)現(xiàn)功能猎拨。
Application膀藐、Service屠阻、ContextThemeWrapper繼承自ContextWrapper,它們也是通過ContextImpl實(shí)現(xiàn)功能额各,同時在ContextWrapper的基礎(chǔ)上添加了自己的功能国觉。此外ContextThemeWrapper中包含了主題相關(guān)的方法,Activity繼承自ContextThemeWrapper虾啦。