Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -32,6 +33,7 @@ public class AwaitingResultActivity extends Activity {
static final int THIRD_REQUEST = 33;
static final int FORTH_REQUEST = 44;
static final int FIFTH_REQUEST = 55;
static final int SIXTH_REQUEST = 66;
boolean onResultCalled = false;
boolean onResultWithDataCalled = false;
boolean onActivityResultWithResultCodeAndDataCalled = false;
Expand Down Expand Up @@ -86,4 +88,8 @@ void onResultWithIntentExtras(Intent originalIntent, @OnActivityResult.Extra Int
this.originalIntent = originalIntent;
this.extraIntent = extraIntent;
}

@OnActivityResult(SIXTH_REQUEST)
void onResultWithIntentExtras(@OnActivityResult.Extra byte bytee, @OnActivityResult.Extra byte[] bytes) {
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -80,11 +81,8 @@ public class BundleHelper {

private AndroidAnnotationsEnvironment environment;
private AnnotationHelper annotationHelper;
private ParcelerHelper parcelerHelper;
private APTCodeModelHelper codeModelHelper;

private TypeMirror element;

private boolean restoreCallNeedCastStatement = false;
private boolean restoreCallNeedsSuppressWarning = false;
private boolean parcelerBean = false;
Expand All @@ -98,8 +96,6 @@ public BundleHelper(AndroidAnnotationsEnvironment environment, TypeMirror elemen
this.environment = environment;
annotationHelper = new AnnotationHelper(environment);
codeModelHelper = new APTCodeModelHelper(environment);
parcelerHelper = new ParcelerHelper(environment);
this.element = element;

String typeString = element.toString();
TypeMirror type = element;
Expand Down Expand Up @@ -177,6 +173,8 @@ public BundleHelper(AndroidAnnotationsEnvironment environment, TypeMirror elemen
boolean hasTypeArguments = element.getKind() == TypeKind.DECLARED && hasTypeArguments(element) || //
element.getKind() == TypeKind.TYPEVAR && hasTypeArguments(getUpperBound(element));

ParcelerHelper parcelerHelper = new ParcelerHelper(environment);

if (isTypeParcelable(type)) {
methodNameToSave = "put" + "Parcelable";
methodNameToRestore = "get" + "Parcelable";
Expand All @@ -196,10 +194,6 @@ public BundleHelper(AndroidAnnotationsEnvironment environment, TypeMirror elemen
}
}

public String getMethodNameToSave() {
return methodNameToSave;
}

private boolean isTypeParcelable(TypeMirror typeMirror) {
TypeMirror parcelableType = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.PARCELABLE).asType();
return annotationHelper.isSubtype(typeMirror, parcelableType);
Expand All @@ -215,14 +209,6 @@ private boolean hasTypeArguments(TypeMirror type) {
return declaredType.getTypeArguments().size() > 0;
}

public IJExpression getExpressionToRestoreFromIntentOrBundle(AbstractJClass variableClass, IJExpression intent, IJExpression extras, IJExpression extraKey, JMethod method) {
if ("byte[]".equals(element.toString())) {
return intent.invoke("getByteArrayExtra").arg(extraKey);
} else {
return getExpressionToRestoreFromBundle(variableClass, extras, extraKey, method);
}
}

public IJExpression getExpressionToRestoreFromBundle(AbstractJClass variableClass, IJExpression bundle, IJExpression extraKey, JMethod method) {
IJExpression expressionToRestore;
if (methodNameToRestore.equals("getParcelableArray")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand All @@ -15,7 +16,6 @@
*/
package org.androidannotations.internal.core.handler;

import static com.helger.jcodemodel.JExpr.invoke;
import static com.helger.jcodemodel.JExpr.lit;
import static com.helger.jcodemodel.JMod.FINAL;
import static com.helger.jcodemodel.JMod.PUBLIC;
Expand Down Expand Up @@ -104,8 +104,7 @@ public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EActivi
JMethod injectExtrasMethod = holder.getInjectExtrasMethod();
JVar extras = holder.getInjectExtras();

IJExpression intent = invoke("getIntent");
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromIntentOrBundle(elementClass, intent, extras, extraKeyStaticField, injectExtrasMethod);
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromBundle(elementClass, extras, extraKeyStaticField, injectExtrasMethod);

JBlock ifContainsKey = targetBlock._if(JExpr.invoke(extras, "containsKey").arg(extraKeyStaticField))._then();
ifContainsKey.assign(fieldRef, restoreMethodCall);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -61,11 +62,11 @@ public void process(Element element, GeneratedClassHolder holder) throws Excepti
// Don't do anything here.
}

public IJExpression getExtraValue(VariableElement parameter, JVar intent, JVar extras, JBlock block, JMethod annotatedMethod, GeneratedClassHolder holder) {
return getExtraValue(parameter, intent, extras, block, annotatedMethod, holder.getGeneratedClass());
public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, JMethod annotatedMethod, GeneratedClassHolder holder) {
return getExtraValue(parameter, extras, block, annotatedMethod, holder.getGeneratedClass());
}

public IJExpression getExtraValue(VariableElement parameter, JVar intent, JVar extras, JBlock block, JMethod annotatedMethod, JDefinedClass generatedClass) {
public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, JMethod annotatedMethod, JDefinedClass generatedClass) {
String parameterName = parameter.getSimpleName().toString();
AbstractJClass parameterClass = codeModelHelper.typeMirrorToJClass(parameter.asType());

Expand All @@ -75,7 +76,7 @@ public IJExpression getExtraValue(VariableElement parameter, JVar intent, JVar e
}

BundleHelper bundleHelper = new BundleHelper(getEnvironment(), parameter.asType());
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromIntentOrBundle(parameterClass, intent, extras, getStaticExtraField(generatedClass, extraKey), annotatedMethod);
IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromBundle(parameterClass, extras, getStaticExtraField(generatedClass, extraKey), annotatedMethod);

return block.decl(parameterClass, parameterName, restoreMethodCall);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -125,7 +126,7 @@ public String getAnnotationValue(VariableElement parameter) {
}

public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, HasOnActivityResult holder) {
return super.getExtraValue(parameter, holder.getOnActivityResultDataParam(), extras, block, holder.getOnActivityResultMethod(), holder);
return super.getExtraValue(parameter, extras, block, holder.getOnActivityResultMethod(), holder);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -165,7 +166,7 @@ public String getAnnotationValue(VariableElement parameter) {
}

public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, EReceiverHolder holder) {
return getExtraValue(parameter, holder.getOnReceiveIntent(), extras, block, holder.getOnReceiveMethod(), holder);
return getExtraValue(parameter, extras, block, holder.getOnReceiveMethod(), holder);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -125,7 +126,7 @@ private JFieldVar createReceiverField(HasReceiverRegistration holder, String rec
if (extras == null) {
extras = body.decl(getClasses().BUNDLE, "extras_", JOp.cond(intentVar.invoke("getExtras").ne(_null()), intentVar.invoke("getExtras"), _new(getClasses().BUNDLE)));
}
methodCall.arg(extraHandler.getExtraValue(param, intentVar, extras, body, onReceiveMethod, anonymousReceiverClass));
methodCall.arg(extraHandler.getExtraValue(param, extras, body, onReceiveMethod, anonymousReceiverClass));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
* Copyright (C) 2016 the AndroidAnnotations project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -108,7 +109,7 @@ private void addActionInOnHandleIntent(EIntentServiceHolder holder, ExecutableEl
AbstractJClass extraParamClass = codeModelHelper.typeMirrorToJClass(param.asType());

BundleHelper bundleHelper = new BundleHelper(getEnvironment(), param.asType());
IJExpression getExtraExpression = bundleHelper.getExpressionToRestoreFromIntentOrBundle(extraParamClass, intent, extras, paramVar, onHandleIntentMethod);
IJExpression getExtraExpression = bundleHelper.getExpressionToRestoreFromBundle(extraParamClass, extras, paramVar, onHandleIntentMethod);

JVar extraField = callActionBlock.decl(extraParamClass, extraParamName, getExtraExpression);
callActionInvocation.arg(extraField);
Expand Down