use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EActivityHolder method setFindSupportFragmentByTag.
@Override
protected void setFindSupportFragmentByTag() {
JMethod method = generatedClass.method(PRIVATE, getClasses().SUPPORT_V4_FRAGMENT, "findSupportFragmentByTag");
JVar tagParam = method.param(getClasses().STRING, "tag");
JBlock body = method.body();
body._return(invoke("getSupportFragmentManager").invoke("findFragmentByTag").arg(tagParam));
findSupportFragmentByTag = method;
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class EActivityHolder method setOnRetainNonConfigurationInstance.
private void setOnRetainNonConfigurationInstance() throws JClassAlreadyExistsException {
AnnotationHelper annotationHelper = new AnnotationHelper(getEnvironment());
TypeElement fragmentActivityTypeElement = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.FRAGMENT_ACTIVITY);
TypeElement typeElement = annotationHelper.typeElementFromQualifiedName(generatedClass._extends().fullName());
String onRetainNonConfigurationInstanceName = "onRetainNonConfigurationInstance";
if (fragmentActivityTypeElement != null && annotationHelper.isSubtype(typeElement.asType(), fragmentActivityTypeElement.asType())) {
onRetainNonConfigurationInstanceName = "onRetainCustomNonConfigurationInstance";
}
NonConfigurationHolder ncHolder = getNonConfigurationHolder();
JDefinedClass ncHolderClass = ncHolder.getGeneratedClass();
JMethod onRetainNonConfigurationInstanceMethod = generatedClass.method(PUBLIC, ncHolderClass, onRetainNonConfigurationInstanceName);
onRetainNonConfigurationInstanceMethod.annotate(Override.class);
JBlock methodBody = onRetainNonConfigurationInstanceMethod.body();
onRetainNonConfigurationInstance = methodBody.decl(ncHolderClass, "nonConfigurationInstanceState_", _new(ncHolderClass));
IJExpression superCall = _super().invoke(onRetainNonConfigurationInstanceMethod);
methodBody.assign(onRetainNonConfigurationInstance.ref(ncHolder.getSuperNonConfigurationInstanceField()), superCall);
onRetainNonConfigurationInstanceBindBlock = methodBody.blockSimple();
methodBody._return(onRetainNonConfigurationInstance);
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class RoboGuiceHandler method onNewIntentMethod.
private void onNewIntentMethod(EActivityHolder holder, JFieldVar eventManager) {
JBlock onNewIntentAfterSuperBlock = holder.getOnNewIntentAfterSuperBlock();
fireEvent(eventManager, onNewIntentAfterSuperBlock, getJClass(RoboGuiceClasses.ON_NEW_INTENT_EVENT));
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class RoboGuiceHandler method onConfigurationChangedMethod.
private void onConfigurationChangedMethod(EActivityHolder holder, RoboGuiceHolder roboGuiceHolder, JFieldVar eventManager) {
JVar currentConfig = roboGuiceHolder.getCurrentConfig();
IJExpression newConfig = holder.getOnConfigurationChangedNewConfigParam();
JBlock onConfigurationChangedAfterSuperBlock = holder.getOnConfigurationChangedAfterSuperBlock();
fireEvent(eventManager, onConfigurationChangedAfterSuperBlock, getJClass(RoboGuiceClasses.ON_CONFIGURATION_CHANGED_EVENT), currentConfig, newConfig);
}
use of com.helger.jcodemodel.JBlock in project androidannotations by androidannotations.
the class RoboGuiceHandler method beforeCreateMethod.
private void beforeCreateMethod(EActivityHolder holder, JFieldVar scope, JFieldVar scopedObjects, JFieldVar eventManager) {
JBlock body = holder.getInitBody();
AbstractJClass keyWildCard = getJClass(RoboGuiceClasses.KEY).narrow(getCodeModel().wildcard());
AbstractJClass scopedHashMap = getClasses().HASH_MAP.narrow(keyWildCard, getClasses().OBJECT);
body.assign(scopedObjects, JExpr._new(scopedHashMap));
JVar injector = body.decl(getJClass(RoboGuiceClasses.ROBO_INJECTOR), "injector_", getJClass(RoboGuiceClasses.ROBO_GUICE).staticInvoke("getInjector").arg(_this()));
body.assign(scope, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.CONTEXT_SCOPE).dotclass()));
body.assign(eventManager, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.EVENT_MANAGER).dotclass()));
body.add(injector.invoke("injectMembersWithoutViews").arg(_this()));
fireEvent(eventManager, body, getJClass(RoboGuiceClasses.ON_CREATE_EVENT), holder.getInitSavedInstanceParam());
}
Aggregations