@Test public void testHandleResultActivity() { }
MethodSpec handleResultActivity(NavigableAnnotatedClass value) { TypeName activityTypeName = AndroidSpecificClassProvider.getActivityTypeName(); TypeName intentTypeName = AndroidSpecificClassProvider.getIntentTypeName(); String activityQualifiedName = value.getTypeElement().getQualifiedName().toString(); ArrayTypeName integerArray = ArrayTypeName.of(ClassName.get(Integer.class)); String annotatedClassName = CodeGeneratorHelper.buildMethodName(value.getAnnotatedClassName() + "ForResult", value.getNavigableAnnotation()); MethodSpec.Builder builder = MethodSpec.methodBuilder(annotatedClassName) .addParameter(activityTypeName, "activity", Modifier.FINAL) .addParameter(TypeName.INT, "requestCode", Modifier.FINAL) .addParameter(integerArray, "flags", Modifier.FINAL) .varargs() .addModifiers(Modifier.STATIC, Modifier.PUBLIC) .addStatement("$T intent = new $T(activity, " + activityQualifiedName + ".class)", intentTypeName, intentTypeName) .beginControlFlow("for (Integer flag : flags)") .addStatement("intent.addFlags(flag)") .endControlFlow() .addStatement("activity.startActivityForResult(intent, requestCode)"); return builder.build(); }
NavigatorCodeGenerator { MethodSpec handleResultActivity(NavigableAnnotatedClass value) { TypeName activityTypeName = AndroidSpecificClassProvider.getActivityTypeName(); TypeName intentTypeName = AndroidSpecificClassProvider.getIntentTypeName(); String activityQualifiedName = value.getTypeElement().getQualifiedName().toString(); ArrayTypeName integerArray = ArrayTypeName.of(ClassName.get(Integer.class)); String annotatedClassName = CodeGeneratorHelper.buildMethodName(value.getAnnotatedClassName() + "ForResult", value.getNavigableAnnotation()); MethodSpec.Builder builder = MethodSpec.methodBuilder(annotatedClassName) .addParameter(activityTypeName, "activity", Modifier.FINAL) .addParameter(TypeName.INT, "requestCode", Modifier.FINAL) .addParameter(integerArray, "flags", Modifier.FINAL) .varargs() .addModifiers(Modifier.STATIC, Modifier.PUBLIC) .addStatement("$T intent = new $T(activity, " + activityQualifiedName + ".class)", intentTypeName, intentTypeName) .beginControlFlow("for (Integer flag : flags)") .addStatement("intent.addFlags(flag)") .endControlFlow() .addStatement("activity.startActivityForResult(intent, requestCode)"); return builder.build(); } }
NavigatorCodeGenerator { MethodSpec handleResultActivity(NavigableAnnotatedClass value) { TypeName activityTypeName = AndroidSpecificClassProvider.getActivityTypeName(); TypeName intentTypeName = AndroidSpecificClassProvider.getIntentTypeName(); String activityQualifiedName = value.getTypeElement().getQualifiedName().toString(); ArrayTypeName integerArray = ArrayTypeName.of(ClassName.get(Integer.class)); String annotatedClassName = CodeGeneratorHelper.buildMethodName(value.getAnnotatedClassName() + "ForResult", value.getNavigableAnnotation()); MethodSpec.Builder builder = MethodSpec.methodBuilder(annotatedClassName) .addParameter(activityTypeName, "activity", Modifier.FINAL) .addParameter(TypeName.INT, "requestCode", Modifier.FINAL) .addParameter(integerArray, "flags", Modifier.FINAL) .varargs() .addModifiers(Modifier.STATIC, Modifier.PUBLIC) .addStatement("$T intent = new $T(activity, " + activityQualifiedName + ".class)", intentTypeName, intentTypeName) .beginControlFlow("for (Integer flag : flags)") .addStatement("intent.addFlags(flag)") .endControlFlow() .addStatement("activity.startActivityForResult(intent, requestCode)"); return builder.build(); } NavigatorCodeGenerator(ProcessingEnvironment processingEnv); }
NavigatorCodeGenerator { MethodSpec handleResultActivity(NavigableAnnotatedClass value) { TypeName activityTypeName = AndroidSpecificClassProvider.getActivityTypeName(); TypeName intentTypeName = AndroidSpecificClassProvider.getIntentTypeName(); String activityQualifiedName = value.getTypeElement().getQualifiedName().toString(); ArrayTypeName integerArray = ArrayTypeName.of(ClassName.get(Integer.class)); String annotatedClassName = CodeGeneratorHelper.buildMethodName(value.getAnnotatedClassName() + "ForResult", value.getNavigableAnnotation()); MethodSpec.Builder builder = MethodSpec.methodBuilder(annotatedClassName) .addParameter(activityTypeName, "activity", Modifier.FINAL) .addParameter(TypeName.INT, "requestCode", Modifier.FINAL) .addParameter(integerArray, "flags", Modifier.FINAL) .varargs() .addModifiers(Modifier.STATIC, Modifier.PUBLIC) .addStatement("$T intent = new $T(activity, " + activityQualifiedName + ".class)", intentTypeName, intentTypeName) .beginControlFlow("for (Integer flag : flags)") .addStatement("intent.addFlags(flag)") .endControlFlow() .addStatement("activity.startActivityForResult(intent, requestCode)"); return builder.build(); } NavigatorCodeGenerator(ProcessingEnvironment processingEnv); void generateClass(List<NavigableAnnotatedClass> navigableAnnotatedClassList); }
NavigatorCodeGenerator { MethodSpec handleResultActivity(NavigableAnnotatedClass value) { TypeName activityTypeName = AndroidSpecificClassProvider.getActivityTypeName(); TypeName intentTypeName = AndroidSpecificClassProvider.getIntentTypeName(); String activityQualifiedName = value.getTypeElement().getQualifiedName().toString(); ArrayTypeName integerArray = ArrayTypeName.of(ClassName.get(Integer.class)); String annotatedClassName = CodeGeneratorHelper.buildMethodName(value.getAnnotatedClassName() + "ForResult", value.getNavigableAnnotation()); MethodSpec.Builder builder = MethodSpec.methodBuilder(annotatedClassName) .addParameter(activityTypeName, "activity", Modifier.FINAL) .addParameter(TypeName.INT, "requestCode", Modifier.FINAL) .addParameter(integerArray, "flags", Modifier.FINAL) .varargs() .addModifiers(Modifier.STATIC, Modifier.PUBLIC) .addStatement("$T intent = new $T(activity, " + activityQualifiedName + ".class)", intentTypeName, intentTypeName) .beginControlFlow("for (Integer flag : flags)") .addStatement("intent.addFlags(flag)") .endControlFlow() .addStatement("activity.startActivityForResult(intent, requestCode)"); return builder.build(); } NavigatorCodeGenerator(ProcessingEnvironment processingEnv); void generateClass(List<NavigableAnnotatedClass> navigableAnnotatedClassList);  }