Java 类android.databinding.Observable.OnPropertyChangedCallback 实例源码

项目:okuki    文件:RxObservableField.java   
public static <T> Observable<T> toObservable(@NonNull final ObservableField<T> field) {

        return Observable.create(e -> {
            T initialValue = field.get();
            if (initialValue != null) {
                e.onNext(initialValue);
            }
            final OnPropertyChangedCallback callback = new OnPropertyChangedCallback() {
                @Override
                public void onPropertyChanged(android.databinding.Observable observable, int i) {
                    e.onNext(field.get());
                }
            };
            field.addOnPropertyChangedCallback(callback);
            e.setCancellable(() -> field.removeOnPropertyChangedCallback(callback));
        });
    }
项目:Muse-EEG-Toolkit    文件:EpochSurfaceView.java   
public void setEpochCollector(EpochCollector collector) {
  this.collector = collector;
  this.collector.addOnPropertyChangedCallback(new OnPropertyChangedCallback() {
      @Override public void onPropertyChanged(Observable sender, int propertyId) {
        EpochSurfaceView.this.invalidate();
      }
    }
  );
}