From d94d66eb1f9df659f6ed7d96bda26471278d8ebb Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Fri, 6 Jan 2023 11:21:12 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../list/NotificationsListViewModel.kt | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt index 030f84bd..d13e00fb 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt @@ -9,42 +9,33 @@ import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.* import javax.inject.Inject -typealias NotificationsListViewModel = BaseViewModel +abstract class NotificationsListViewModel : + BaseViewModel() { + + override fun createInitialState(): NotificationsListUiState = NotificationsListUiState() + + override fun dispatchEvent(partialChange: NotificationsListPartialChange): UiEvent? = + when (partialChange) { + is NotificationsListPartialChange.Refresh.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) + is NotificationsListPartialChange.LoadMore.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) + else -> null + } +} @HiltViewModel class ReplyMeListViewModel @Inject constructor() : NotificationsListViewModel() { - override fun createInitialState(): NotificationsListUiState = NotificationsListUiState() - override fun createPartialChangeProducer(): PartialChangeProducer { return NotificationsListPartialChangeProducer(NotificationsType.ReplyMe) } - - override fun dispatchEvent(partialChange: NotificationsListPartialChange): UiEvent? = - when (partialChange) { - is NotificationsListPartialChange.Refresh.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) - is NotificationsListPartialChange.LoadMore.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) - else -> null - } - } @HiltViewModel class AtMeListViewModel @Inject constructor() : NotificationsListViewModel() { - override fun createInitialState(): NotificationsListUiState = NotificationsListUiState() - override fun createPartialChangeProducer(): PartialChangeProducer { return NotificationsListPartialChangeProducer(NotificationsType.AtMe) } - - override fun dispatchEvent(partialChange: NotificationsListPartialChange): UiEvent? = - when (partialChange) { - is NotificationsListPartialChange.Refresh.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) - is NotificationsListPartialChange.LoadMore.Failure -> CommonUiEvent.Toast(partialChange.error.getErrorMessage()) - else -> null - } - } private class NotificationsListPartialChangeProducer(private val type: NotificationsType) : PartialChangeProducer {