Skip to content

Commit

Permalink
fix android onresized event in new arch
Browse files Browse the repository at this point in the history
  • Loading branch information
NMGuner committed May 22, 2024
1 parent b65bab2 commit 5af8561
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ public void sendKlarnaMobileSDKError(@Nullable KlarnaCheckoutView view, @NonNull
KlarnaEventHandlerEventsUtil.sendKlarnaMobileSDKError(this, view, klarnaMobileSDKError);
}

public void sendOnResizedEvent(@Nullable EventDispatcher eventDispatcher, int viewId, int height) {
public void sendOnResizedEvent(@Nullable KlarnaCheckoutView view, int height) {
WritableMap params = ArgumentsUtil.createMap(
new HashMap<String, Object>() {{
put("height", String.valueOf(height));
}}
);
ComponentEvent event = new ComponentEvent(viewId, EVENT_NAME_ON_RESIZED, params);
postEvent(eventDispatcher, event);
postEventForView(view, EVENT_NAME_ON_RESIZED, params);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected ResizeObserverWrapperView<KlarnaCheckoutView> createViewInstance(@NonN
if (eventDispatcher == null) {
return;
}
eventSender.sendOnResizedEvent(eventDispatcher, resizeObserverWrapperView.getId(), newHeight);
eventSender.sendOnResizedEvent(resizeObserverWrapperView.getView(), newHeight);
});
view.addInterfaceToWebView();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ protected void postEvent(@Nullable EventDispatcher eventDispatcher, @NonNull Com

protected ComponentEvent createEvent(@Nullable View view, @NonNull String eventName, @Nullable WritableMap params) {
T viewReference = getView(view);
if (view == null) {
if (viewReference == null) {
return null;
}
return new ComponentEvent(view.getId(), eventName, params);
return new ComponentEvent(viewReference.getId(), eventName, params);
}

protected void postEventForView(@Nullable View view, @NonNull String eventName, @Nullable WritableMap params) {
Expand Down

0 comments on commit 5af8561

Please sign in to comment.