Merge pull request #8 from hypothermic/master

Fix NullPointerException in MyWebViewClient
This commit is contained in:
Max 2019-02-16 16:35:35 +01:00 committed by GitHub
commit 1e48553263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,8 @@ class MyWebViewClient extends WebViewClient {
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) {
Uri uri = Uri.parse(url);
if (uri.getHost() != null && uri.getHost().contains("example.com")) {
return false;
}
@ -20,4 +21,4 @@ class MyWebViewClient extends WebViewClient {
view.getContext().startActivity(intent);
return true;
}
}
}