-
Notifications
You must be signed in to change notification settings - Fork 27
Wrap WebViewClient to provide custom web view client implementation #96
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
Wrap WebViewClient to provide custom web view client implementation #96
Conversation
Demo/src/main/java/com/braintreepayments/popupbridge/demo/CustomWebViewClient.java
Outdated
Show resolved
Hide resolved
PopupBridge/src/main/java/com/braintreepayments/api/PopupBridgeClient.kt
Show resolved
Hide resolved
| import android.webkit.WebViewClient | ||
| import com.braintreepayments.api.internal.isVenmoInstalled | ||
|
|
||
| open class PopupBridgeWebViewClient : WebViewClient() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, it is possible to make this class as a wrapper that receives library user WebViewClient implementation as a delegate?
class PopupBridgeWebViewClient(
private val delegate: WebViewClient? = null
) : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
setVenmoInstalled(view, view?.context?.isVenmoInstalled() == true)
delegate?.onPageFinished(view, url)
}
// same for other methods
}
I know it is painful to override all the calls with delegate calls inside, but this approach doesn't limit library users to inheriting strictly from PopupBridgeWebViewClient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seviraristocrat Thanks for reporting the bug and suggesting the solution!
PopupBridge/src/test/java/com/braintreepayments/api/PopupBridgeWebViewClientTest.kt
Show resolved
Hide resolved
PopupBridge/src/test/java/com/braintreepayments/api/PopupBridgeWebViewClientTest.kt
Show resolved
Hide resolved
…eWebViewClientTest.kt Co-authored-by: Tim Chow <[email protected]>
Summary of changes
PopupBridgeWebViewClientthat merchants can implement to extend WebViewClient functionality.Checklist
Authors