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

[TIMOB-17754] Throw an event from webview #6528

Merged
merged 3 commits into from
Jan 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,14 @@ public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError e
Log.e(TAG, "SSL error occurred: " + error.toString());
}
}

@Override
public void onLoadResource(WebView view, String url)
{
super.onLoadResource(view, url);
KrollDict data = new KrollDict();
data.put(TiC.PROPERTY_URL, url);
webView.getProxy().fireEvent(TiC.EVENT_WEBVIEW_ON_LOAD_RESOURCE, data);
}

}
4 changes: 4 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ public class TiC
*/
public static final String EVENT_SSL_ERROR = "sslerror";

/**
* @module.api
*/
public static final String EVENT_WEBVIEW_ON_LOAD_RESOURCE = "onLoadResource";

/**
* @module.api
Expand Down
13 changes: 12 additions & 1 deletion apidoc/Titanium/UI/WebView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,18 @@ events:
properties:
- name: url
summary: URL of the web document.


- name: onLoadResource
summary: Fired when loading resource.
description: |
Android only. Notify the host application that the WebView will load the resource specified by the given url.
platforms: [android]
since: "3.6.0"
properties:
- name: url
summary: The url of the resource that will load.
type: String

- name: sslerror
summary: Fired when an SSL error occurred.
description: |
Expand Down