Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: callback when bridge is created #26

Merged
merged 1 commit into from
Jan 9, 2023
Merged

Conversation

carlpoole
Copy link
Member

@carlpoole carlpoole commented Jan 6, 2023

Creates a callback similar to iOS https://github.com/ionic-team/ionic-portals-ios/blob/0cc7e1a025958f4731fde861fd1a1cf24211c2ed/Sources/IonicPortals/PortalView.swift#L14

passes the bridge to the callback when the private load() function is finished and the bridge should be non null. Requested by Paylocity. It was possible to get the bridge before but no assurance it was not null until after load() had been called.

Will add usage examples to the docs.

Kotlin use:

val portalFragment = PortalFragment(checkoutPortal, (bridge) -> {
    val portalWebView = bridge.getWebView();
});

Java use:

Direct use:

portalFragment = new PortalFragment(checkoutPortal, (bridge) -> {
    WebView portalWebView = bridge.getWebView();
    return null;
});

Subclass:

public class ProfileFragment extends PortalFragment {

    public static ProfileFragment newInstance() {
        return new ProfileFragment(PortalManager.getPortal("profile"), (bridge) -> {
            WebView myWebView = bridge.getWebView();
            return null;
        });
    }

    public ProfileFragment() {
        super();
    }

    public ProfileFragment(Portal portal) {
        super(portal);
    }

    public ProfileFragment(@Nullable Portal portal, @NonNull Function1<? super Bridge, Unit> onBridgeAvailable) {
        super(portal, onBridgeAvailable);
    }

    @Override
    public void onViewCreated(@NotNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        setHasOptionsMenu(false);
    }
}

@carlpoole carlpoole self-assigned this Jan 6, 2023
@carlpoole carlpoole changed the title feat(android): callback when bridge is created feat: callback when bridge is created Jan 6, 2023
@carlpoole carlpoole merged commit 65c9259 into main Jan 9, 2023
@carlpoole carlpoole deleted the android-bridge-callback branch January 9, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants