29
29
*
30
30
* The view hierarchy for the presentation is as following:
31
31
*
32
- * rootView
33
- * |
34
- * state.fakeWindowViewGroup
35
- * / \
36
- * state. container [other popup views]
37
- * |
38
- * EmbeddedView
32
+ * rootView
33
+ * / \
34
+ * / \
35
+ * / \
36
+ * container state.fakeWindowViewGroup
37
+ * |
38
+ * EmbeddedView
39
39
*/
40
40
@ TargetApi (Build .VERSION_CODES .JELLY_BEAN_MR1 )
41
41
class SingleViewPresentation extends Presentation {
@@ -55,9 +55,6 @@ static class PresentationState {
55
55
56
56
// Contains views that were added directly to the window manager (e.g android.widget.PopupWindow).
57
57
private FakeWindowViewGroup fakeWindowViewGroup ;
58
-
59
- // Contains the embedded platform view (platformView.getView()) when it is attached to the presentation.
60
- private FrameLayout container ;
61
58
}
62
59
63
60
private final PlatformViewFactory viewFactory ;
@@ -75,13 +72,13 @@ static class PresentationState {
75
72
// so when we create the platform view we can tell it its view id.
76
73
private Object createParams ;
77
74
78
- // The root view for the presentation, it has a single child called fakeWindowViewGroup which contains
79
- // views that were added directly to the presentation's window manager. fakeWindowViewGroup's first
80
- // child is the state.container which contains the embedded view. So all other views are drawn on-top but
81
- // the embedded view itself is not obscured directly by the fakeWindowViewGroup.
82
- //
75
+ // The root view for the presentation, it has 2 childs: container which contains the embedded view, and
76
+ // fakeWindowViewGroup which contains views that were added directly to the presentation's window manager.
83
77
private AccessibilityDelegatingFrameLayout rootView ;
84
78
79
+ // Contains the embedded platform view (platformView.getView()) when it is attached to the presentation.
80
+ private FrameLayout container ;
81
+
85
82
private PresentationState state ;
86
83
87
84
private boolean startFocused = false ;
@@ -145,26 +142,22 @@ protected void onCreate(Bundle savedInstanceState) {
145
142
if (state .fakeWindowViewGroup == null ) {
146
143
state .fakeWindowViewGroup = new FakeWindowViewGroup (getContext ());
147
144
}
148
- if (state .container == null ) {
149
- state .container = new FrameLayout (getContext ());
150
- final WindowManager .LayoutParams params = new WindowManager .LayoutParams ();
151
- params .gravity = Gravity .FILL ;
152
- state .fakeWindowViewGroup .addView (state .container , params );
153
- }
154
145
if (state .windowManagerHandler == null ) {
155
146
WindowManager windowManagerDelegate = (WindowManager ) getContext ().getSystemService (WINDOW_SERVICE );
156
147
state .windowManagerHandler = new WindowManagerHandler (windowManagerDelegate , state .fakeWindowViewGroup );
157
148
}
158
149
150
+ container = new FrameLayout (getContext ());
159
151
PresentationContext context = new PresentationContext (getContext (), state .windowManagerHandler );
160
152
161
153
if (state .platformView == null ) {
162
154
state .platformView = viewFactory .create (context , viewId , createParams );
163
155
}
164
156
165
157
View embeddedView = state .platformView .getView ();
166
- state . container .addView (embeddedView );
158
+ container .addView (embeddedView );
167
159
rootView = new AccessibilityDelegatingFrameLayout (getContext (), accessibilityEventsDelegate , embeddedView );
160
+ rootView .addView (container );
168
161
rootView .addView (state .fakeWindowViewGroup );
169
162
170
163
embeddedView .setOnFocusChangeListener (focusChangeListener );
@@ -178,7 +171,7 @@ protected void onCreate(Bundle savedInstanceState) {
178
171
}
179
172
180
173
public PresentationState detachState () {
181
- state . container .removeAllViews ();
174
+ container .removeAllViews ();
182
175
rootView .removeAllViews ();
183
176
return state ;
184
177
}
0 commit comments