You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Fields({
@Field(propName = "test_self1"),
@Field(propName = "test_self2", type = int.class)
})
@ImplClass(TestUtil.class) //define the source impl class of self method publicinterfaceTestSelfMethod1extendsDataPools.Poolable {
//define a constant field. add annotation @Keep for not effect by idea-plugin(Data-mediator generator)@KeepintSTATE_OK = 1;
PropertyPROP_test_self1 = SharedProperties.get("java.lang.String", "test_self1", 0);
PropertyPROP_test_self2 = SharedProperties.get("int", "test_self2", 0);
StringgetTest_self1();
TestSelfMethod1setTest_self1(Stringtest_self11);
intgetTest_self2();
TestSelfMethod1setTest_self2(inttest_self21);
@ImplMethod("getStudentId")
intgetId(Studentstu, intkey);
//not assigned method name of ImplClass. so use the same name.@ImplMethodvoidparseStudent(Studentstu, intkey);
}
publicclassTestUtil {
//compare to 'int getId(Student stu, int key)', only add a first param of module.publicstaticintgetStudentId(TestSelfMethod1tsf, Studentstu, intkey){
//do something you want.return0;
}
publicstaticvoidparseStudent(TestSelfMethod1tsf, Studentstu, intkey){
//do something you want.
}
}
Android sample of self method/impl self interface
//data module definepublicinterfaceTestSelfMethodextendsTestSelfMethodWithImplInterface.TextDelegate, DataPools.Poolable {
PropertyPROP_text = SharedProperties.get("java.lang.String", "text", 0);
@Keep@ImplMethod(from = HelpUtil.class)
voidchangeText(Stringtext);
TestSelfMethodsetText(Stringtext1);
StringgetText();
classHelpUtil {
//compare to ' void changeText(String text);' , just add a module param at the first.publicstaticvoidchangeText(TestSelfMethodmodule, Stringtext) {
//just mock text change.//module can be real data or data proxy, if is proxy it will auto dispatch text change= event.module.setText(text);
}
}
}
//sample activitypublicclassTestSelfMethodWithImplInterfaceextendsBaseActivity {
@BindView(R.id.textView)
TextViewmTv;
privateTestSelfMethodmProxy;
@OverrideprotectedintgetLayoutId() {
returnR.layout.ac_self_methods;
}
@OverrideprotectedvoidonInit(Contextcontext, BundlesavedInstanceState) {
Binder<TestSelfMethod> binder = DataMediatorFactory.createBinder(TestSelfMethod.class);
//bind property to textViewbinder.bindText(TestSelfMethod.PROP_text, mTv);
//get proxymProxy = binder.getDataProxy();
}
@OnClick(R.id.button)
publicvoidonClickCallSelf(Viewview){
//call self methodmProxy.changeText("text changed: " + System.currentTimeMillis());
}
publicinterfaceTextDelegate{
voidchangeText(Stringtext);
}
}