I am trying to override the download Listener for a WebView so it gets to open websites not belonging to us in an external browser instead of loading them in the webview. Thing is, I'd like to simplify the code into something like this
webView?.setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
if (!url.contains("mydomain")) {
CLog.v("InternalWebviewFragment.configWebView().setDownloadListener() isNOTmydomain url: $url")
val i = Intent(Intent.ACTION_VIEW, Uri.parse(url))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity?.startActivity(i)
}else{
super(url, userAgent, contentDisposition, mimetype, contentLength)
}
}
However, that call to super there, which I intend to have for urls that do belong to our domain, says that can only be used on the left hand of a dot. When I try to type
super.onDownloadStart
it gives an unresolved reference error
.
How could I get the webview Listener to go on business as usual when the url is part of our domain? Is the super call only available in non-lambda methods?