ParcelerIntegration

Tamas Vegh edited this page Sep 7, 2017 · 3 revisions

2/11/2017 The 4.4.0 release is out !

Using AndroidAnnotations

Questions?

Enjoying AndroidAnnotations

Improving AndroidAnnotations

Extending AndroidAnnotations

Clone this wiki locally

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 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_.personExtra(john).start();

Related annotations: