1
Hi, I’m developing a project for my site, and until then it’s getting really cool. Only I had a little problem and it’s like this, whenever the page gives error I called Feature Snackbar, getting 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 error the Feature is shown, when the user selects "Refresh" and the page continues giving error Feature continues persisting ... Only I don’t want to leave the original error page, so I created an html page and called along with Snackbar, getting like this:
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();
}
Only at this time comes the problem, I calling this "custom error page" the Snackbar Feature appears only once, or it is only for the first time that the error page, then when the user selects "Update" even the page giving error again it no longer appears. I mean, this page of error is getting in the way of something, can you help me? How do I make the two work, and the Feature works without problem.
Peeeeeeeeeerfeito was exactly that friend. MUUITO obliged.
– Tech Positivo