New Features
- add new annotations for DataBinding.
@BindAny(value = "prop", method = "bindAddText")
@BindsAny(value = {"prop1", "prop2"}, methods = {"bindAddText1", "bindAddText2"})
TextView mTv_supplier;
@BindTextGravity("gravity")
@BindHighlightColor("highLightColor")
@BindHintText("hintText")
@BindHintTextRes("hintTextRes")
@BindHintTextColor("hintTextColor")
@BindHintTextColorRes("hintTextColorRes")
TextView mTv_hints;
@BindAny(value = "prop", method = "bindAddText")
@BindsAny(value = {"prop1", "prop2"}, methods = {"bindAddText1", "bindAddText2"})
TextView mTv_supplier;
@BindTextGravity("gravity")
@BindHighlightColor("highLightColor")
@BindHintText("hintText")
@BindHintTextRes("hintTextRes")
@BindHintTextColor("hintTextColor")
@BindHintTextColorRes("hintTextColorRes")
TextView mTv_hints;
* actually demo like this.
/**
* 第二种方式: 绑定一组属性到view
* Created by heaven7 on 2017/11/13 0013.
*/
@BindMethodSupplierClass(BindMethodSupplier.DefaultBindMethodSupplier2.class)
public class TestBindArrayPropertyToOneView2 extends BaseActivity {
//bind array properties to a TextView.
//relative to @BindsTextView , @BindsAny has greater freedom(翻译: BindsAny注解有更大的自由度).
// but it must use with @BindMethodSupplierClass.(翻译: 但是他必须搭配注解BindMethodSupplierClass.)
@BindView(R.id.tv)
@BindsAny(value = {"textSizeRes", "textRes"}, //any count you want
methods = {"bindTextSizeRes", "bindTextRes"})
@BindAny(value = "textColorRes", method = "bindTextColorRes") //only one property
TextView mTv;
private ResHelper mHelper = new ResHelper();
private Binder<TextViewBind> mBinder;
@Override
protected int getLayoutId() {
return R.layout.ac_bind_array_prop_to_view;
}
@Override
protected void onInit(Context context, Bundle savedInstanceState) {
mHelper.init(context);
TextViewBind data = DataMediatorFactory.createData(TextViewBind.class);
mBinder = DataMediatorFactory.createDataBinding(this)
.bind(data, 0, PropertyInterceptor.NULL);
}
@OnClick(R.id.bt_text_color)
public void onClickChangeTextColorRes(View v) {
mBinder.getDataProxy().setTextColorRes(mHelper.toggleTextColorRes());
}
@OnClick(R.id.bt_text_size)
public void onClickChangeTextSizeRes(View v) {
mBinder.getDataProxy().setTextSizeRes(mHelper.toggleTextSizeRes());
}
@OnClick(R.id.bt_text)
public void onClickChangeTextRes(View v) {
mBinder.getDataProxy().setTextRes(mHelper.toggleTextRes());
}
}
Release Libs
//changed libs, Note: 'annotationProcessor ' must be replaced with 'apt' if gradle version lower 4.1.
compile 'com.heaven7.java.data.mediator:data-mediator:1.4.3'
annotationProcessor 'com.heaven7.java.data.mediator.compiler:data-mediator-compiler:1.4.3'
compile 'com.heaven7.android.data.mediator:data-mediator-android:1.1.4'
compile 'com.heaven7.java.data.mediator.annotation:data-mediator-annotations:1.2.1'
//not changed libs.
compile 'com.heaven7.java.data.mediator.support.gson:data-mediator-support-gson:1.0.5'