I want to display a snackBar when my token becomes invalid. The snackbar will have an action attached to "Refresh" the token.
SnackBar outerSnackBar;
outerSnackBar = Snackbar.make(coordinatorLayout,
"Your request is unauthorized. Please refresh your token",
Snackbar.LENGTH_INDEFINITE).setAction("Refresh"), new View.OnClickListener() {
@Override
public void onClick(View v) {
outerSnackBar.setAction("", null);
outerSnackBar.setText("Refreshing");
outerSnackBar.show();
}
}).show();
When I click on the snackBar's "Refresh" action button, I want the existing snackBar's text to change to "Refreshing" and the action to display hence this is the code that I have written in the onClickListener.
However, when I click on the "Refresh" action button, the snackbar just dismisses itself.
Is there anyway to modify the text and action of an existing snackbar?