Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Apply main request check in all web page load error callbacks
Browse files Browse the repository at this point in the history
- LEARNER-1943
  • Loading branch information
farhan authored and miankhalid committed Jul 19, 2017
1 parent 0cd834f commit 0927ed4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0927ed4

Please sign in to comment.