android.webkit.WebViewClient Java Examples

The following examples show how to use android.webkit.WebViewClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PresentationActivity.java    From Pimp_my_Z1 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //noinspection ConstantConditions
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setContentView(R.layout.presentation_activity);
    mWebView = (WebView) findViewById(R.id.webView);
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.loadUrl("file:///android_asset/slides/index.html");
}
 
Example #2
Source File: TaskAddHtml.java    From pe-protector-moe with GNU General Public License v3.0 6 votes vote down vote up
public TaskAddHtml(WebView webview, HttpFinishCallBack callBack) {
    this.callBack = callBack;
    List<MapConfigBean> list = LitePal.findAll(MapConfigBean.class);
    List<String> name = new ArrayList<>();
    for (MapConfigBean m : list) {
        name.add(m.name);
    }
    webview.loadUrl("file:///android_asset/html/task.html");
    webview.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            view.loadUrl(String.format("javascript:onLoad(\'%s\')", JSON.toJSONString(name)));
        }
    });
}
 
Example #3
Source File: OriginalDocsActivity.java    From LearningAppAndroid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView markdownView = (WebView) findViewById(R.id.markdownView);
    markdownView.getSettings().setJavaScriptEnabled(true);
    markdownView.loadUrl(getResources().getString(R.string.official_remote_url));
    markdownView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }
    });

    MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
        @Override
        public void ready(MarketingCloudSdk marketingCloudSdk) {
            marketingCloudSdk.getAnalyticsManager().trackPageView("data://OriginalDocsActivity", getResources().getString(R.string.official_remote_url), null, null);
        }
    });
}
 
Example #4
Source File: IssuePreviewActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void resetView() {
       setContentView(R.layout.activity_issue_preview);

	((TextView) findViewById(R.id.title)).setText(Utils.stripTags(title));

       final WebView web = (WebView) findViewById(R.id.detailsLabel);
       web.loadDataWithBaseURL(null, details, "text/html", "utf-8", null);
       web.setWebViewClient(new WebViewClient() {
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
           	try {
           		view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
           	} catch (Exception failed) {
           		return false;
           	}
               return true;
           }
       });
}
 
Example #5
Source File: AboutActivity.java    From AntennaPodSP with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide();
    setContentView(R.layout.about);
    webview = (WebView) findViewById(R.id.webvAbout);
    webview.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.startsWith("http")) {
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(url));
                startActivity(i);
            } else {
                view.loadUrl(url);
            }
            return false;
        }

    });
    webview.loadUrl("file:///android_asset/about.html");
}
 
Example #6
Source File: SystemWebViewClient.java    From BigDataPlatform with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #7
Source File: FocusWebViewClient.java    From firefox-echo-show with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    handler.cancel();

    // WebView can try to load the favicon for a bad page when you set a new URL. If we then
    // loadErrorPage() again, WebView tries to load the favicon again. We end up in onReceivedSSlError()
    // again, and we get an infinite loop of reloads (we also erroneously show the favicon URL
    // in the toolbar, but that's less noticeable). Hence we check whether this error is from
    // the desired page, or a page resource:
    if (error.getUrl().equals(currentPageURL)) {
        TelemetryWrapper.sslErrorEvent(true, error);
        ErrorPage.loadErrorPage(view, error.getUrl(), WebViewClient.ERROR_FAILED_SSL_HANDSHAKE);
    } else {
        TelemetryWrapper.sslErrorEvent(false, error);
    }
}
 
Example #8
Source File: DetailFragment.java    From ListItemFold with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_blank, container, false);

    mWebview = (WebView) view.findViewById(R.id.h5_web);
    WebSettings webSettings = mWebview.getSettings();
    webSettings.setSupportZoom(false);
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setJavaScriptEnabled(true);
    mWebview.setWebChromeClient(new WebChromeClient());
    mWebview.setWebViewClient(new WebViewClient());
    mWebview.loadUrl(mUrl);
    DetailAnimViewGroup wrapper = new DetailAnimViewGroup(inflater.getContext(), view, 0);
    wrapper.setReversed(false);
    return wrapper;
}
 
