use of org.androidannotations.helper.AnnotationHelper 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 org.androidannotations.helper.AnnotationHelper in project androidannotations by androidannotations.
the class EActivityHolder method setGetLastNonConfigurationInstance.
private void setGetLastNonConfigurationInstance() throws JClassAlreadyExistsException {
AnnotationHelper annotationHelper = new AnnotationHelper(getEnvironment());
TypeElement fragmentActivityTypeElement = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.FRAGMENT_ACTIVITY);
TypeElement typeElement = annotationHelper.typeElementFromQualifiedName(generatedClass._extends().fullName());
String getLastNonConfigurationInstanceName = "getLastNonConfigurationInstance";
if (fragmentActivityTypeElement != null && annotationHelper.isSubtype(typeElement.asType(), fragmentActivityTypeElement.asType())) {
getLastNonConfigurationInstanceName = "getLastCustomNonConfigurationInstance";
}
NonConfigurationHolder ncHolder = getNonConfigurationHolder();
JDefinedClass ncHolderClass = ncHolder.getGeneratedClass();
JFieldVar superNonConfigurationInstanceField = ncHolder.getSuperNonConfigurationInstanceField();
getLastNonConfigurationInstance = generatedClass.method(PUBLIC, Object.class, getLastNonConfigurationInstanceName);
getLastNonConfigurationInstance.annotate(Override.class);
JBlock body = getLastNonConfigurationInstance.body();
JVar nonConfigurationInstance = body.decl(ncHolderClass, "nonConfigurationInstance", cast(ncHolderClass, _super().invoke(getLastNonConfigurationInstance)));
body._if(nonConfigurationInstance.eq(_null()))._then()._return(_null());
body._return(nonConfigurationInstance.ref(superNonConfigurationInstanceField));
}
Aggregations