diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/base/FindCoursesBaseActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/base/FindCoursesBaseActivity.java index 94948260bf..161f7b35a0 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/base/FindCoursesBaseActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/base/FindCoursesBaseActivity.java @@ -357,9 +357,12 @@ public void onPageLoadError(WebView view, int errorCode, String description, Str } @Override - public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { - isWebViewLoaded = false; - showOfflineMessage(); + public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, + boolean isMainRequestFailure) { + if (isMainRequestFailure) { + isWebViewLoaded = false; + showOfflineMessage(); + } } @Override diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CertificateFragment.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CertificateFragment.java index b61e9c8ccb..27c0ecfa5b 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CertificateFragment.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CertificateFragment.java @@ -109,8 +109,11 @@ public void onPageLoadError(WebView view, int errorCode, String description, Str } @Override - public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { - loadingIndicator.setVisibility(View.GONE); + public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, + boolean isMainRequestFailure) { + if (isMainRequestFailure) { + loadingIndicator.setVisibility(View.GONE); + } } @Override diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitWebViewFragment.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitWebViewFragment.java index 203d5b388e..73d928234f 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitWebViewFragment.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitWebViewFragment.java @@ -64,8 +64,9 @@ public void onPageLoadError(WebView view, int errorCode, String description, Str @Override @TargetApi(Build.VERSION_CODES.M) - public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { - if (request.getUrl().toString().equals(view.getUrl())) { + public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, + boolean isMainRequestFailure) { + if (isMainRequestFailure) { ViewPagerDownloadManager.instance.done(CourseUnitWebViewFragment.this, false); } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/custom/URLInterceptorWebViewClient.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/custom/URLInterceptorWebViewClient.java index 8b9536dd12..8f0dc7ed4d 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/custom/URLInterceptorWebViewClient.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/custom/URLInterceptorWebViewClient.java @@ -129,10 +129,12 @@ public void onReceivedError(WebView view, int errorCode, String description, Str } @Override + @TargetApi(Build.VERSION_CODES.M) public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { super.onReceivedHttpError(view, request, errorResponse); if (pageStatusListener != null) { - pageStatusListener.onPageLoadError(view, request, errorResponse); + pageStatusListener.onPageLoadError(view, request, errorResponse, + request.getUrl().toString().equals(view.getUrl())); } } @@ -295,7 +297,8 @@ public interface IPageStatusListener { /** * Callback that indicates error during page load. */ - void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse); + void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, + boolean isMainRequestFailure); /** * Callback that indicates that the page is 50 percent loaded. diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/dialog/WebViewActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/dialog/WebViewActivity.java index d217d5a0f8..425de5305b 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/dialog/WebViewActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/dialog/WebViewActivity.java @@ -58,8 +58,11 @@ public void onPageLoadError(WebView view, int errorCode, String description, Str } @Override - public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { - progress.setVisibility(View.GONE); + public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, + boolean isMainRequestFailure) { + if (isMainRequestFailure) { + progress.setVisibility(View.GONE); + } } @Override