Example #9
Source File: AlbumPlayActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
private void initWebView() {
    if (this.mWebView == null) {
        this.mWebView = new WebView(this);
        this.mWebView.setBackgroundColor(-1);
        this.rootView.addView(this.mWebView, new LayoutParams(-1, -1));
        this.mWebView.getSettings().setUseWideViewPort(true);
        this.mWebView.getSettings().setSupportZoom(true);
        this.mWebView.getSettings().setBuiltInZoomControls(true);
        this.mWebView.setVerticalScrollBarEnabled(true);
        this.mWebView.setHorizontalScrollBarEnabled(true);
        this.mWebView.getSettings().setJavaScriptEnabled(true);
        this.mWebView.getSettings().setDomStorageEnabled(true);
        this.mWebView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                AlbumPlayActivity.this.mWebView.loadUrl(url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
        this.mWebView.setClickable(false);
    }
}
 
Example #10
Source File: MessageEffects.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
static void toggleInvisibleInk(final WebView invisibleInkView, final ViewGroup bubble, TextView text, LinearLayout replay){
    bubble.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

    text.setVisibility(View.GONE);
    replay.setVisibility(View.GONE);
    invisibleInkView.setVisibility(View.VISIBLE);

    String invisibleInk = "<html><head><style type='text/css' rel='stylesheet'> html { margin: 0; padding: 0em; }</style></head><body><span class='ink'>" + text.getText() + "</span> <script src='jquery.js' type='text/javascript'></script> <script src='invisibleink.js' type='text/javascript'></script></body></html>";

    invisibleInkView.loadDataWithBaseURL("file:///android_asset/html/", invisibleInk, "text/html", "UTF-8", null);
    invisibleInkView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            invisibleInkView.loadUrl("javascript:weMessage.resizeInvisibleInk(document.body.getBoundingClientRect().height)");
            super.onPageFinished(view, url);
        }
    });
}
 
Example #11
Source File: PluginWebViewActivity.java    From Android-Plugin-Framework with MIT License 6 votes vote down vote up
private void setClient() {

		web.setWebChromeClient(new WebChromeClient() {
		});

		// 如果要自动唤起自定义的scheme,不能设置WebViewClient,
		// 否则,需要在shouldOverrideUrlLoading中自行处理自定义scheme
		// webView.setWebViewClient();
		web.setWebViewClient(new WebViewClient() {

			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				view.loadUrl(url);
				return true;
			}

		});
	}
 
Example #12
Source File: IssuePreviewActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public void resetView() {
       setContentView(R.layout.activity_issue_preview);

	((TextView) findViewById(R.id.title)).setText(Utils.stripTags(title));

       final WebView web = (WebView) findViewById(R.id.detailsLabel);
       web.loadDataWithBaseURL(null, details, "text/html", "utf-8", null);
       web.setWebViewClient(new WebViewClient() {
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
           	try {
           		view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
           	} catch (Exception failed) {
           		return false;
           	}
               return true;
           }
       });
}
 
Example #13
Source File: SystemWebViewClient.java    From countly-sdk-cordova with MIT License 6 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param view          The WebView that is initiating the callback.
 * @param errorCode     The error code corresponding to an ERROR_* value.
 * @param description   A String describing the error.
 * @param failingUrl    The url that failed to load.
 */
@Override
@SuppressWarnings("deprecation")
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    // Ignore error due to stopLoading().
    if (!isCurrentlyLoading) {
        return;
    }
    LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);

    // If this is a "Protocol Not Supported" error, then revert to the previous
    // page. If there was no previous page, then punt. The application's config
    // is likely incorrect (start page set to sms: or something like that)
    if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
        parentEngine.client.clearLoadTimeoutTimer();

        if (view.canGoBack()) {
            view.goBack();
            return;
        } else {
            super.onReceivedError(view, errorCode, description, failingUrl);
        }
    }
    parentEngine.client.onReceivedError(errorCode, description, failingUrl);
}
 
Example #14
Source File: ApplicationModule.java    From v9porn with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Provides
@Singleton
static WebView providesWebView(@ApplicationContext Context context){
    Logger.t(TAG).d("初始化");
    WebView mWebView = new WebView(context);

    WebSettings mWebSettings = mWebView.getSettings();

    //启用JavaScript。
    mWebSettings.setJavaScriptEnabled(true);
    mWebSettings.setUseWideViewPort(true);
    mWebSettings.setJavaScriptCanOpenWindowsAutomatically(true);

    mWebView.loadUrl("file:///android_asset/web/index.html"); //js文件路径
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            Logger.t(TAG).d("加载完成..:" + url);
        }
    });
    return mWebView;
}
 
Example #15
Source File: CustomWebViewActivity.java    From JsBridge with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Custom WebView");
    jsBridge = JsBridge.loadModule();
    WebView.setWebContentsDebuggingEnabled(true);
    customWebView = new CustomWebView(this);
    setContentView(customWebView);
    customWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            jsBridge.injectJs(customWebView);
        }
    });
    customWebView.setPromptResult(new PromptResultCallback() {
        @Override
        public void onResult(String args, PromptResultImpl promptResult) {
            jsBridge.callJsPrompt(args, promptResult);
        }
    });
    customWebView.loadUrl("file:///android_asset/sample.html");
}
 
