@Test public void shouldOverrideUrlLoading_withMoPubFailLoad_shouldCallLoadFailUrl() throws Exception { boolean didOverrideUrl = subject.shouldOverrideUrlLoading(htmlWebView, "mopub: assertThat(didOverrideUrl).isTrue(); verify(htmlWebViewListener).onFailed(UNSPECIFIED); }
@Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { new UrlHandler.Builder() .withSupportedUrlActions( UrlAction.HANDLE_MOPUB_SCHEME, UrlAction.IGNORE_ABOUT_SCHEME, UrlAction.HANDLE_PHONE_SCHEME, UrlAction.OPEN_APP_MARKET, UrlAction.OPEN_NATIVE_BROWSER, UrlAction.OPEN_IN_APP_BROWSER, UrlAction.HANDLE_SHARE_TWEET, UrlAction.FOLLOW_DEEP_LINK) .withResultActions(new UrlHandler.ResultActions() { @Override public void urlHandlingSucceeded(@NonNull String url, @NonNull UrlAction urlAction) { if (mHtmlWebView.wasClicked()) { mHtmlWebViewListener.onClicked(); mHtmlWebView.onResetUserClick(); } } @Override public void urlHandlingFailed(@NonNull String url, @NonNull UrlAction lastFailedUrlAction) { } }) .withMoPubSchemeListener(new UrlHandler.MoPubSchemeListener() { @Override public void onFinishLoad() { mHtmlWebViewListener.onLoaded(mHtmlWebView); } @Override public void onClose() { mHtmlWebViewListener.onCollapsed(); } @Override public void onFailLoad() { mHtmlWebViewListener.onFailed(UNSPECIFIED); } }) .build().handleUrl(mContext, url, mHtmlWebView.wasClicked()); return true; }
HtmlWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { new UrlHandler.Builder() .withSupportedUrlActions( UrlAction.HANDLE_MOPUB_SCHEME, UrlAction.IGNORE_ABOUT_SCHEME, UrlAction.HANDLE_PHONE_SCHEME, UrlAction.OPEN_APP_MARKET, UrlAction.OPEN_NATIVE_BROWSER, UrlAction.OPEN_IN_APP_BROWSER, UrlAction.HANDLE_SHARE_TWEET, UrlAction.FOLLOW_DEEP_LINK) .withResultActions(new UrlHandler.ResultActions() { @Override public void urlHandlingSucceeded(@NonNull String url, @NonNull UrlAction urlAction) { if (mHtmlWebView.wasClicked()) { mHtmlWebViewListener.onClicked(); mHtmlWebView.onResetUserClick(); } } @Override public void urlHandlingFailed(@NonNull String url, @NonNull UrlAction lastFailedUrlAction) { } }) .withMoPubSchemeListener(new UrlHandler.MoPubSchemeListener() { @Override public void onFinishLoad() { mHtmlWebViewListener.onLoaded(mHtmlWebView); } @Override public void onClose() { mHtmlWebViewListener.onCollapsed(); } @Override public void onFailLoad() { mHtmlWebViewListener.onFailed(UNSPECIFIED); } }) .build().handleUrl(mContext, url, mHtmlWebView.wasClicked()); return true; } }
HtmlWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { new UrlHandler.Builder() .withSupportedUrlActions( UrlAction.HANDLE_MOPUB_SCHEME, UrlAction.IGNORE_ABOUT_SCHEME, UrlAction.HANDLE_PHONE_SCHEME, UrlAction.OPEN_APP_MARKET, UrlAction.OPEN_NATIVE_BROWSER, UrlAction.OPEN_IN_APP_BROWSER, UrlAction.HANDLE_SHARE_TWEET, UrlAction.FOLLOW_DEEP_LINK) .withResultActions(new UrlHandler.ResultActions() { @Override public void urlHandlingSucceeded(@NonNull String url, @NonNull UrlAction urlAction) { if (mHtmlWebView.wasClicked()) { mHtmlWebViewListener.onClicked(); mHtmlWebView.onResetUserClick(); } } @Override public void urlHandlingFailed(@NonNull String url, @NonNull UrlAction lastFailedUrlAction) { } }) .withMoPubSchemeListener(new UrlHandler.MoPubSchemeListener() { @Override public void onFinishLoad() { mHtmlWebViewListener.onLoaded(mHtmlWebView); } @Override public void onClose() { mHtmlWebViewListener.onCollapsed(); } @Override public void onFailLoad() { mHtmlWebViewListener.onFailed(UNSPECIFIED); } }) .build().handleUrl(mContext, url, mHtmlWebView.wasClicked()); return true; } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); }
HtmlWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { new UrlHandler.Builder() .withSupportedUrlActions( UrlAction.HANDLE_MOPUB_SCHEME, UrlAction.IGNORE_ABOUT_SCHEME, UrlAction.HANDLE_PHONE_SCHEME, UrlAction.OPEN_APP_MARKET, UrlAction.OPEN_NATIVE_BROWSER, UrlAction.OPEN_IN_APP_BROWSER, UrlAction.HANDLE_SHARE_TWEET, UrlAction.FOLLOW_DEEP_LINK) .withResultActions(new UrlHandler.ResultActions() { @Override public void urlHandlingSucceeded(@NonNull String url, @NonNull UrlAction urlAction) { if (mHtmlWebView.wasClicked()) { mHtmlWebViewListener.onClicked(); mHtmlWebView.onResetUserClick(); } } @Override public void urlHandlingFailed(@NonNull String url, @NonNull UrlAction lastFailedUrlAction) { } }) .withMoPubSchemeListener(new UrlHandler.MoPubSchemeListener() { @Override public void onFinishLoad() { mHtmlWebViewListener.onLoaded(mHtmlWebView); } @Override public void onClose() { mHtmlWebViewListener.onCollapsed(); } @Override public void onFailLoad() { mHtmlWebViewListener.onFailed(UNSPECIFIED); } }) .build().handleUrl(mContext, url, mHtmlWebView.wasClicked()); return true; } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); @Override boolean shouldOverrideUrlLoading(final WebView view, final String url); @Override void onPageStarted(WebView view, String url, Bitmap favicon); }
HtmlWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { new UrlHandler.Builder() .withSupportedUrlActions( UrlAction.HANDLE_MOPUB_SCHEME, UrlAction.IGNORE_ABOUT_SCHEME, UrlAction.HANDLE_PHONE_SCHEME, UrlAction.OPEN_APP_MARKET, UrlAction.OPEN_NATIVE_BROWSER, UrlAction.OPEN_IN_APP_BROWSER, UrlAction.HANDLE_SHARE_TWEET, UrlAction.FOLLOW_DEEP_LINK) .withResultActions(new UrlHandler.ResultActions() { @Override public void urlHandlingSucceeded(@NonNull String url, @NonNull UrlAction urlAction) { if (mHtmlWebView.wasClicked()) { mHtmlWebViewListener.onClicked(); mHtmlWebView.onResetUserClick(); } } @Override public void urlHandlingFailed(@NonNull String url, @NonNull UrlAction lastFailedUrlAction) { } }) .withMoPubSchemeListener(new UrlHandler.MoPubSchemeListener() { @Override public void onFinishLoad() { mHtmlWebViewListener.onLoaded(mHtmlWebView); } @Override public void onClose() { mHtmlWebViewListener.onCollapsed(); } @Override public void onFailLoad() { mHtmlWebViewListener.onFailed(UNSPECIFIED); } }) .build().handleUrl(mContext, url, mHtmlWebView.wasClicked()); return true; } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); @Override boolean shouldOverrideUrlLoading(final WebView view, final String url); @Override void onPageStarted(WebView view, String url, Bitmap favicon);  }