2929 *
3030 * The view hierarchy for the presentation is as following:
3131 *
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
3939 */
4040@ TargetApi (Build .VERSION_CODES .JELLY_BEAN_MR1 )
4141class SingleViewPresentation extends Presentation {
@@ -55,9 +55,6 @@ static class PresentationState {
5555
5656 // Contains views that were added directly to the window manager (e.g android.widget.PopupWindow).
5757 private FakeWindowViewGroup fakeWindowViewGroup ;
58-
59- // Contains the embedded platform view (platformView.getView()) when it is attached to the presentation.
60- private FrameLayout container ;
6158 }
6259
6360 private final PlatformViewFactory viewFactory ;
@@ -75,13 +72,13 @@ static class PresentationState {
7572 // so when we create the platform view we can tell it its view id.
7673 private Object createParams ;
7774
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.
8377 private AccessibilityDelegatingFrameLayout rootView ;
8478
79+ // Contains the embedded platform view (platformView.getView()) when it is attached to the presentation.
80+ private FrameLayout container ;
81+
8582 private PresentationState state ;
8683
8784 private boolean startFocused = false ;
@@ -145,26 +142,22 @@ protected void onCreate(Bundle savedInstanceState) {
145142 if (state .fakeWindowViewGroup == null ) {
146143 state .fakeWindowViewGroup = new FakeWindowViewGroup (getContext ());
147144 }
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- }
154145 if (state .windowManagerHandler == null ) {
155146 WindowManager windowManagerDelegate = (WindowManager ) getContext ().getSystemService (WINDOW_SERVICE );
156147 state .windowManagerHandler = new WindowManagerHandler (windowManagerDelegate , state .fakeWindowViewGroup );
157148 }
158149
150+ container = new FrameLayout (getContext ());
159151 PresentationContext context = new PresentationContext (getContext (), state .windowManagerHandler );
160152
161153 if (state .platformView == null ) {
162154 state .platformView = viewFactory .create (context , viewId , createParams );
163155 }
164156
165157 View embeddedView = state .platformView .getView ();
166- state . container .addView (embeddedView );
158+ container .addView (embeddedView );
167159 rootView = new AccessibilityDelegatingFrameLayout (getContext (), accessibilityEventsDelegate , embeddedView );
160+ rootView .addView (container );
168161 rootView .addView (state .fakeWindowViewGroup );
169162
170163 embeddedView .setOnFocusChangeListener (focusChangeListener );
@@ -178,7 +171,7 @@ protected void onCreate(Bundle savedInstanceState) {
178171 }
179172
180173 public PresentationState detachState () {
181- state . container .removeAllViews ();
174+ container .removeAllViews ();
182175 rootView .removeAllViews ();
183176 return state ;
184177 }
0 commit comments