Reputation: 1
i have swipe refresh that refresh my webview content, and i have 1 issue sometimes i don't need for refreshing for exaple when my location is /test or /norefresh, and how i can exclude swipe refresh by my condition (when location have some url's) ?
//swipe refresh
swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
swipeLayout.setColorSchemeResources(R.color.colorPrimary);
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mywebview.reload();
}
});
Upvotes: 0
Views: 355
Reputation: 16214
I recommend you to use the method setEnabled()
on SwipeRefreshLayout
.
The logic to detect page change is different if you use WebViewClient
or WebChromeClient
.
For WebViewClient
for example:
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
swipeLayout.setEnabled(!url.contains("/test") && !url.contains("norefresh/"));
return super.shouldOverrideUrlLoading(view, url);
}
});
Upvotes: 1