Это, вероятно, не лучший ответ, который вы найдете, но он выполняет свою работу ..
Поскольку мы не используем двухстороннюю привязку данных, я прослушал onClick кнопки отправки вMainActivity, где я изменяю переменную NoteBinderhelper
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
final NoteBinderhelper noteBinderhelper = new NoteBinderhelper();
mainBinding.setHelper(noteBinderhelper);
mainBinding.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String textOne = mainBinding.editText1.getText().toString();
String textTwo = mainBinding.editText2.getText().toString();
if(textOne.isEmpty() || textTwo.isEmpty()){
noteBinderhelper.setPresentationNoteViewVisible(false);
} else {
noteBinderhelper.setPresentationNoteViewVisible(true);
}
mainBinding.setHelper(noteBinderhelper);
}
});
}
Сделано небольшое изменение в классе NoteBinderHelper
public class NoteBinderhelper extends BaseObservable {
private Boolean presentation_note;
private Boolean timerElementsVisible;
public NoteBinderhelper(){
this.presentation_note = true;
this.timerElementsVisible = false;
}
public void setPresentationNoteViewVisible(boolean presentationElementsVisible) {
this.presentation_note = presentationElementsVisible;
notifyPropertyChanged(BR.presentation_note);
}
@Bindable
public Boolean getPresentation_note() {
return presentation_note;
}
}
И я изменил видимость textView на
android:visibility="@{helper.presentation_note ? View.VISIBLE : View.GONE}"