sealed class StateClass {
data class StateNormal(val action: Int = ACTION_NONE) : StateClass()
data class StatePreparing(val action: Int = ACTION_NONE) : StateClass()
data class StateRecording(val action: Int = ACTION_NONE) : StateClass()
data class StateWantCancel(val action: Int = ACTION_NONE) : StateClass()
}
private val recordLiveData = MutableLiveData<StateClass>()
recordLiveData.observe(context as LifecycleOwner) { state ->
when (state) {
is StateClass.StateNormal -> {
if (state.action == MotionEvent.ACTION_UP) {
...
}
}
...
}
...
}