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

Commit 471beb0

Browse files
Pass the FlutterView to app message listeners (#2767)
This will make it simpler to write listeners that can be reused in multiple applications.
1 parent f8b2cca commit 471beb0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sky/shell/platform/android/io/flutter/view/FlutterView.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,15 @@ public interface OnMessageListener {
610610
* Called when a message is received from the Flutter app.
611611
* @return the reply to the message (can be null)
612612
*/
613-
String onMessage(String message);
613+
String onMessage(FlutterView view, String message);
614614
};
615615

616616
public interface OnMessageListenerAsync {
617617
/**
618618
* Called when a message is received from the Flutter app.
619619
* @param response Used to send a reply back to the app.
620620
*/
621-
void onMessage(String message, MessageResponse response);
621+
void onMessage(FlutterView view, String message, MessageResponse response);
622622
}
623623

624624
public interface MessageResponse {
@@ -636,13 +636,13 @@ public void onConnectionError(MojoException e) {}
636636
public void sendString(String messageName, String message, SendStringResponse callback) {
637637
OnMessageListener listener = mOnMessageListeners.get(messageName);
638638
if (listener != null) {
639-
callback.call(listener.onMessage(message));
639+
callback.call(listener.onMessage(FlutterView.this, message));
640640
return;
641641
}
642642

643643
OnMessageListenerAsync asyncListener = mAsyncOnMessageListeners.get(messageName);
644644
if (asyncListener != null) {
645-
asyncListener.onMessage(message, new MessageResponseAdapter(callback));
645+
asyncListener.onMessage(FlutterView.this, message, new MessageResponseAdapter(callback));
646646
return;
647647
}
648648

0 commit comments

Comments
 (0)