Ejemplo n.º 1
0
  private void setupApplicationProfile(
      ComponentDescriptor applicationDescriptor, ASTType astType, AnalysisContext context) {

    ASTMethod onCreateASTMethod = getASTMethod("onCreate");
    // onCreate
    applicationDescriptor.setInitMethodBuilder(
        OnCreate.class,
        componentBuilderFactory.buildOnCreateMethodBuilder(
            onCreateASTMethod, new NoOpLayoutBuilder()));

    applicationDescriptor.setInjectionNodeFactory(
        componentBuilderFactory.buildInjectionNodeFactory(astType, context));

    // onLowMemory
    applicationDescriptor.addGenerators(buildEventMethod(OnLowMemory.class, "onLowMemory"));
    // onTerminate
    applicationDescriptor.addGenerators(buildEventMethod(OnTerminate.class, "onTerminate"));
    // onConfigurationChanged
    ASTMethod onConfigurationChangedASTMethod =
        getASTMethod("onConfigurationChanged", Configuration.class);
    applicationDescriptor.addGenerators(
        componentBuilderFactory.buildMethodCallbackGenerator(
            OnConfigurationChanged.class,
            componentBuilderFactory.buildMirroredMethodGenerator(
                onConfigurationChangedASTMethod, true)));

    applicationDescriptor.addGenerators(contextScopeComponentBuilder);

    applicationDescriptor.addRegistration(observesExpressionDecorator);
  }
Ejemplo n.º 2
0
  private MethodCallbackGenerator buildEventMethod(
      Class<? extends Annotation> eventAnnotation, String methodName) {
    ASTMethod method = getASTMethod(methodName);

    return componentBuilderFactory.buildMethodCallbackGenerator(
        eventAnnotation, componentBuilderFactory.buildMirroredMethodGenerator(method, true));
  }