Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slymax committed Jan 21, 2019
1 parent 5c5fc46 commit b2f9d68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/example/app/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.example.app;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
Expand All @@ -12,12 +11,13 @@ public class MainActivity extends Activity {

private WebView mWebView;

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mWebView = (WebView) findViewById(R.id.activity_main_webview);
mWebView = findViewById(R.id.activity_main_webview);

// Force links and redirects to open in the WebView instead of in a browser
mWebView.setWebViewClient(new WebViewClient());
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/com/example/app/MyWebViewClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MyWebViewClient extends WebViewClient {
import java.util.Objects;

class MyWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().endsWith("example.com")) {
if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) {
return false;
}

Expand Down

0 comments on commit b2f9d68

Please sign in to comment.