mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +03:00
Hilt: continue migration
This commit is contained in:
parent
f8d208fb4f
commit
9dd7017131
16 changed files with 106 additions and 117 deletions
|
@ -59,6 +59,11 @@ class HiltMavericksViewModelFactory<VM : MavericksViewModel<S>, S : MavericksSta
|
|||
val castedViewModelFactory = viewModelFactory as? MavericksAssistedViewModelFactory<VM, S>
|
||||
return castedViewModelFactory?.create(state) as VM
|
||||
}
|
||||
|
||||
override fun initialState(viewModelContext: ViewModelContext): S? {
|
||||
return super.initialState(viewModelContext)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,14 @@ import dagger.Binds
|
|||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.multibindings.IntoMap
|
||||
import im.vector.app.features.auth.ReAuthViewModel
|
||||
import im.vector.app.features.call.VectorCallViewModel
|
||||
import im.vector.app.features.call.conference.JitsiCallViewModel
|
||||
import im.vector.app.features.home.room.list.RoomListViewModel
|
||||
import im.vector.app.features.roomdirectory.RoomDirectoryViewModel
|
||||
import im.vector.app.features.spaces.SpaceListViewModel
|
||||
import im.vector.app.features.spaces.manage.SpaceManageRoomsViewModel
|
||||
import im.vector.app.features.spaces.manage.SpaceManageSharedViewModel
|
||||
|
||||
@InstallIn(MavericksViewModelComponent::class)
|
||||
@Module
|
||||
|
@ -30,4 +37,42 @@ interface MavericksViewModelModule {
|
|||
@IntoMap
|
||||
@MavericksViewModelKey(RoomListViewModel::class)
|
||||
fun roomListViewModelFactory(factory: RoomListViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(SpaceManageRoomsViewModel::class)
|
||||
fun spaceManageRoomsViewModelFactory(factory: SpaceManageRoomsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(SpaceManageSharedViewModel::class)
|
||||
fun spaceManageSharedViewModelFactory(factory: SpaceManageSharedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(SpaceListViewModel::class)
|
||||
fun spaceListViewModelFactory(factory: SpaceListViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(ReAuthViewModel::class)
|
||||
fun reAuthViewModelFactory(factory: ReAuthViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(VectorCallViewModel::class)
|
||||
fun vectorCallViewModelFactory(factory: VectorCallViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(JitsiCallViewModel::class)
|
||||
fun jitsiCallViewModelFactory(factory: JitsiCallViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@MavericksViewModelKey(RoomDirectoryViewModel::class)
|
||||
fun roomDirectoryViewModelFactory(factory: RoomDirectoryViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.matrix.android.sdk.api.auth.registration.nextUncompletedStage
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class ReAuthActivity : SimpleFragmentActivity(), ReAuthViewModel.Factory {
|
||||
class ReAuthActivity : SimpleFragmentActivity(){
|
||||
|
||||
@Parcelize
|
||||
data class Args(
|
||||
|
@ -59,9 +59,6 @@ class ReAuthActivity : SimpleFragmentActivity(), ReAuthViewModel.Factory {
|
|||
private var customTabsSession: CustomTabsSession? = null
|
||||
|
||||
@Inject lateinit var authenticationService: AuthenticationService
|
||||
@Inject lateinit var reAuthViewModelFactory: ReAuthViewModel.Factory
|
||||
|
||||
override fun create(initialState: ReAuthState) = reAuthViewModelFactory.create(initialState)
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
super.injectWith(injector)
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.airbnb.mvrx.ViewModelContext
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
@ -35,20 +37,11 @@ class ReAuthViewModel @AssistedInject constructor(
|
|||
) : VectorViewModel<ReAuthState, ReAuthActions, ReAuthEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: ReAuthState): ReAuthViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<ReAuthViewModel,ReAuthState> {
|
||||
override fun create(state: ReAuthState): ReAuthViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<ReAuthViewModel, ReAuthState> {
|
||||
|
||||
override fun create(viewModelContext: ViewModelContext, state: ReAuthState): ReAuthViewModel? {
|
||||
val factory = when (viewModelContext) {
|
||||
is FragmentViewModelContext -> viewModelContext.fragment as? Factory
|
||||
is ActivityViewModelContext -> viewModelContext.activity as? Factory
|
||||
}
|
||||
return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface")
|
||||
}
|
||||
}
|
||||
companion object : MavericksViewModelFactory<ReAuthViewModel, ReAuthState> by hiltMavericksViewModelFactory()
|
||||
|
||||
override fun handle(action: ReAuthActions) = withState { state ->
|
||||
when (action) {
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.airbnb.mvrx.viewModel
|
|||
import com.airbnb.mvrx.withState
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
|
@ -89,6 +90,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
|
||||
override fun getBinding() = ActivityCallBinding.inflate(layoutInflater)
|
||||
|
||||
@Inject lateinit var callManager: WebRtcCallManager
|
||||
@Inject lateinit var avatarRenderer: AvatarRenderer
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
|
@ -97,8 +99,6 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
|
||||
private val callViewModel: VectorCallViewModel by viewModel()
|
||||
|
||||
@Inject lateinit var callManager: WebRtcCallManager
|
||||
@Inject lateinit var viewModelFactory: VectorCallViewModel.Factory
|
||||
|
||||
private val dialPadCallback = object : DialPadFragment.Callback {
|
||||
override fun onDigitAppended(digit: String) {
|
||||
|
|
|
@ -25,6 +25,8 @@ import com.airbnb.mvrx.ViewModelContext
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.call.audio.CallAudioManager
|
||||
|
@ -341,16 +343,9 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: VectorCallViewState): VectorCallViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<VectorCallViewModel,VectorCallViewState> {
|
||||
override fun create(state: VectorCallViewState): VectorCallViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<VectorCallViewModel, VectorCallViewState> {
|
||||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: VectorCallViewState): VectorCallViewModel {
|
||||
val callActivity: VectorCallActivity = viewModelContext.activity()
|
||||
return callActivity.viewModelFactory.create(state)
|
||||
}
|
||||
}
|
||||
companion object : MavericksViewModelFactory<VectorCallViewModel, VectorCallViewState> by hiltMavericksViewModelFactory()
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.airbnb.mvrx.ViewModelContext
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -46,8 +48,8 @@ class JitsiCallViewModel @AssistedInject constructor(
|
|||
) : VectorViewModel<JitsiCallViewState, JitsiCallViewActions, JitsiCallViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: JitsiCallViewState): JitsiCallViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<JitsiCallViewModel,JitsiCallViewState> {
|
||||
override fun create(state: JitsiCallViewState): JitsiCallViewModel
|
||||
}
|
||||
|
||||
private var currentWidgetObserver: Job? = null
|
||||
|
@ -143,24 +145,9 @@ class JitsiCallViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<JitsiCallViewModel, JitsiCallViewState> {
|
||||
|
||||
companion object : MavericksViewModelFactory<JitsiCallViewModel, JitsiCallViewState> by hiltMavericksViewModelFactory() {
|
||||
const val ENABLE_VIDEO_OPTION = "ENABLE_VIDEO_OPTION"
|
||||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: JitsiCallViewState): JitsiCallViewModel? {
|
||||
val callActivity: VectorJitsiActivity = viewModelContext.activity()
|
||||
return callActivity.viewModelFactory.create(state)
|
||||
}
|
||||
|
||||
override fun initialState(viewModelContext: ViewModelContext): JitsiCallViewState? {
|
||||
val args: VectorJitsiActivity.Args = viewModelContext.args()
|
||||
|
||||
return JitsiCallViewState(
|
||||
roomId = args.roomId,
|
||||
widgetId = args.widgetId,
|
||||
enableVideo = args.enableVideo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,4 +26,12 @@ data class JitsiCallViewState(
|
|||
val widgetId: String = "",
|
||||
val enableVideo: Boolean = false,
|
||||
val widget: Async<Widget> = Uninitialized
|
||||
) : MavericksState
|
||||
) : MavericksState {
|
||||
|
||||
constructor(args: VectorJitsiActivity.Args): this(
|
||||
roomId = args.roomId,
|
||||
widgetId = args.widgetId,
|
||||
enableVideo = args.enableVideo
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -61,8 +61,6 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
|
|||
|
||||
override fun getBinding() = ActivityJitsiBinding.inflate(layoutInflater)
|
||||
|
||||
@Inject lateinit var viewModelFactory: JitsiCallViewModel.Factory
|
||||
|
||||
private var jitsiMeetView: JitsiMeetView? = null
|
||||
|
||||
private val jitsiViewModel: JitsiCallViewModel by viewModel()
|
||||
|
|
|
@ -26,6 +26,8 @@ import com.airbnb.mvrx.appendAt
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import kotlinx.coroutines.CancellationException
|
||||
|
@ -49,18 +51,12 @@ class RoomDirectoryViewModel @AssistedInject constructor(
|
|||
) : VectorViewModel<PublicRoomsViewState, RoomDirectoryAction, RoomDirectoryViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: PublicRoomsViewState): RoomDirectoryViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<RoomDirectoryViewModel,PublicRoomsViewState> {
|
||||
override fun create(state: PublicRoomsViewState): RoomDirectoryViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<RoomDirectoryViewModel, PublicRoomsViewState> {
|
||||
companion object : MavericksViewModelFactory<RoomDirectoryViewModel, PublicRoomsViewState> by hiltMavericksViewModelFactory() {
|
||||
private const val PUBLIC_ROOMS_LIMIT = 20
|
||||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: PublicRoomsViewState): RoomDirectoryViewModel? {
|
||||
val activity: RoomDirectoryActivity = (viewModelContext as ActivityViewModelContext).activity()
|
||||
return activity.roomDirectoryViewModelFactory.create(state)
|
||||
}
|
||||
}
|
||||
|
||||
private val showAllRooms = vectorPreferences.showAllPublicRooms()
|
||||
|
|
|
@ -39,12 +39,11 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
|||
import javax.inject.Inject
|
||||
|
||||
class SpaceListFragment @Inject constructor(
|
||||
val spaceListViewModelFactory: SpacesListViewModel.Factory,
|
||||
private val spaceController: SpaceSummaryController
|
||||
) : VectorBaseFragment<FragmentGroupListBinding>(), SpaceSummaryController.Callback {
|
||||
|
||||
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
||||
private val viewModel: SpacesListViewModel by fragmentViewModel()
|
||||
private val viewModel: SpaceListViewModel by fragmentViewModel()
|
||||
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentGroupListBinding {
|
||||
return FragmentGroupListBinding.inflate(inflater, container, false)
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
package im.vector.app.features.spaces
|
||||
|
||||
import androidx.lifecycle.asFlow
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.AppStateHandler
|
||||
import im.vector.app.RoomGroupingMethod
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
|
@ -59,7 +59,7 @@ import org.matrix.android.sdk.api.session.space.model.TopLevelSpaceComparator
|
|||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
|
||||
class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: SpaceListViewState,
|
||||
class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: SpaceListViewState,
|
||||
private val appStateHandler: AppStateHandler,
|
||||
private val session: Session,
|
||||
private val vectorPreferences: VectorPreferences,
|
||||
|
@ -67,18 +67,11 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
) : VectorViewModel<SpaceListViewState, SpaceListAction, SpaceListViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: SpaceListViewState): SpacesListViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<SpaceListViewModel, SpaceListViewState> {
|
||||
override fun create(state: SpaceListViewState): SpaceListViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<SpacesListViewModel, SpaceListViewState> {
|
||||
|
||||
@JvmStatic
|
||||
override fun create(viewModelContext: ViewModelContext, state: SpaceListViewState): SpacesListViewModel {
|
||||
val groupListFragment: SpaceListFragment = (viewModelContext as FragmentViewModelContext).fragment()
|
||||
return groupListFragment.spaceListViewModelFactory.create(state)
|
||||
}
|
||||
}
|
||||
companion object : MavericksViewModelFactory<SpaceListViewModel, SpaceListViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
// private var currentGroupingMethod : RoomGroupingMethod? = null
|
||||
|
|
@ -51,10 +51,8 @@ data class SpaceManageArgs(
|
|||
) : Parcelable
|
||||
|
||||
class SpaceManageActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>(),
|
||||
ToolbarConfigurable,
|
||||
SpaceManageSharedViewModel.Factory {
|
||||
ToolbarConfigurable {
|
||||
|
||||
@Inject lateinit var sharedViewModelFactory: SpaceManageSharedViewModel.Factory
|
||||
private lateinit var sharedDirectoryActionViewModel: RoomDirectorySharedActionViewModel
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
|
@ -194,8 +192,6 @@ class SpaceManageActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun create(initialState: SpaceManageViewState) = sharedViewModelFactory.create(initialState)
|
||||
|
||||
override fun configure(toolbar: MaterialToolbar) {
|
||||
configureToolbar(toolbar)
|
||||
}
|
||||
|
|
|
@ -45,10 +45,8 @@ import java.util.concurrent.TimeUnit
|
|||
import javax.inject.Inject
|
||||
|
||||
class SpaceManageRoomsFragment @Inject constructor(
|
||||
private val viewModelFactory: SpaceManageRoomsViewModel.Factory,
|
||||
private val epoxyController: SpaceManageRoomsController
|
||||
) : VectorBaseFragment<FragmentSpaceAddRoomsBinding>(),
|
||||
SpaceManageRoomsViewModel.Factory,
|
||||
OnBackPressed,
|
||||
SpaceManageRoomsController.Listener,
|
||||
Callback {
|
||||
|
@ -107,8 +105,6 @@ class SpaceManageRoomsFragment @Inject constructor(
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun create(initialState: SpaceManageRoomViewState) = viewModelFactory.create(initialState)
|
||||
|
||||
override fun invalidate() = withState(viewModel) { state ->
|
||||
epoxyController.setData(state)
|
||||
|
||||
|
|
|
@ -16,18 +16,16 @@
|
|||
|
||||
package im.vector.app.features.spaces.manage
|
||||
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.ActivityViewModelContext
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.mvrx.runCatchingToAsync
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
|
@ -56,19 +54,11 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: SpaceManageRoomViewState): SpaceManageRoomsViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<SpaceManageRoomsViewModel, SpaceManageRoomViewState> {
|
||||
override fun create(state: SpaceManageRoomViewState): SpaceManageRoomsViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<SpaceManageRoomsViewModel, SpaceManageRoomViewState> {
|
||||
override fun create(viewModelContext: ViewModelContext, state: SpaceManageRoomViewState): SpaceManageRoomsViewModel? {
|
||||
val factory = when (viewModelContext) {
|
||||
is FragmentViewModelContext -> viewModelContext.fragment as? Factory
|
||||
is ActivityViewModelContext -> viewModelContext.activity as? Factory
|
||||
}
|
||||
return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface")
|
||||
}
|
||||
}
|
||||
companion object : MavericksViewModelFactory<SpaceManageRoomsViewModel, SpaceManageRoomViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
override fun handle(action: SpaceManageRoomViewAction) {
|
||||
when (action) {
|
||||
|
|
|
@ -16,13 +16,12 @@
|
|||
|
||||
package im.vector.app.features.spaces.manage
|
||||
|
||||
import com.airbnb.mvrx.ActivityViewModelContext
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.ViewModelContext
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
@ -33,19 +32,11 @@ class SpaceManageSharedViewModel @AssistedInject constructor(
|
|||
) : VectorViewModel<SpaceManageViewState, SpaceManagedSharedAction, SpaceManagedSharedViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(initialState: SpaceManageViewState): SpaceManageSharedViewModel
|
||||
interface Factory: MavericksAssistedViewModelFactory<SpaceManageSharedViewModel,SpaceManageViewState>{
|
||||
override fun create(state: SpaceManageViewState): SpaceManageSharedViewModel
|
||||
}
|
||||
|
||||
companion object : MavericksViewModelFactory<SpaceManageSharedViewModel, SpaceManageViewState> {
|
||||
override fun create(viewModelContext: ViewModelContext, state: SpaceManageViewState): SpaceManageSharedViewModel? {
|
||||
val factory = when (viewModelContext) {
|
||||
is FragmentViewModelContext -> viewModelContext.fragment as? Factory
|
||||
is ActivityViewModelContext -> viewModelContext.activity as? Factory
|
||||
}
|
||||
return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface")
|
||||
}
|
||||
}
|
||||
companion object : MavericksViewModelFactory<SpaceManageSharedViewModel, SpaceManageViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
override fun handle(action: SpaceManagedSharedAction) {
|
||||
when (action) {
|
||||
|
|
Loading…
Reference in a new issue