所以我得到了Retrofit API + Gson作为转换器,并且我有一个可打包的类传递给各种活动...
@Parcelize
data class GenericList<T>(
@SerializedName("data") var data: @RawValue List<T>
) : Parcelable
这里是一个通用列表类,可以通过以下内容进行打包:
abstract class AbsPlot : Parcelable {
abstract var rating: Map<String, Rating>?
abstract var plots: GenericList<Plot>?
....
abstract var languages: GenericList<Language>?
}
@Parcelize
data class Plot(
@SerializedName("rating") override var rating: Map<String, Rating>?,
@SerializedName("plots") override var plots: GenericList<Plot>?,
....
@SerializedName("languages") override var languages: GenericList<Language>?,
) : AbsPlot()
一旦我想取消包裹这些类,它就会崩溃原因:android.os.BadParcelableException:解组时出现ClassNotFoundException
什么是解决方案?
问题可能是@RawValue
注释。