Skip to content

Commit 416b05c

Browse files
flexaddictedNiklasMerz
authored andcommitted
Replace "beforeload" with BEFORELOAD (#524)
Improve code formatting
1 parent 9a15737 commit 416b05c

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/android/InAppBrowser.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ private HashMap<String, String> parseFeature(String optString) {
437437
if (option.hasMoreElements()) {
438438
String key = option.nextToken();
439439
String value = option.nextToken();
440-
if (!customizableOptions.contains(key)){
440+
if (!customizableOptions.contains(key)) {
441441
value = value.equals("yes") || value.equals("no") ? value : "yes";
442442
}
443443
map.put(key, value);
@@ -616,7 +616,7 @@ private boolean getShowLocationBar() {
616616
return this.showLocationBar;
617617
}
618618

619-
private InAppBrowser getInAppBrowser(){
619+
private InAppBrowser getInAppBrowser() {
620620
return this;
621621
}
622622

@@ -730,7 +730,7 @@ private int dpToPixels(int dipValue) {
730730
return value;
731731
}
732732

733-
private View createCloseButton(int id){
733+
private View createCloseButton(int id) {
734734
View _close;
735735
Resources activityRes = cordova.getActivity().getResources();
736736

@@ -906,9 +906,9 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
906906
// Footer
907907
RelativeLayout footer = new RelativeLayout(cordova.getActivity());
908908
int _footerColor;
909-
if(footerColor != ""){
909+
if(footerColor != "") {
910910
_footerColor = Color.parseColor(footerColor);
911-
}else{
911+
} else {
912912
_footerColor = android.graphics.Color.LTGRAY;
913913
}
914914
footer.setBackgroundColor(_footerColor);
@@ -1208,26 +1208,26 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
12081208

12091209
if (beforeload.equals("yes") && method == null) {
12101210
useBeforeload = true;
1211-
}else if(beforeload.equals("yes")
1211+
} else if(beforeload.equals("yes")
12121212
//TODO handle POST requests then this condition can be removed:
12131213
&& !method.equals("POST"))
12141214
{
12151215
useBeforeload = true;
1216-
}else if(beforeload.equals("get") && (method == null || method.equals("GET"))){
1216+
} else if(beforeload.equals("get") && (method == null || method.equals("GET"))) {
12171217
useBeforeload = true;
1218-
}else if(beforeload.equals("post") && (method == null || method.equals("POST"))){
1218+
} else if(beforeload.equals("post") && (method == null || method.equals("POST"))) {
12191219
//TODO handle POST requests
12201220
errorMessage = "beforeload doesn't yet support POST requests";
12211221
}
12221222

12231223
// On first URL change, initiate JS callback. Only after the beforeload event, continue.
12241224
if (useBeforeload && this.waitForBeforeload) {
1225-
if(sendBeforeLoad(url, method)){
1225+
if(sendBeforeLoad(url, method)) {
12261226
return true;
12271227
}
12281228
}
12291229

1230-
if(errorMessage != null){
1230+
if(errorMessage != null) {
12311231
try {
12321232
LOG.e(LOG_TAG, errorMessage);
12331233
JSONObject obj = new JSONObject();
@@ -1236,7 +1236,7 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
12361236
obj.put("code", -1);
12371237
obj.put("message", errorMessage);
12381238
sendUpdate(obj, true, PluginResult.Status.ERROR);
1239-
}catch(Exception e){
1239+
} catch(Exception e) {
12401240
LOG.e(LOG_TAG, "Error sending loaderror for " + url + ": " + e.toString());
12411241
}
12421242
}
@@ -1322,12 +1322,12 @@ else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^
13221322
return override;
13231323
}
13241324

1325-
private boolean sendBeforeLoad(String url, String method){
1325+
private boolean sendBeforeLoad(String url, String method) {
13261326
try {
13271327
JSONObject obj = new JSONObject();
1328-
obj.put("type", "beforeload");
1328+
obj.put("type", BEFORELOAD);
13291329
obj.put("url", url);
1330-
if(method != null){
1330+
if(method != null) {
13311331
obj.put("method", method);
13321332
}
13331333
sendUpdate(obj, true);
@@ -1365,7 +1365,7 @@ public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceReque
13651365
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
13661366
}
13671367

1368-
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method){
1368+
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method) {
13691369
return response;
13701370
}
13711371

@@ -1406,13 +1406,11 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
14061406
}
14071407
}
14081408

1409-
1410-
14111409
public void onPageFinished(WebView view, String url) {
14121410
super.onPageFinished(view, url);
14131411

14141412
// Set the namespace for postMessage()
1415-
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
1413+
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
14161414
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
14171415
}
14181416

0 commit comments

Comments
 (0)