Example #16
Source File: WebTextActivity.java    From YCCustomText with Apache License 2.0 6 votes vote down vote up
public void initWebView(String data) {
    WebView mWebView = findViewById(R.id.showdiarys);
    WebSettings settings = mWebView.getSettings();

    //settings.setUseWideViewPort(true);//调整到适合webview的大小,不过尽量不要用,有些手机有问题
    settings.setLoadWithOverviewMode(true);//设置WebView是否使用预览模式加载界面。
    mWebView.setVerticalScrollBarEnabled(false);//不能垂直滑动
    mWebView.setHorizontalScrollBarEnabled(false);//不能水平滑动
    settings.setTextSize(WebSettings.TextSize.NORMAL);//通过设置WebSettings,改变HTML中文字的大小
    settings.setJavaScriptCanOpenWindowsAutomatically(true);//支持通过JS打开新窗口
    //设置WebView属性,能够执行Javascript脚本
    mWebView.getSettings().setJavaScriptEnabled(true);//设置js可用
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.addJavascriptInterface(new AndroidJavaScript(getApplication()), "android");//设置js接口
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);//支持内容重新布局

    mWebView.loadUrl(data);
}
 
Example #17
Source File: ChatWindowView.java    From chat-window-android with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onReceivedError(final WebView view, final WebResourceRequest request, final WebResourceError error) {
    final boolean errorHandled = chatWindowListener != null && chatWindowListener.onError(ChatWindowErrorType.WebViewClient, error.getErrorCode(), String.valueOf(error.getDescription()));
    post(new Runnable() {
        @Override
        public void run() {
            onErrorDetected(errorHandled, ChatWindowErrorType.WebViewClient, error.getErrorCode(), String.valueOf(error.getDescription()));
        }
    });

    super.onReceivedError(view, request, error);
    Log.e("ChatWindow Widget", "onReceivedError: " + error.getErrorCode() + ": desc: " + error.getDescription() + " url: " + request.getUrl());
}
 
Example #18
Source File: WebViewUtils.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public static void loadUrl(Context mContext, WebView webview, String url,
                           boolean javaScriptEnabled) {
    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(javaScriptEnabled);
    webview.setWebViewClient(new WebViewClient());
    webview.loadUrl(url);
}
 
Example #19
Source File: CordovaActivity.java    From cordova-plugin-intent with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode    The error code corresponding to an ERROR_* value.
 * @param description  A String describing the error.
 * @param failingUrl   The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example #20
Source File: CreateReplyActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_create_reply);
       
       if (MainActivity.instance instanceof ForumConfig) {
       	HttpGetImageAction.fetchImage(this, MainActivity.instance.avatar, findViewById(R.id.icon));
       } else {
       	((ImageView)findViewById(R.id.icon)).setImageResource(R.drawable.icon);
       }
       
       TextView text = (TextView) findViewById(R.id.topicText);
       text.setText(MainActivity.post.topic);
       
       CheckBox checkbox = (CheckBox) findViewById(R.id.replyToParentCheckBox);
       if (MainActivity.post.parent != null && MainActivity.post.parent.length() != 0) {
       	checkbox.setChecked(true);
       } else {
       	checkbox.setVisibility(View.GONE);
       }
       
       final WebView web = (WebView) findViewById(R.id.detailsLabel);
       web.loadDataWithBaseURL(null, MainActivity.post.detailsText, "text/html", "utf-8", null);
       
       web.setWebViewClient(new WebViewClient() {
           public boolean shouldOverrideUrlLoading(WebView view, String url) {
           	try {
           		view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
           	} catch (Exception failed) {
           		return false;
           	}
               return true;
           }
       });
}
 
Example #21
Source File: ArticleViewAdapter.java    From GankMeizhi with Apache License 2.0 5 votes vote down vote up
private void initWebview(WebView webView) {
    webView.setWebChromeClient(new WebChromeClient());
    webView.setWebViewClient(new WebViewClient());
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webView.getSettings().setAppCacheEnabled(true);

    webView.requestFocus();
    webView.getSettings().getAllowFileAccess();
}
 
Example #22
Source File: BaseWebActivity.java    From qrcode_android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onWebViewReceivedError(WebView view, int errorCode, CharSequence description, String failingUrl) {
    Log.i("0000", "errorCode:   " + errorCode);
    switch (errorCode) {
        case WebViewClient.ERROR_CONNECT:
        case WebViewClient.ERROR_TIMEOUT:
        case WebViewClient.ERROR_HOST_LOOKUP:
        case WebViewClient.ERROR_BAD_URL:
            showErrorHint(failingUrl);
            break;
    }
}
 
