Java 类android.databinding.BaseObservable 实例源码

项目:ui-atoms-android    文件:AtomWatcher.java   
public AtomWatcher(BaseObservable... fields){
    for(BaseObservable field: fields){

        BaseObservable af = field;

        Observable.OnPropertyChangedCallback callback = new Observable.OnPropertyChangedCallback() {
            @Override
            public void onPropertyChanged(Observable sender, int propertyId) {
                run();
            }
        };

        field.addOnPropertyChangedCallback(callback);

        closables.add(new ClosableAction(()->{
            af.removeOnPropertyChangedCallback(callback);
        }));
    }
}
项目:Droidux    文件:StoreClassGenerator.java   
private TypeSpec createTypeSpec() {
    return TypeSpec.classBuilder(storeModel.getClassName().simpleName())
            .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
            .addSuperinterface(storeModel.getInterfaceName())
            .superclass(TypeName.get(BaseObservable.class))
            .addFields(createFieldSpecs())
            .addMethod(createConstructor())
            .addMethod(createBuilderMethodSpec())
            .addMethods(createGetterMethodSpecs())
            .addMethod(createDispatchMethodSpec())
            .addType(new StoreBuilderClassGenerator(storeModel).createBuilderTypeSpec())
            .build();
}
项目:ui-atoms-android    文件:AtomViewModel.java   
public <T> AtomWatcher<T> watch(BaseObservable... fields){
    AtomWatcher<T> watcher = new AtomWatcher<T>(fields);
    register(watcher);
    return watcher;
}
项目:Mvvm    文件:ObservableMessage.java   
public static void unbind(BaseObservable observable, Observable.OnPropertyChangedCallback callback) {
    if (null == observable || null == callback) {
        return;
    }
    observable.removeOnPropertyChangedCallback(callback);
}
项目:Cinder    文件:Cinder.java   
public static <T> CinderArrayList<T> computeArrayList(OnComputeArrayListCallback<T> computeCallback, BaseObservable... observables) {
    CinderArrayList<T> cinderArrayList = new CinderArrayList<>();
    cinderArrayList.setObservableBehaviour(Cinder.observe(() -> computeCallback.onComputeChange(cinderArrayList), observables));
    return cinderArrayList;
}
项目:Cinder    文件:Cinder.java   
public static <K, V> CinderArrayMap<K, V> computeArrayMap(OnComputeArrayMapCallback<K, V> computeCallback, BaseObservable... observables) {
    CinderArrayMap<K, V> cinderArrayMap = new CinderArrayMap<>();
    cinderArrayMap.setObservableBehaviour(Cinder.observe(() -> computeCallback.onComputeChange(cinderArrayMap), observables));
    return cinderArrayMap;
}
项目:Cinder    文件:Cinder.java   
public static CinderBoolean computeBoolean(OnComputeBooleanCallback computeCallback, BaseObservable... observables) {
    CinderBoolean cinderBoolean = new CinderBoolean();
    cinderBoolean.setObservableBehaviour(Cinder.observe(() -> cinderBoolean.set(computeCallback.onComputeChange()), observables));
    return cinderBoolean;
}
项目:Cinder    文件:Cinder.java   
public static CinderByte computeByte(OnComputeByteCallback computeCallback, BaseObservable... observables) {
    CinderByte cinderByte = new CinderByte();
    cinderByte.setObservableBehaviour(Cinder.observe(() -> cinderByte.set(computeCallback.onComputeChange()), observables));
    return cinderByte;
}
项目:Cinder    文件:Cinder.java   
public static CinderChar computeChar(OnComputeCharCallback computeCallback, BaseObservable... observables) {
    CinderChar cinderChar = new CinderChar();
    cinderChar.setObservableBehaviour(Cinder.observe(() -> cinderChar.set(computeCallback.onComputeChange()), observables));
    return cinderChar;
}
项目:Cinder    文件:Cinder.java   
public static CinderDouble computeDouble(OnComputeDoubleCallback computeCallback, BaseObservable... observables) {
    CinderDouble cinderDouble = new CinderDouble();
    cinderDouble.setObservableBehaviour(Cinder.observe(() -> cinderDouble.set(computeCallback.onComputeChange()), observables));
    return cinderDouble;
}
项目:Cinder    文件:Cinder.java   
public static <T> CinderField<T> computeField(OnComputeFieldCallback<T> computeCallback, BaseObservable... observables) {
    CinderField<T> cinderField = new CinderField<>();
    cinderField.setObservableBehaviour(Cinder.observe(() -> cinderField.set(computeCallback.onComputeChange()), observables));
    return cinderField;
}
项目:Cinder    文件:Cinder.java   
public static CinderFloat computeFloat(OnComputeFloatCallback computeCallback, BaseObservable... observables) {
    CinderFloat cinderFloat = new CinderFloat();
    cinderFloat.setObservableBehaviour(Cinder.observe(() -> cinderFloat.set(computeCallback.onComputeChange()), observables));
    return cinderFloat;
}
项目:Cinder    文件:Cinder.java   
public static CinderInt computeInt(OnComputeIntCallback computeCallback, BaseObservable... observables) {
    CinderInt cinderInt = new CinderInt();
    cinderInt.setObservableBehaviour(Cinder.observe(() -> cinderInt.set(computeCallback.onComputeChange()), observables));
    return cinderInt;
}
项目:Cinder    文件:Cinder.java   
public static CinderLong computeLong(OnComputeLongCallback computeCallback, BaseObservable... observables) {
    CinderLong cinderLong = new CinderLong();
    cinderLong.setObservableBehaviour(Cinder.observe(() -> cinderLong.set(computeCallback.onComputeChange()), observables));
    return cinderLong;
}
项目:Cinder    文件:Cinder.java   
public static <T extends Parcelable> CinderParcelable<T> computeParcelable(OnComputeParcelableCallback<T> computeCallback, BaseObservable... observables) {
    CinderParcelable<T> cinderParcelable = new CinderParcelable<>();
    cinderParcelable.setObservableBehaviour(Cinder.observe(() -> cinderParcelable.set(computeCallback.onComputeChange()), observables));
    return cinderParcelable;
}
项目:Cinder    文件:Cinder.java   
public static CinderShort computeShort(OnComputeShortCallback computeCallback, BaseObservable... observables) {
    CinderShort cinderShort = new CinderShort();
    cinderShort.setObservableBehaviour(Cinder.observe(() -> cinderShort.set(computeCallback.onComputeChange()), observables));
    return cinderShort;
}
项目:Cinder    文件:CinderPair.java   
CinderPair(BaseObservable observable,
           Observable.OnPropertyChangedCallback callback){
    this.observable = observable;
    this.callback = callback;
}
项目:Cinder    文件:CinderPair.java   
public BaseObservable getObservable(){
    return this.observable;
}