Skip to content

Commit 5caf8aa

Browse files
committed
feat(android): allow custom native WebViewClient
Will be much more performant that the N JS one, plus will use threading
1 parent 8c9b6e3 commit 5caf8aa

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/webview/index.android.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ export class AWebView extends WebViewExtBase {
539539

540540
public supportXLocalScheme = true;
541541

542+
public createWebViewClient?: (AWebView, clientClass: typeof WebViewExtClient) => android.webkit.WebViewClient;
543+
542544
public readonly instance = ++instanceNo;
543545

544546
public android: AndroidWebView;
@@ -576,11 +578,17 @@ export class AWebView extends WebViewExtBase {
576578
if (!nativeView) {
577579
return;
578580
}
581+
if (this.createWebViewClient) {
582+
const client = this.createWebViewClient(this, WebViewExtClient);
579583

580-
const client = new WebViewExtClient(this);
584+
nativeView.setWebViewClient(client);
585+
nativeView.client = client;
586+
} else {
587+
const client = new WebViewExtClient(this);
588+
nativeView.setWebViewClient(client);
589+
nativeView.client = client;
590+
}
581591
const chromeClient = new WebChromeViewExtClient(this);
582-
nativeView.setWebViewClient(client);
583-
nativeView.client = client;
584592

585593
nativeView.setWebChromeClient(chromeClient);
586594
nativeView.chromeClient = chromeClient;

0 commit comments

Comments
 (0)