我使用Parceler FragmentArgs与RealmObjects(和Lombok)并获得以下构建错误。
Error:(73, 70) error: Parceler: Unable to find read/write generator for type io.realm.RealmList<backend.model.Invitation> for backend.model.ProjectInfo#invitations
我的类ProjectInfo看起来像这样
@Parcel(implementations = {ProjectInfoRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {ProjectInfo.class})
public class ProjectInfo extends RealmObject
{
@Getter @Setter @PrimaryKey long projectId;
@ParcelPropertyConverter(RealmListParcelConverter.class) @Getter @Setter @Ignore RealmList<Invitation> invitations;
@ParcelPropertyConverter(RealmListParcelConverter.class) @Getter @Setter RealmList<Submission> submissions;
}
Classes Submission和Invitation都是非常简单的数据结构,也扩展了RealmObject
班级RealmListParcelConverter
如下所示:
public class RealmListParcelConverter implements TypeRangeParcelConverter<RealmList<? extends RealmObject>, RealmList<? extends RealmObject>>
{
private static final int NULL = -1;
@Override
public void toParcel(RealmList<? extends RealmObject> input, Parcel parcel)
{
parcel.writeInt(input == null ? NULL : input.size());
if(input != null)
{
for(RealmObject item : input)
{
parcel.writeParcelable(Parcels.wrap(item), 0);
}
}
}
@Override
public RealmList fromParcel(Parcel parcel)
{
int size = parcel.readInt();
RealmList list = new RealmList();
for(int i = 0; i < size; i++)
{
Parcelable parcelable = parcel.readParcelable(getClass().getClassLoader());
list.add((RealmObject) Parcels.unwrap(parcelable));
}
return list;
}
}
我做错了什么?
邀请班
@Parcel(implementations = {InvitationRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Invitation.class})
public class Invitation extends RealmObject
{
@Getter @Setter long accountId;
@Getter @Setter long projectId;
@Getter @Setter boolean declined;
@Getter @Setter String name;
public Invitation() {}
}
提交类
@Parcel(implementations = {SubmissionRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {Submission.class})
public class Submission extends RealmObject
{
@Getter @Setter @PrimaryKey long id;
@Getter @Setter long creator;
@Getter @Setter float length;
public Submission() {}
}
只有在我使用
时才会发生这种情况@Parcel(implementations = {ProjectInfoRealmProxy.class}, value = Parcel.Serialization.BEAN, analyze = {ProjectInfo.class})
如果我使用简单的
@Parcel
它在运行时崩溃
时崩溃org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for io.realm.ProjectInfoRealmProxy
我正在使用@Args注释中的parcel,就像这样
@Arg(bundler = ParcelerArgsBundler.class) ProjectInfo projectInfo;