cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sgreb...@apache.org
Subject [03/11] cordova-plugin-inappbrowser git commit: CB-10407: Re-adding onPageStarted to re-add LOAD_START, even though it's in the wrong place
Date Tue, 02 Feb 2016 11:38:05 GMT
CB-10407: Re-adding onPageStarted to re-add LOAD_START, even though it's in the wrong place


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/8da5e25e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/8da5e25e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/8da5e25e

Branch: refs/heads/1.2.x
Commit: 8da5e25eeee892590f3ddb781a4fde8e9f8ef512
Parents: 15a5748
Author: Joe Bowser <bowserj@apache.org>
Authored: Fri Jan 22 14:22:53 2016 -0800
Committer: Joe Bowser <bowserj@apache.org>
Committed: Fri Jan 22 14:22:58 2016 -0800

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8da5e25e/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index b912439..256c064 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -820,6 +820,45 @@ public class InAppBrowser extends CordovaPlugin {
         }
 
 
+        /*
+         * onPageStarted fires the LOAD_START_EVENT
+         *
+         * @param view
+         * @param url
+         * @param favicon
+         */
+        @Override
+        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+            super.onPageStarted(view, url, favicon);
+            String newloc = "";
+            if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:"))
{
+                newloc = url;
+            }
+            else
+            {
+                // Assume that everything is HTTP at this point, because if we don't specify,
+                // it really should be.  Complain loudly about this!!!
+                LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI");
+                newloc = "http://" + url;
+            }
+
+            // Update the UI if we haven't already
+            if (!newloc.equals(edittext.getText().toString())) {
+                edittext.setText(newloc);
+             }
+
+            try {
+                JSONObject obj = new JSONObject();
+                obj.put("type", LOAD_START_EVENT);
+                obj.put("url", newloc);
+                sendUpdate(obj, true);
+            } catch (JSONException ex) {
+                LOG.e(LOG_TAG, "URI passed in has caused a JSON error.");
+            }
+        }
+
+
+
         public void onPageFinished(WebView view, String url) {
             super.onPageFinished(view, url);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message