JExpr._new(m.directClass(org.joda.time.LocalDateTime.class.getCanonicalName())).arg(tsVar)); jc._else().assign(returnValueHolder.ref("value"), localDateTimeVar.invoke("toDateTime") .arg(m.directClass(org.joda.time.DateTimeZone.class.getCanonicalName()).staticRef("UTC")).invoke("getMillis")); return block;
private JInvocation inflateView(JVar inflaterParam, JVar containerParam) { // inflater.inflate(R.layout.fragment_sample, container, false); return JExpr.invoke(inflaterParam, "inflate").arg(ref.r().staticRef("layout").ref("fragment_sample")).// arg(containerParam). // arg(JExpr.FALSE); }
public void doFindViewById(JBlock afterViewsBody, String id, JFieldVar field, JVar contentViewVar) { JFieldRef rId = ref.r().staticRef("id").ref(id); JInvocation findViewById = JExpr.invoke(contentViewVar, "findViewById").arg(rId); JExpression findViewByIdCasted = JExpr.cast(field.type(), findViewById); afterViewsBody.assign(field, findViewByIdCasted); }
private void createAndInitLocationsField() { // private String[] locations; locationsField = jClass.field(JMod.PRIVATE, ref.string().array(), "locations"); // locations = getResources().getStringArray(R.array.locations); JFieldRef rArrayLocations = ref.r().staticRef("array").ref("locations"); JInvocation getResources = JExpr.invoke("getResources"); JInvocation getStringArray = getResources.invoke("getStringArray").arg(rArrayLocations); afterViewsBody.assign(locationsField, getStringArray); }
public void doViewById(JBlock body, String id, JFieldVar field) { if (state.isAndroidAnnotations()) { field.annotate(ref.viewById()); } else if (state.isRoboguice()) { JAnnotationUse injectViewAnnotation = field.annotate(ref.injectView()); JFieldRef rId = ref.r().staticRef("id").ref(id); injectViewAnnotation.param("value", rId); } else { doFindViewById(body, id, field); } }
private void createOnCreateOptionsMenu() { JMethod onCreateOptionsMenu = null; JClass menu = !appDetails.isActionBarSherlock() ? ref.menu() : ref.sMenu(); onCreateOptionsMenu = jClass.method(JMod.PUBLIC, jCodeModel.BOOLEAN, "onCreateOptionsMenu"); JVar menuVar = onCreateOptionsMenu.param(menu, "menu"); onCreateOptionsMenu.annotate(ref.override()); JBlock onCreateOptionsMenuBody = onCreateOptionsMenu.body(); String getMenuInflater = appDetails.isActionBarSherlock() ? "getSupportMenuInflater" : "getMenuInflater"; JFieldRef rMenuMain = ref.r().staticRef("menu").ref("activity_main"); onCreateOptionsMenuBody.invoke(getMenuInflater).// invoke("inflate"). // arg(rMenuMain). // arg(menuVar); onCreateOptionsMenuBody._return(TRUE); }
private JFieldRef extractIdStaticRef(EBeanHolder holder, String staticFieldQualifiedName) { if (staticFieldQualifiedName != null) { int fieldSuffix = staticFieldQualifiedName.lastIndexOf('.'); String fieldName = staticFieldQualifiedName.substring(fieldSuffix + 1); String className = staticFieldQualifiedName.substring(0, fieldSuffix); return holder.refClass(className).staticRef(fieldName); } else { return null; } }
private JBlock createAfterViewsMethod() { JBlock afterViewsBody; if (!appDetails.isAndroidAnnotations()) { JMethod onCreate = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "onCreate"); onCreate.annotate(ref.override()); JVar params = onCreate.param(ref.bundle(), "savedInstanceState"); afterViewsBody = onCreate.body(); // super.onCreate() afterViewsBody.invoke(JExpr._super(), "onCreate").arg(params); // setContentView(R.layout.xxx) afterViewsBody.invoke("setContentView").arg(ref.r().staticRef("layout").ref(appDetails.getActivityLayout())); } else { JMethod afterViews = jClass.method(JMod.NONE, jCodeModel.VOID, "afterViews"); afterViews.annotate(ref.afterViews()); afterViewsBody = afterViews.body(); } return afterViewsBody; }
JVar contextVar = configureActionBarBody.decl(ref.context(), "context", getContext); JFieldRef rArrayLocations = ref.r().staticRef("array").ref("locations"); JVar listVar = configureActionBarBody.decl(listType, "list", createFromResource); JFieldRef navigationModeList = ref.sActionBar().staticRef("NAVIGATION_MODE_LIST"); configureActionBarBody.invoke(getSupportActionbar, "setNavigationMode").arg(navigationModeList); configureActionBarBody.invoke(getSupportActionbar, "setListNavigationCallbacks").//
public JExpression createConstant(Outline outline, XmlString literal) { // correctly identifying which constant it maps to is hard, so // here I'm cheating JClass type = toType(outline,Aspect.EXPOSED); for (CEnumConstant mem : members) { if(mem.getLexicalValue().equals(literal.value)) return type.staticRef(mem.getName()); } return null; }
public JExpression createConstant(Outline outline, XmlString literal) { // correctly identifying which constant it maps to is hard, so // here I'm cheating JClass type = toType(outline,Aspect.EXPOSED); for (CEnumConstant mem : members) { if(mem.getLexicalValue().equals(literal.value)) return type.staticRef(mem.getName()); } return null; }
public JExpression createConstant(Outline outline, XmlString literal) { // correctly identifying which constant it maps to is hard, so // here I'm cheating JClass type = toType(outline,Aspect.EXPOSED); for (CEnumConstant mem : members) { if(mem.getLexicalValue().equals(literal.value)) return type.staticRef(mem.getName()); } return null; }
private void createActivity() { JClass parentActivity; if (appDetails.isRoboguice() && appDetails.isActionBarSherlock()) { if (appDetails.isViewPager()) { parentActivity = ref.ref(appDetails.getRoboSherlockFragmentActivityPackage()); } else { parentActivity = ref.ref(appDetails.getRoboSherlockActivityPackage()); } } else if (appDetails.isActionBarSherlock()) { parentActivity = appDetails.isViewPager() ? ref.sFragmentActivity() : ref.sActivity(); } else if (appDetails.isRoboguice()) { parentActivity = appDetails.isViewPager() ? ref.roboFragmentActivity() : ref.roboActivity(); } else { parentActivity = appDetails.isViewPager() ? ref.fragmentActivity() : ref.activity(); } jClass._extends(parentActivity); // @EActivity if (appDetails.isAndroidAnnotations()) { JAnnotationUse eactivityAnnotation = jClass.annotate(ref.eactivity()); JFieldRef field = ref.r().staticRef("layout").ref(appDetails.getActivityLayout()); eactivityAnnotation.param("value", field); } }
public JExpression dotclass(Type type) { Class clazz = toClass(type); if (clazz.isPrimitive()) { return toJType(clazz).boxify().staticRef("TYPE"); } return toJClass(clazz).dotclass(); } }
public JAnnotationArrayMember visit(XEnumByNameAnnotationValue<?> value) { final JClass type = (JClass) CodeModelUtils.ref(this.codeModel, value.getEnumClassName()); return annotationArrayMember.param(type.staticRef(value.getName())); }
JFieldRef navigationModeList = ref.sActionBar().staticRef("NAVIGATION_MODE_TABS"); configureActionBarBody.invoke(getSupportActionBar, "setNavigationMode").arg(navigationModeList);
private Refs(JCodeModel m, String packageName, String layoutName) { this.m = m; this.packageName = packageName; this.layoutName = layoutName; viewHolder = m.ref("me.tatarka.socket.Socket"); viewClass = m.ref("android.view.View"); androidRClass = m.ref("android.R"); rClass = m.ref(packageName + ".R"); layoutRef = rClass.staticRef("layout").ref(layoutName); }
@Override public void process(Element element, JCodeModel codeModel, EBeanHolder holder) { JFieldRef fullScreen = holder.classes().WINDOW_MANAGER_LAYOUT_PARAMS.staticRef("FLAG_FULLSCREEN"); JInvocation arg = invoke(invoke("getWindow"), "setFlags").arg(fullScreen).arg(fullScreen); holder.init.body().add(arg); }