Java Code Examples for androidx.databinding.Observable#OnPropertyChangedCallback

The following examples show how to use androidx.databinding.Observable#OnPropertyChangedCallback . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddEditTaskFragment.java    From simple-stack with Apache License 2.0 5 votes vote down vote up
@Override
public void bindViewModel(AddEditTaskViewModel viewModel) {
    checkNotNull(viewModel);
    if(this.viewModel == viewModel) {
        return;
    }
    this.viewModel = viewModel;
    snackbarCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            SnackbarUtils.showSnackbar(getView(), viewModel.getSnackbarText());
        }
    };
    viewModel.snackbarText.addOnPropertyChangedCallback(snackbarCallback);
}
 
Example 2
Source File: TaskDetailFragment.java    From simple-stack with Apache License 2.0 5 votes vote down vote up
private void setupSnackbar() {
    snackbarCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable observable, int i) {
            SnackbarUtils.showSnackbar(getView(), viewModel.getSnackbarText());
        }
    };
    viewModel.snackbarText.addOnPropertyChangedCallback(snackbarCallback);
}
 
Example 3
Source File: BindingViewItem.java    From recyclerview-adapters with Apache License 2.0 5 votes vote down vote up
public void bindVisible(final ObservableField<Boolean> visibleChangeField) {
    if (visibleChangeField.get() != null) setVisible(visibleChangeField.get());

    releaseVisibleChangeBinding();

    visibleChangeCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            setVisible(visibleChangeField.get(), false);
        }
    };
    visibleChangeField.addOnPropertyChangedCallback(visibleChangeCallback);
    this.visibleChangeField = visibleChangeField;
}
 
Example 4
Source File: DataSourceBindingViewItem.java    From recyclerview-adapters with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
    callback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            notifyDataSetChanged();
        }
    };
    source.addOnPropertyChangedCallback(callback);
}
 
Example 5
Source File: BindingItemAdapter.java    From recyclerview-adapters with Apache License 2.0 5 votes vote down vote up
public void bindVisible(final ObservableField<Boolean> visibleChangeField) {
    if (visibleChangeField.get() != null) setVisible(visibleChangeField.get());

    releaseVisibleChangeBinding();

    visibleChangeCallback = new Observable.OnPropertyChangedCallback() {
        @Override
        public void onPropertyChanged(Observable sender, int propertyId) {
            setVisible(visibleChangeField.get(), false);
        }
    };
    visibleChangeField.addOnPropertyChangedCallback(visibleChangeCallback);
    this.visibleChangeField = visibleChangeField;
}