11. DI
public class DemoModule extends GModule {
public DemoModule(GContext context) {
super(context);
}
@Override
protected void configure() {
configure_context();
bind(DemoContext.class).toInstance((DemoContext)gcontext);
bind(GErrorModel.class).to(DemoErrorModel.class).in
(Singleton.class);
bind(GModel.class).to(DemoModel.class).in(Singleton.class);
bind(GAgent.class).to(DemoAgent.class).in(Singleton.class);
bind(GController.class).to(DemoController.class);
bind(IDemoRestDriver.class).to(DemoG3Driver.class);
}
}
12. DI
public class CustomerRestViewActivity extends
GActivity<DemoController> {
@LayoutView(R.id.header)
TextView mHeader;
@ResourceString(R.string.header)
String mHeaderLabel;
@ResourceColor(R.color.header)
Color mHeaderColor;
@IntentExtra("message")
String mMessage;
public CustomerRestViewActivity() {
addTrait(new ListViewTrait());
}
…
13. • Scala⾔言
• Java
• (Scala)
class MyListActivity extends Activity with ListViewer
class MyMapActivity extends MapActivity with
MyLocationOverlayViewer