Search in sources :

Example 1 with URLInterceptorWebViewClient

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

the class BaseWebViewFindCoursesActivity method setupWebView.

private void setupWebView() {
    URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView);
    // if all the links are to be treated as external
    client.setAllLinksAsExternal(isAllLinksExternal());
    client.setActionListener(this);
    client.setPageStatusListener(pageStatusListener);
}
Also used : URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

Example 2 with URLInterceptorWebViewClient

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

the class WebViewActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    super.setToolbarAsActionBar();
    final ProgressBar progress = (ProgressBar) findViewById(R.id.loading_indicator);
    progress.setVisibility(View.GONE);
    webView = (WebView) findViewById(R.id.webView);
    final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView);
    client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() {

        @Override
        public void onPageStarted() {
            progress.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished() {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) {
            if (isMainRequestFailure) {
                progress.setVisibility(View.GONE);
            }
        }

        @Override
        public void onPagePartiallyLoaded() {
            progress.setVisibility(View.GONE);
        }
    });
    webView.loadUrl(getIntent().getStringExtra(ARG_URL));
    final String title = getIntent().getStringExtra(ARG_TITLE);
    if (!TextUtils.isEmpty(title)) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(title);
    }
}
Also used : WebResourceRequest(android.webkit.WebResourceRequest) WebResourceResponse(android.webkit.WebResourceResponse) WebView(android.webkit.WebView) ProgressBar(android.widget.ProgressBar) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

Example 3 with URLInterceptorWebViewClient

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

the class BaseWebViewDiscoverFragment method initWebView.

private void initWebView() {
    URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), webView);
    // if all the links are to be treated as external
    client.setAllLinksAsExternal(isAllLinksExternal());
    client.setActionListener(this);
    client.setPageStatusListener(pageStatusListener);
}
Also used : URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

Example 4 with URLInterceptorWebViewClient

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

the class CertificateFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_certificate, container, false);
    webview = (WebView) view.findViewById(R.id.webview);
    final View loadingIndicator = view.findViewById(R.id.loading_indicator);
    final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), webview);
    client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() {

        @Override
        public void onPageStarted() {
            loadingIndicator.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished() {
            loadingIndicator.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) {
            loadingIndicator.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) {
            if (isMainRequestFailure) {
                loadingIndicator.setVisibility(View.GONE);
            }
        }

        @Override
        public void onPagePartiallyLoaded() {
            loadingIndicator.setVisibility(View.GONE);
        }
    });
    return view;
}
Also used : WebResourceRequest(android.webkit.WebResourceRequest) WebResourceResponse(android.webkit.WebResourceResponse) WebView(android.webkit.WebView) View(android.view.View) WebView(android.webkit.WebView) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

Example 5 with URLInterceptorWebViewClient

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

the class CourseCombinedInfoFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_course_combined_info, container, false);
    announcementWebView = (EdxWebView) view.findViewById(R.id.announcement_webview);
    URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(getActivity(), announcementWebView);
    // treat every link as external link in this view, so that all links will open in external browser
    client.setAllLinksAsExternal(true);
    notificationSettingRow = view.findViewById(R.id.notification_setting_row);
    notificationSwitch = (Switch) view.findViewById(R.id.notification_switch);
    return view;
}
Also used : View(android.view.View) EdxWebView(org.edx.mobile.view.custom.EdxWebView) LikeView(com.facebook.widget.LikeView) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient)

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