Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Closed
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
Expand Up @@ -15,16 +15,14 @@
*/
package org.androidannotations.handler;

import static com.sun.codemodel.JExpr.invoke;
import static com.sun.codemodel.JExpr.lit;
import static com.sun.codemodel.JMod.FINAL;
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;

import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JFieldRef;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JVar;
import org.androidannotations.annotations.Extra;
import org.androidannotations.helper.APTCodeModelHelper;
import org.androidannotations.helper.AnnotationHelper;
Expand All @@ -35,14 +33,15 @@
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.process.IsValid;

import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JFieldRef;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JVar;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;

import static com.sun.codemodel.JExpr.invoke;
import static com.sun.codemodel.JExpr.lit;
import static com.sun.codemodel.JMod.FINAL;
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;

public class ExtraHandler extends BaseAnnotationHandler<HasExtras> {

Expand All @@ -64,6 +63,8 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa
validatorHelper.enclosingElementHasEActivity(element, validatedElements, valid);

validatorHelper.isNotPrivate(element, valid);

validatorHelper.canBePutInABundle(element, valid);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,6 @@
*/
package org.androidannotations.handler;

import static com.sun.codemodel.JExpr._this;
import static com.sun.codemodel.JExpr.lit;
import static com.sun.codemodel.JMod.FINAL;
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;

import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.helper.APTCodeModelHelper;
import org.androidannotations.helper.AnnotationHelper;
import org.androidannotations.helper.BundleHelper;
import org.androidannotations.helper.CaseHelper;
import org.androidannotations.holder.EFragmentHolder;
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.process.IsValid;

import com.sun.codemodel.JBlock;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JDefinedClass;
Expand All @@ -43,6 +24,24 @@
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JVar;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.helper.APTCodeModelHelper;
import org.androidannotations.helper.AnnotationHelper;
import org.androidannotations.helper.BundleHelper;
import org.androidannotations.helper.CaseHelper;
import org.androidannotations.holder.EFragmentHolder;
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.process.IsValid;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.type.TypeMirror;

import static com.sun.codemodel.JExpr._this;
import static com.sun.codemodel.JExpr.lit;
import static com.sun.codemodel.JMod.FINAL;
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;

public class FragmentArgHandler extends BaseAnnotationHandler<EFragmentHolder> {

Expand All @@ -59,6 +58,8 @@ public void validate(Element element, AnnotationElements validatedElements, IsVa
validatorHelper.enclosingElementHasEFragment(element, validatedElements, valid);

validatorHelper.isNotPrivate(element, valid);

validatorHelper.canBePutInABundle(element, valid);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,24 @@
*/
package org.androidannotations.helper;

import static org.androidannotations.helper.CanonicalNameConstants.BUNDLE;
import static org.androidannotations.helper.CanonicalNameConstants.CHAR_SEQUENCE;
import static org.androidannotations.helper.CanonicalNameConstants.STRING;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JMethod;
import org.androidannotations.holder.GeneratedClassHolder;

import javax.lang.model.element.TypeElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.androidannotations.holder.GeneratedClassHolder;

import com.sun.codemodel.JClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JExpression;
import com.sun.codemodel.JMethod;
import static org.androidannotations.helper.CanonicalNameConstants.BUNDLE;
import static org.androidannotations.helper.CanonicalNameConstants.CHAR_SEQUENCE;
import static org.androidannotations.helper.CanonicalNameConstants.STRING;

public class BundleHelper {
public static final Map<String, String> METHOD_SUFFIX_BY_TYPE_NAME = new HashMap<String, String>();
Expand Down Expand Up @@ -185,26 +183,12 @@ public BundleHelper(AnnotationHelper helper, TypeMirror element) {
}
}

public boolean restoreCallNeedCastStatement() {
return restoreCallNeedCastStatement;
}

public boolean restoreCallNeedsSuppressWarning() {
return restoreCallNeedsSuppressWarning;
}

public String getMethodNameToSave() {
return methodNameToSave;
}

public String getMethodNameToRestore() {
return methodNameToRestore;
}

private boolean isTypeParcelable(TypeElement elementType) {

TypeElement parcelableType = annotationHelper.typeElementFromQualifiedName(CanonicalNameConstants.PARCELABLE);

return elementType != null && annotationHelper.isSubtype(elementType, parcelableType);
}

Expand All @@ -225,10 +209,10 @@ public JExpression getExpressionToRestoreFromBundle(JClass variableClass, JExpre
expressionToRestore = JExpr.invoke(bundle, methodNameToRestore).arg(extraKey);
}

if (restoreCallNeedCastStatement()) {
if (restoreCallNeedCastStatement) {
expressionToRestore = JExpr.cast(variableClass, expressionToRestore);

if (restoreCallNeedsSuppressWarning()) {
if (restoreCallNeedsSuppressWarning) {
codeModelHelper.addSuppressWarnings(method, "unchecked");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
*/
package org.androidannotations.test15;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;

import android.app.Activity;
import android.content.Intent;
import java.util.ArrayList;

@EActivity
public class ExtraInjectedActivity extends Activity {
Expand All @@ -33,7 +32,7 @@ public class ExtraInjectedActivity extends Activity {
CustomData[] arrayExtra;

@Extra("listExtra")
List<String> listExtra;
ArrayList<String> listExtra;

@Extra("intExtra")
int intExtra;
Expand Down