Example #23
Source File: WebViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initWebView() {
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient());
    WebSettings settings = mWebView.getSettings();
    settings.setSavePassword(true);
    settings.setSaveFormData(true);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDomStorageEnabled(true);
    settings.setSupportMultipleWindows(false);


    mWebView.loadUrl("http://developer.android.com");
}
 
Example #24
Source File: ServerApprovalDialogFragment.java    From Intra with Apache License 2.0 5 votes vote down vote up
private View makeWebView(int index) {
  final String url = getResources().getStringArray(R.array.server_websites)[index];

  final WebView webView = new WebView(getContext());
  webView.getSettings().setJavaScriptEnabled(true);
  webView.setWebViewClient(new WebViewClient());  // Makes navigation stay in this webview.
  webView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  webView.loadUrl(url);

  return webView;
}
 
Example #25
Source File: BaseWebActivity.java    From QRScanner with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onWebViewReceivedError(WebView view, int errorCode, CharSequence description, String failingUrl) {
    Log.i("0000", "errorCode:   " + errorCode);
    switch (errorCode) {
        case WebViewClient.ERROR_CONNECT:
        case WebViewClient.ERROR_TIMEOUT:
        case WebViewClient.ERROR_HOST_LOOKUP:
        case WebViewClient.ERROR_BAD_URL:
            showErrorHint(failingUrl);
            break;
    }
}
 
Example #26
Source File: CordovaActivity.java    From cordova-plugin-app-update-demo with MIT License 5 votes vote down vote up
/**
 * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 * The errorCode parameter corresponds to one of the ERROR_* constants.
 *
 * @param errorCode   The error code corresponding to an ERROR_* value.
 * @param description A String describing the error.
 * @param failingUrl  The url that failed to load.
 */
public void onReceivedError(final int errorCode, final String description, final String failingUrl) {
    final CordovaActivity me = this;

    // If errorUrl specified, then load it
    final String errorUrl = preferences.getString("errorUrl", null);
    if ((errorUrl != null) && (!failingUrl.equals(errorUrl)) && (appView != null)) {
        // Load URL on UI thread
        me.runOnUiThread(new Runnable() {
            public void run() {
                me.appView.showWebPage(errorUrl, false, true, null);
            }
        });
    }
    // If not, then display error dialog
    else {
        final boolean exit = !(errorCode == WebViewClient.ERROR_HOST_LOOKUP);
        me.runOnUiThread(new Runnable() {
            public void run() {
                if (exit) {
                    me.appView.getView().setVisibility(View.GONE);
                    me.displayError("Application Error", description + " (" + failingUrl + ")", "OK", exit);
                }
            }
        });
    }
}
 
Example #27
Source File: FastWebView.java    From FastWebView with MIT License 5 votes vote down vote up
@Override
public void setWebViewClient(WebViewClient client) {
    if (mFastClient != null) {
        mFastClient.updateProxyClient(client);
    } else {
        super.setWebViewClient(client);
    }
    mUserWebViewClient = client;
}
 
Example #28
Source File: InAppBrowser.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
/**
 * Closes the dialog
 */
public void closeDialog() {
    final WebView childView = this.inAppWebView;
    // The JS protects against multiple calls, so this should happen only when
    // closeDialog() is called by other native code.
    if (childView == null) {
        return;
    }
    this.cordova.getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            childView.setWebViewClient(new WebViewClient() {
                // NB: wait for about:blank before dismissing
                public void onPageFinished(WebView view, String url) {
            if (dialog != null) {
                dialog.dismiss();
            }
        }
    });
            // NB: From SDK 19: "If you call methods on WebView from any thread 
            // other than your app's UI thread, it can cause unexpected results."
            // http://developer.android.com/guide/webapps/migrating.html#Threads
            childView.loadUrl("about:blank");
        }
    });

    try {
        JSONObject obj = new JSONObject();
        obj.put("type", EXIT_EVENT);
        sendUpdate(obj, false);
    } catch (JSONException ex) {
        Log.d(LOG_TAG, "Should never happen");
    }
}
 
Example #29
Source File: NetContentFragment.java    From pandora with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@Override
protected View getLayoutView() {
    webView = new WebView(getContext());
    webView.getSettings().setDefaultTextEncodingName("UTF-8");
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            loadData();
        }
    });
    return webView;
}
 
Example #30
Source File: WebViewSimpleActivity.java    From StickHeaderLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);

    WebView v_scroll = (WebView)findViewById(R.id.v_scroll);
    v_scroll.loadUrl("http://www.github.com/w446108264");
    v_scroll.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    });
}