Search in sources :

Example 6 with URLInterceptorWebViewClient

use of org.edx.mobile.view.custom.URLInterceptorWebViewClient in project edx-app-android by edx.

the class CourseDetailFragment method populateAboutThisCourse.

/**
 * Takes a string which can include html and then renders it into the courseAbout webview.
 *
 * @param overview A string that can contain html tags
 */
private void populateAboutThisCourse(String overview) {
    courseAbout.setVisibility(View.VISIBLE);
    URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), courseAboutWebView);
    client.setAllLinksAsExternal(true);
    StringBuilder buff = WebViewUtil.getIntialWebviewBuffer(getActivity(), logger);
    buff.append("<body>");
    buff.append("<div class=\"header\">");
    buff.append(overview);
    buff.append("</div>");
    buff.append("</body>");
    courseAboutWebView.clearCache(true);
    courseAboutWebView.loadDataWithBaseURL(environment.getConfig().getApiHostURL(), buff.toString(), "text/html", StandardCharsets.UTF_8.name(), null);
}
Also used : URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

Example 7 with URLInterceptorWebViewClient

use of org.edx.mobile.view.custom.URLInterceptorWebViewClient in project edx-app-android by edx.

the class CourseHandoutFragment method onViewCreated.

@SuppressLint("SetJavaScriptEnabled")
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    errorNotification = new FullScreenErrorNotification(webview);
    snackbarErrorNotification = new SnackbarErrorNotification(webview);
    new URLInterceptorWebViewClient(getActivity(), webview).setAllLinksAsExternal(true);
    loadData();
}
Also used : FullScreenErrorNotification(org.edx.mobile.http.notifications.FullScreenErrorNotification) SnackbarErrorNotification(org.edx.mobile.http.notifications.SnackbarErrorNotification) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient) SuppressLint(android.annotation.SuppressLint)

Aggregations

URLInterceptorWebViewClient (org.edx.mobile.view.custom.URLInterceptorWebViewClient)7 View (android.view.View)2 WebResourceRequest (android.webkit.WebResourceRequest)2 WebResourceResponse (android.webkit.WebResourceResponse)2 WebView (android.webkit.WebView)2 SuppressLint (android.annotation.SuppressLint)1 ProgressBar (android.widget.ProgressBar)1 LikeView (com.facebook.widget.LikeView)1 FullScreenErrorNotification (org.edx.mobile.http.notifications.FullScreenErrorNotification)1 SnackbarErrorNotification (org.edx.mobile.http.notifications.SnackbarErrorNotification)1 EdxWebView (org.edx.mobile.view.custom.EdxWebView)1