Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

ParcelerIntegration

Csaba Kozák edited this page Feb 16, 2019 · 4 revisions

Integrating Parceler and AndroidAnnotations

Since AndroidAnnotations 4.0.0

Parceler is an annotation processor which generates implementation of the Parcelable interface, thus removes tons of boilerplate code.

AndroidAnnotations can detect if Parceler is on the classpath, and automatically call it during various Bundle operations. You just have to annotate your POJO with Parceler annotations as usual, and pass the simple object around: AndroidAnnotations will call Parcels.wrap/unwrap when needed.

Usage example:

@Parcel
public class Person {

	String name;
	int age;

	public Person() {
	}

	@ParcelConstructor
	public Person(String name, int age) {
		this.name = name;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public int getAge() {
		return age;
	}
}
@EActivity
public class ExtraInjectedActivity extends Activity {

	@Extra("personExtra")
	Person person;

	@AfterInject
	void afterInject() {
		Log.w("AAParceler", person.getName());
	}
}
Person john = new Person("John Doe", 25);
ExtraInjectedActivity_.intent(context).personExtra(john).start();

Related annotations:

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Extending AndroidAnnotations

Clone this wiki locally