-
Notifications
You must be signed in to change notification settings - Fork 7
Property change demo
LightSun edited this page Sep 18, 2017
·
2 revisions
comes from TestPropertyChangeActivity
public class TestPropertyChangeActivity extends BaseActivity {
@BindView(R.id.tv_desc)
TextView mTv_desc;
@BindView(R.id.bt_set_text_on_TextView)
Button mBt_changeProperty;
@BindView(R.id.bt_set_text_on_mediator)
Button mBt_temp;
DataMediator<StudentModule> mMediator;
@Override
protected int getLayoutId() {
return R.layout.ac_test_double_bind;
}
@Override
protected void onInit(Context context, Bundle savedInstanceState) {
mBt_changeProperty.setText("click this to change property");
mBt_temp.setVisibility(View.GONE);
//为数据模型创建 中介者。
mMediator = DataMediatorFactory.createDataMediator(StudentModule.class);
//添加属性callback
mMediator.addDataMediatorCallback(new DataMediatorCallback<StudentModule>() {
@Override
public void onPropertyValueChanged(StudentModule data, Property prop, Object oldValue, Object newValue) {
Logger.w("TestPropertyChangeActivity","onPropertyValueChanged","prop = "
+ prop.getName() + " ,oldValue = " + oldValue + " ,newValue = " + newValue);
mTv_desc.setText(String.valueOf(newValue));
}
});
mMediator.getDataProxy().setName("heaven7");
}
@OnClick(R.id.bt_set_text_on_TextView)
public void onClickSetTextOnTextView(View v){
mMediator.getDataProxy().setName("time: " + System.currentTimeMillis());
}
}