Skip to content

Commit f36852c

Browse files
authored
Merge pull request #36 from leonardo-fernandes/outsystems-fix-before-load
Fix beforeLoad not being called in some requests
2 parents d338752 + 96d929e commit f36852c

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/android/InAppBrowser.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,6 @@ else if (action.equals("loadAfterBeforeload")) {
273273
@SuppressLint("NewApi")
274274
@Override
275275
public void run() {
276-
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
277-
currentClient.waitForBeforeload = false;
278-
inAppWebView.setWebViewClient(currentClient);
279-
} else {
280-
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
281-
}
282276
inAppWebView.loadUrl(url);
283277
}
284278
});
@@ -722,6 +716,8 @@ public String showWebPage(final String url, HashMap<String, String> features) {
722716
}
723717
if (features.get(BEFORELOAD) != null) {
724718
beforeload = features.get(BEFORELOAD);
719+
} else {
720+
beforeload = "";
725721
}
726722
String fullscreenSet = features.get(FULLSCREEN);
727723
if (fullscreenSet != null) {
@@ -1173,7 +1169,6 @@ public class InAppBrowserClient extends WebViewClient {
11731169
EditText edittext;
11741170
CordovaWebView webView;
11751171
String beforeload;
1176-
boolean waitForBeforeload;
11771172

11781173
/**
11791174
* Constructor.
@@ -1185,7 +1180,6 @@ public InAppBrowserClient(CordovaWebView webView, EditText mEditText, String bef
11851180
this.webView = webView;
11861181
this.edittext = mEditText;
11871182
this.beforeload = beforeload;
1188-
this.waitForBeforeload = beforeload != null;
11891183
}
11901184

11911185
/**
@@ -1246,7 +1240,7 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
12461240
}
12471241

12481242
// On first URL change, initiate JS callback. Only after the beforeload event, continue.
1249-
if (useBeforeload && this.waitForBeforeload) {
1243+
if (useBeforeload) {
12501244
if(sendBeforeLoad(url, method)) {
12511245
return true;
12521246
}
@@ -1341,9 +1335,6 @@ else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^
13411335
}
13421336
}
13431337

1344-
if (useBeforeload) {
1345-
this.waitForBeforeload = true;
1346-
}
13471338
return override;
13481339
}
13491340

www/inappbrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
_eventHandler: function (event) {
4242
if (event && (event.type in this.channels)) {
4343
if (event.type === 'beforeload') {
44-
this.channels[event.type].fire(event, this._loadAfterBeforeload);
44+
this.channels[event.type].fire(event, this._loadAfterBeforeload.bind(this));
4545
} else {
4646
this.channels[event.type].fire(event);
4747
}

0 commit comments

Comments
 (0)