Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
Expand Up @@ -15,6 +15,7 @@
*/
package org.androidannotations.helper;

import java.io.Serializable;
import java.net.URI;
import java.sql.SQLException;
import java.util.ArrayList;
Expand Down Expand Up @@ -42,6 +43,7 @@ public final class CanonicalNameConstants {
public static final String INTEGER = Integer.class.getCanonicalName();
public static final String BOOLEAN = Boolean.class.getCanonicalName();
public static final String ARRAYLIST = ArrayList.class.getCanonicalName();
public static final String SERIALIZABLE = Serializable.class.getCanonicalName();

/*
* Android
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class Classes {
public final JClass HANDLER = refClass(CanonicalNameConstants.HANDLER);
public final JClass KEY_STORE = refClass(CanonicalNameConstants.KEY_STORE);
public final JClass VIEW_SERVER = refClass(CanonicalNameConstants.VIEW_SERVER);
public final JClass PARCELABLE = refClass(CanonicalNameConstants.PARCELABLE);

/*
* Sherlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static com.sun.codemodel.JMod.PUBLIC;
import static com.sun.codemodel.JMod.STATIC;
import static org.androidannotations.helper.CanonicalNameConstants.PARCELABLE;
import static org.androidannotations.helper.CanonicalNameConstants.SERIALIZABLE;
import static org.androidannotations.helper.CanonicalNameConstants.STRING;

import javax.annotation.processing.ProcessingEnvironment;
Expand Down Expand Up @@ -137,6 +138,7 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) {
JMethod method = holder.intentBuilderClass.method(PUBLIC, holder.intentBuilderClass, fieldName);

boolean castToSerializable = false;
boolean castToParcelable = false;
TypeMirror extraType = elementType;
if (extraType.getKind() == TypeKind.DECLARED) {
Elements elementUtils = processingEnv.getElementUtils();
Expand All @@ -147,6 +149,11 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) {
if (!typeUtils.isSubtype(extraType, stringType)) {
castToSerializable = true;
}
} else {
TypeMirror serializableType = elementUtils.getTypeElement(SERIALIZABLE).asType();
if (typeUtils.isSubtype(extraType, serializableType)) {
castToParcelable = true;
}
}
}
JClass paramClass = helper.typeMirrorToJClass(extraType, holder);
Expand All @@ -155,6 +162,8 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) {
JInvocation invocation = body.invoke(holder.intentField, "putExtra").arg(extraKeyField);
if (castToSerializable) {
invocation.arg(cast(classes.SERIALIZABLE, extraParam));
} else if (castToParcelable) {
invocation.arg(cast(classes.PARCELABLE, extraParam));
} else {
invocation.arg(extraParam);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class ExtraInjectedActivity extends Activity {

@Extra
String extraWithoutValue;

@Extra
ParcelableSerializableData parcelableSerializableData;

@Override
protected void onNewIntent(Intent intent) {
Expand All @@ -53,5 +56,6 @@ void intentWithExtras() {
ExtraInjectedActivity_.intent(this).arrayExtra(null).start();
ExtraInjectedActivity_.intent(this).intExtra(42).get();
ExtraInjectedActivity_.intent(this).stringExtra("hello").startForResult(42);
ExtraInjectedActivity_.intent(this).parcelableSerializableData(new ParcelableSerializableData()).get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.androidannotations.test15;

import java.io.Serializable;

import android.os.Parcel;
import android.os.Parcelable;

public class ParcelableSerializableData implements Parcelable, Serializable {

private static final long serialVersionUID = 920532042616086169L;

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {

}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.