-
Notifications
You must be signed in to change notification settings - Fork 8
Advanced Tips
Newtron Labs edited this page Mar 19, 2017
·
3 revisions
Here are a set of additional tips that can enhance the use of this library.
Events can be composed of objects that will be transferred over IPC. To easily facilitate this you can implement the IObjectIpc interface. For example:
public class ExampleObject implements IObjectIpc
{
}Instead of implementing all the methods of IEventIpc, a lightweight version of the events can be quickly created by extending EventIpcSimple.
public class ExampleEvent extends EventIpcSimple
{
public ExampleEvent()
{
}
public ExampleEvent(Parcel in)
{
super.readFromParcel(in);
}
}You can also extend EventIpcSimple and still allow the event to transfer objects.
public class ExampleEvent extends EventIpcSimple
{
private ExampleObject mExampleObject;
public ExampleEvent(ExampleObject exampleObject)
{
mExampleObject = exampleObject;
}
public ExampleEvent(Parcel in)
{
readFromParcel(in);
}
@Override
public void readFromParcel(Parcel in)
{
mExampleObject = (ExampleObject) ParcelHelper.getInstance()
.createFromParcel(in, ExampleObject.class);
}
@Override
public void writeToParcel(Parcel dest, int flags)
{
ParcelHelper.getInstance().writeToParcel(dest, flags, mExampleObject);
}
public ExampleObject getTestObject()
{
return mExampleObject;
}
}