Java 类android.databinding.InverseBindingListener 实例源码

项目:Android-MVVMFramework    文件:BindingConfig.java   
@BindingAdapter(value = {"onRefreshListener", "refreshingAttrChanged"}, requireAll = false)
public static void setOnRefreshListener(final SwipeRefreshLayout view,
                                        final SwipeRefreshLayout.OnRefreshListener listener,
                                        final InverseBindingListener refreshingAttrChanged) {

    SwipeRefreshLayout.OnRefreshListener newValue = new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (listener != null) {
                if (refreshingAttrChanged != null) {
                    refreshingAttrChanged.onChange();
                }
                listener.onRefresh();
            }
        }
    };

    SwipeRefreshLayout.OnRefreshListener oldValue = ListenerUtil.trackListener(view, newValue, R.id.onRefreshListener);
    if (oldValue != null) {
        view.setOnRefreshListener(null);
    }
    view.setOnRefreshListener(newValue);
}
项目:Android-MVVMFramework    文件:BindingConfig.java   
@BindingAdapter(value = {"onRefreshListener", "refreshingAttrChanged"}, requireAll = false)
public static void setOnRefreshListener(final SwipeRefreshLayout view,
                                        final SwipeRefreshLayout.OnRefreshListener listener,
                                        final InverseBindingListener refreshingAttrChanged) {

    SwipeRefreshLayout.OnRefreshListener newValue = new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if (listener != null) {
                if (refreshingAttrChanged != null) {
                    refreshingAttrChanged.onChange();
                }
                listener.onRefresh();
            }
        }
    };

    SwipeRefreshLayout.OnRefreshListener oldValue = ListenerUtil.trackListener(view, newValue, R.id.onRefreshListener);
    if (oldValue != null) {
        view.setOnRefreshListener(null);
    }
    view.setOnRefreshListener(newValue);
}
项目:spline    文件:HuePickerBindingAdapters.java   
/**
 * This is how you implement 2-way data binding of a custom attribute if you want to maintain
 * a custom listener interface - OnHueChangeListener, in this case - while also leveraging
 * the synthetic attributes hueAttrChanged (the InverseBindingListener). For an example of
 * how to implement custom 2-way binding with just the synthetic AttrChanged attribute's
 * InverseBindingListener, see DocumentView or LayerListView's currentLayer 2-way binding
 * (along with the InverseBindingMethod declarations in DocumentViewModelBindingAdapters).
 *
 * @param view                   The view we're 2-way binding to.
 * @param onHueChangeListener    The OnHueChangeListener bound by the developer on the view
 *                               in question.
 * @param inverseBindingListener Synthetic attribute representing an InverseBindingListener
 *                               for changes to the hue attribute.
 */
@BindingAdapter(value = {"onHueChange", "hueAttrChanged"}, requireAll = false)
public static void setListeners(HuePicker view,
                                final HuePicker.OnHueChangeListener onHueChangeListener,
                                final InverseBindingListener inverseBindingListener) {
    HuePicker.OnHueChangeListener newListener;
    if (inverseBindingListener == null) {
        // If the synthetic listener param is null, just keep track of the listener set in
        // the binding
        newListener = onHueChangeListener;
    } else {
        // Otherwise define a new listener to wraps both listeners and invoke them at the
        // right time within the new listener if they are non-null
        newListener = new HuePicker.OnHueChangeListener() {
            @Override
            public void onHueChange(HuePicker huePicker, float hue) {
                if (onHueChangeListener != null) {
                    onHueChangeListener.onHueChange(huePicker, hue);
                }
                inverseBindingListener.onChange();
            }
        };
    }

    // Use track listener to record listener we're adding and return any old listeners
    // registered through this method so that on rebind we don't add duplicate listeners
    HuePicker.OnHueChangeListener oldListener = ListenerUtil.trackListener(view, newListener,
            R.id.hueChangeListener);

    // Remove the old listener we set using this BindingAdapter, if there is one
    if (oldListener != null) {
        view.removeHueChangeListener(oldListener);
    }

    // Add our new listener
    if (newListener != null) {
        view.addHueChangeListener(newListener);
    }
}
项目:spline    文件:LayerListView.java   
public void setCurrentLayerAttrChanged(InverseBindingListener listener) {
    mAdapter.setCurrentLayerAttrChanged(listener);
}
项目:spline    文件:DocumentView.java   
public void setCurrentLayerAttrChanged(InverseBindingListener listener) {
    mCurrentLayerAttrChangedListener = listener;
}
项目:spline    文件:DocumentView.java   
public void setViewportXAttrChanged(InverseBindingListener listener) {
    mViewportXAttrChangedListener = listener;
}
项目:spline    文件:DocumentView.java   
public void setViewportYAttrChanged(InverseBindingListener listener) {
    mViewportYAttrChangedListener = listener;
}
项目:spline    文件:DocumentView.java   
public void setViewportWidthAttrChanged(InverseBindingListener listener) {
    mViewportWidthAttrChangedListener = listener;
}
项目:spline    文件:DocumentView.java   
public void setViewportHeightAttrChanged(InverseBindingListener listener) {
    mViewportHeightAttrChangedListener = listener;
}
项目:spline    文件:SaturationValuePicker.java   
public void setSaturationAttrChanged(InverseBindingListener listener) {
    mSaturationAttrChangedListener = listener;
}
项目:spline    文件:SaturationValuePicker.java   
public void setValueAttrChanged(InverseBindingListener listener) {
    mValueAttrChangedListener = listener;
}
项目:spline    文件:RulerView.java   
public void setViewportStartAttrChanged(InverseBindingListener listener) {
    mViewportStartAttrChangedListener = listener;
}
项目:spline    文件:RulerView.java   
public void setHighlightStartAttrChanged(InverseBindingListener listener) {
    mHighlightStartAttrChangedListener = listener;
}
项目:spline    文件:LayerListAdapter.java   
public void setCurrentLayerAttrChanged(InverseBindingListener currentLayerAttrChanged) {
    mCurrentLayerAttrChangedListener = currentLayerAttrChanged;
}