/** * unbind all property callbacks. */ public void unbindAll(){ unbindAll(false); } /**
/** * bind background drawable of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindBackground(String property) { mBinder.bindBackground(property, mView); return this; } /**
/** * bind background color of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindBackgroundColor(String property) { mBinder.bindBackgroundColor(property, mView); return this; } /**
@Override protected void onInit(Context context, Bundle savedInstanceState) { Binder<TestSelfMethod> binder = DataMediatorFactory.createBinder(TestSelfMethod.class); //bind property to textView binder.bindText(TestSelfMethod.PROP_text, mTv); //get proxy mProxy = binder.getDataProxy(); }
@Override protected void onInit(Context context, Bundle savedInstanceState) { initResource(context); mUserDrawable1 = true; mUserRes1 = true; mUserColor1 = true; binder = DataMediatorFactory.createBinder(ViewBind.class); //初始化属性。 binder.getDataProxy() .setBackground(mDrawable1) .setBackgroundColor(mColor1) .setBackgroundRes(mResId1) .setEnable(true); // 设置属性拦截器,用于应用绑定的时候过滤一些不需要的属性值。 binder.setPropertyInterceptor(PropertyInterceptor.NULL_AND_ZERO); //绑定并 首次应用属性(绑定只需要1次) binder .bindBackground(ViewBind.PROP_background, mV_bg) //使用生成的property对象。有助于模型变化后用的地方知晓改变。 .bindBackgroundRes(ViewBind.PROP_backgroundRes, mV_bg_res) .bindBackgroundColor(ViewBind.PROP_backgroundColor, mV_bg_color) .bindEnable("enable", mV_enable) .applyProperties( // 创建一个只接收固定属性的 拦截器。(1.1.2支持的). 只是用于本次apply. PropertyInterceptor.createFilter(ViewBind.PROP_background, ViewBind.PROP_backgroundRes, ViewBind.PROP_backgroundColor) ); }
/** * bind data to the all defined bind views. and apply it immediately. * * @param data the module data * @param index the index * @param interceptor the property interceptor * @param <D> the module data type * @return the binder */ public <D> Binder<D> bindAndApply(D data, int index, PropertyInterceptor interceptor) { Binder<D> binder = bind(data, index, null, interceptor); binder.applyProperties(); return binder; }
binder.setPropertyInterceptor(interceptor);
/** * bind enable of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindEnable(String property) { mBinder.bindEnable(property, mView); return this; } /**
/** * bind background resource of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindBackgroundRes(String property) { mBinder.bindBackgroundRes(property, mView); return this; } /**
/** * bind text of Text view. * @param property the property * @return this. */ public BatchTextViewBinder<T> bindText(String property){ mBinder.bindText(property, mView); return this; } /**
@Override protected void onBindListItems(Binder<RecyclerListBind> mBinder) { //默认方式 (需要现在RecyclerView 上设置adapter) mBinder.bindRecyclerList(RecyclerListBind.PROP_students, mRv); }
protected void onBindListItems(Binder<RecyclerListBind> mBinder) { //通用的绑定方法. 这里用于绑定列表 mBinder.bindList(RecyclerListBind.PROP_students, mAdapter); }
/** * bind data to the all defined bind views. and apply it immediately. * * @param data the module data * @param index the index * @param interceptor the property interceptor * @param <D> the module data type * @return the binder */ public <D> Binder<D> bindAndApply(D data, int index, PropertyInterceptor interceptor) { Binder<D> binder = bind(data, index, null, interceptor); binder.applyProperties(); return binder; }
binder.setPropertyInterceptor(interceptor);
/** * bind enable of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindEnable(String property) { mBinder.bindEnable(property, mView); return this; } /**
/** * bind background resource of view. * * @param property the property * @return this. */ public BatchViewBinder<T> bindBackgroundRes(String property) { mBinder.bindBackgroundRes(property, mView); return this; } /**
/** * bind text of Text view. * @param property the property * @return this. */ public BatchTextViewBinder<T> bindText(String property){ mBinder.bindText(property, mView); return this; } /**
/** * <p>Recommend you use {@linkplain #bindList(Property, BaseListPropertyCallback.IItemManager)} instead.</p> * bind list of recycler view. * @param property the property of data * @param recyclerView the recycler view. eg: android.support.v7.widget.RecyclerView on android platform * @return this. * @since 1.1.2 */ @java.lang.Deprecated public final Binder<T> bindRecyclerList(Property property, Object recyclerView){ return bindRecyclerList(property.getName(), recyclerView); } /**
/** * <p>Recommend you use {@linkplain #bindList(Property, BaseListPropertyCallback.IItemManager)} instead.</p> * bind list of view. * @param property the property of data * @param listView the list view. eg: android.widget.ListView on android platform * @return this. * @since 1.1.2 */ @java.lang.Deprecated public final Binder<T> bindList(Property property, Object listView){ return bindList(property.getName(), listView); }
public <D> Binder<D> bindAndApply(D data, int index, PropertyInterceptor interceptor) { Binder<D> binder = bind(data, index, interceptor); binder.applyProperties(); return binder; }