I am trying to dismiss a Snackbar
when a condition is satisfied.
snackbar.setAction("Retry", new View.OnClickListener() {
@Override
public void onClick(View view) {
if(isConnected(getApplicationContext())){
toggleButtonsState(true);
snackbar.dismiss();
} else {
snackbar.show();
}
}
});
snackbar.show();
However, the Snackbar
implementation do automatic dismiss of it when the action is clicked.
public Snackbar setAction(CharSequence text, final OnClickListener listener) {
TextView tv = this.mView.getActionView();
if(!TextUtils.isEmpty(text) && listener != null) {
tv.setVisibility(0);
tv.setText(text);
tv.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
listener.onClick(view);
Snackbar.this.dismiss();
}
});
} else {
tv.setVisibility(8);
tv.setOnClickListener((OnClickListener)null);
}
return this;
}
Generally, is there a way to modify a compiled gradle library so as to cope with my needs. ie. to remove this line Snackbar.this.dismiss();
. I know I can search for the source and put in in libs folder and then I can modify it but is there a way to do so rather than this?