<<<<<<< HEAD <<<<<<< HEAD #Use androidannotations to MVP ###Declare a Interface of View
public interface MyView{
public void showName(String name);
}
###Declare bean interface
public interface IMyBean{
public void getUserName();
}
###Implement bean
@EBean
public MyBean implements IMyBean{
@ViewInterface //New Annotation
MyView myView;
@Override
@Background //Use AA to run background
public void getUserName(){
//read user from db or Http server or other
myView.showName("hello");
}
}
###In Activity,Fragment,Service or only a common Class
@EActivity(R.layout.layout_main)
public MyActivity{
@Bean(MyBean.class)
IMyBean myBean;
@Click(R.id.btn)
public void click(){
//Call myBean, excuted in background
myBean.getUserName();
}
//MyBean will invoke this in method getUserName, so need to be UIThread safe
@UIThread
public void showName(String nam
8E41
e){
showToast(name);
}
}
#EIntent,IntentExtra
@EIntent("BroadcastAction-XX")
public class MyIntent{
@IntentExtra
public String name;
@IntentExtra(IntentObjectType.PARCELABLE)
public UserInfo userInfo;
@IntentExtra
public SerializableObject obj;
}
###sendBroadCast
sendBroadCast(new MyIntent_().setName("name").setUserInfo(userInfo).getIntent());
###receive broadcast
MyIntent_ myIntent=MyIntent_.build(intent);
myIntent.getName()
#ContextEvent ###Write a event interface
public interface IMyEvent{
public void onEvent1(String action);
}
###In Fragment,Adapter,View..
@ContextEvent
IMyEvent myEvent;
.............
myEvent.onEvent1("action");
###In activity
//Not necessary,but recommend implements IMyEvent
implements IMyEvent
public void onEvent1(String action){
//do something
}
=======
Note: we presented AndroidAnnotations at Devoxx 2012, video available on Parleys.com!
AndroidAnnotations is an Open Source framework that speeds up Android development. It takes care of the plumbing, and lets you concentrate on what's really important. By simplifying your code, it facilitates its maintenance.
dd05c0576d7b8da39d46c5589ee672f2d2c6c556 =======
96090578b57011fab18dcfe714da38bca2899feb
