我想制作一个可打包的数据类来放置捆绑包。这个数据类还包含一个我将调用的函数。但是当我把应用程序放回去时,我遇到了 parcelize 异常。这是我的可打包数据类,
@Parcelize
data class TransactionConfirmData(
val title: String,
@StringRes val cancelBtnLabel: Int
@StringRes val confirmBtnLabel: Int
val confirmElements: Map<String, String>,
val customConfirmDataList: List<CustomTransactionConfirmData> = emptyList(),
val requestMethodId: Int,
@NavigationRes val cancelDestination: Int = 0,
val contentStructure:
TransactionBodyContentCaseTransactionBodyContentCase.BASE_CONFIRM,
@IgnoredOnParcel val onPressFunction: Serializable
) : 可打包{
fun onPressOkey() = onPressFunction as () -> Unit
companion object {
fun create(
title: String,
@StringRes cancelBtnLabel: Int = R.string.bottom_sheet_behavior
@StringRes confirmBtnLabel: Int = R.string.bottom_sheet_behavior
confirmElements: Map<String, String>,
customConfirmDataList: List<CustomTransactionConfirmData> = emptyList(),
requestMethodId: Int,
@NavigationRes cancelDestination: Int = 0,
contentStructure: TransactionBodyContentCase =
TransactionBodyContentCase.BASE_CONFIRM,
onPressFunction: ()->Unit = {}
): TransactionConfirmData = TransactionConfirmData(
title,
cancelBtnLabel,
confirmBtnLabel,
confirmElements,
customConfirmDataList,
requestMethodId,
cancelDestination,
contentStructure,
onPressFunction as Serializable
)
}
}
但这不起作用。