Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7521767

Browse files
author
Emmanuel Garcia
committed
fixes
1 parent 34819ef commit 7521767

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

shell/platform/android/io/flutter/plugin/platform/PlatformView.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ public interface PlatformView {
1616
View getView();
1717

1818
/**
19-
* Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this {@code
20-
* PlatformView} when the Android {@link View} responsible for rendering a Flutter UI is
21-
* associated with the {@link io.flutter.embedding.engine.FlutterEngine}.
19+
* Called when the {@link View} responsible for rendering a Flutter UI has been attached to a
20+
* {@link io.flutter.embedding.engine.FlutterEngine}.
2221
*
2322
* <p>This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} can now
2423
* render a UI and interact with the user.
@@ -34,9 +33,8 @@ public interface PlatformView {
3433
default void onFlutterViewAttached(@NonNull View flutterView) {}
3534

3635
/**
37-
* Called by the {@link io.flutter.embedding.engine.FlutterEngine} that owns this {@code
38-
* PlatformView} when the Android {@link View} responsible for rendering a Flutter UI is detached
39-
* and disassociated from the {@link io.flutter.embedding.engine.FlutterEngine}.
36+
* Called when the {@link View} responsible for rendering a Flutter UI has been detached from the
37+
* {@link io.flutter.embedding.engine.FlutterEngine}.
4038
*
4139
* <p>This means that our associated {@link io.flutter.embedding.engine.FlutterEngine} no longer
4240
* has a rendering surface, or a user interaction surface of any kind.

shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public long createForTextureLayer(
255255
});
256256
flutterView.addView(wrapperView);
257257
viewWrappers.append(viewId, wrapperView);
258+
platformView.onFlutterViewAttached(flutterView);
258259
return txId;
259260
}
260261

@@ -794,6 +795,7 @@ void initializePlatformViewIfNeeded(int viewId) {
794795

795796
parentView.addView(embeddedView);
796797
flutterView.addView(parentView);
798+
platformView.onFlutterViewAttached(flutterView);
797799
}
798800

799801
public void attachToFlutterRenderer(@NonNull FlutterRenderer flutterRenderer) {

testing/scenario_app/android/app/src/main/java/dev/flutter/scenarios/TextPlatformView.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ public class TextPlatformView implements PlatformView {
2222
textView.setTextSize(72);
2323
textView.setBackgroundColor(Color.rgb(255, 255, 255));
2424
textView.setText(params);
25+
}
2526

27+
@Override
28+
public void onFlutterViewAttached(@NonNull View flutterView) {
2629
// Investigate why this is needed to make some gold tests pass.
2730
Choreographer.getInstance()
28-
.postFrameCallback(
31+
.postFrameCallbackDelayed(
2932
new Choreographer.FrameCallback() {
3033
@Override
3134
public void doFrame(long frameTimeNanos) {
3235
textView.invalidate();
3336
}
34-
});
37+
},
38+
500);
3539
}
3640

3741
@Override

0 commit comments

Comments
 (0)