144 {
145
146
148 getView().postDelayed(onNewSizeFrameAvailable, 0);
149 return;
150 }
151 if (
Build.VERSION.SDK_INT >= API_LEVELS.API_31) {
153 return;
154 }
155 boolean isFocused =
getView().isFocused();
157
158 virtualDisplay.setSurface(null);
159 virtualDisplay.release();
160
161 final DisplayManager displayManager =
162 (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
165 virtualDisplay =
166 displayManager.createVirtualDisplay(
167 "flutter-vd#" + viewId,
170 densityDpi,
173 callback,
174 null );
175
176 final View embeddedView =
getView();
177
178
179
180
181 embeddedView.addOnAttachStateChangeListener(
182 new View.OnAttachStateChangeListener() {
183 @Override
184 public void onViewAttachedToWindow(View v) {
185 OneTimeOnDrawListener.schedule(
186 embeddedView,
187 new Runnable() {
188 @Override
189 public void run() {
190
191
192
193
194
195
196
197
198
199 embeddedView.postDelayed(onNewSizeFrameAvailable, 128);
200 }
201 });
202 embeddedView.removeOnAttachStateChangeListener(this);
203 }
204
205 @Override
206 public void onViewDetachedFromWindow(View v) {}
207 });
208
209
210
211
212
213 SingleViewPresentation newPresentation =
214 new SingleViewPresentation(
215 context,
216 virtualDisplay.getDisplay(),
217 accessibilityEventsDelegate,
218 presentationState,
219 focusChangeListener,
220 isFocused);
221 newPresentation.show();
224 }
def Build(configs, env, options)