Hello, I'm developing a project for my site, and until then it's getting really cool. But I had a problem and it is as follows, whenever the page of error I called the Snackbar feature, it looks like this:
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Snackbar snackbar = Snackbar.make(snackbarCoordinatorLayout, "ERRO NA CONEXÃO", Snackbar.LENGTH_INDEFINITE);
snackbar.setAction("Atualizar", new View.OnClickListener() {
@Override
public void onClick(View v) {
webView.reload();
}
});
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.RED);
snackbar.show();
}
Until then, okay, the page when the error is the feature is shown, when the user selects "Refresh" and the page continues giving error the feature continues persisting ... But I do not want to leave the original error page , so I created a page in html and called along with Snackbar, thus:
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
webView.loadUrl("file:///android_asset/error.html");
Snackbar snackbar = Snackbar.make(snackbarCoordinatorLayout, "ERRO NA CONEXÃO", Snackbar.LENGTH_INDEFINITE);
snackbar.setAction("Atualizar", new View.OnClickListener() {
@Override
public void onClick(View v) {
webView.reload();
}
});
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.RED);
snackbar.show();
}
But this time the problem comes up, I call this "custom error page" the Snackbar feature appears only once, ie only for the first time the error page, hence when the user selects "Update" the page giving error again it does not appear anymore. That is, this error page is messing up something, can you help me? How do I make both works, and the feature works without problem.