我有一個密封的班級
我的事件.kt
sealed class MyEvents<out T : Any>{
sealed class HelloBroadcasting<out T : Any> : MyEvents<Nothing>() {
sealed class FeatureSegments : HelloBroadcasting<Nothing>() {
class SegmentationCourseSeekChapterChange(val context: Context) : FeatureSegments()
class SegmentationChapterNameClicked(val context: Context, chapterName: String) : FeatureSegments()
class SegmentationChapterSelectionFromChapterList(val context: Context) : FeatureSegments()
}
}
}
我叫密封班
sendTheEventEvent(MyEvents.HelloBroadcasting.FeatureSegments.SegmentationChapterNameClicked(mContext,it.textDirection.toString()))
我正在嘗試將事件接收為
fun sendCleverTapEvent(event: MyEvents<Int>) {
when(event){
is MyEvents.HelloBroadcasting.FeatureSegments.SegmentationChapterNameClicked -> test(event.context,event.) // ---> Here I am not able to access the name
is MyEvents.HelloBroadcasting.FeatureSegments.SegmentationChapterSelectionFromChapterList -> TODO()
is MyEvents.HelloBroadcasting.FeatureSegments.SegmentationCourseSeekChapterChange -> TODO()
}
}
我無法訪問接收部分中的名稱。當嵌套級別存在時如何正確執行此操作?
您必須創建chapterName
一個屬性:
- chapterName: String
+ val chapterName: String
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句