Hilt: continue migration VM

This commit is contained in:
ganfra 2021-10-19 16:31:22 +02:00
parent 1d73077184
commit bb68e735f7
42 changed files with 242 additions and 312 deletions

View File

@ -28,11 +28,32 @@ import im.vector.app.features.contactsbook.ContactsBookViewModel
import im.vector.app.features.createdirect.CreateDirectRoomViewModel import im.vector.app.features.createdirect.CreateDirectRoomViewModel
import im.vector.app.features.crypto.keysbackup.settings.KeysBackupSettingsViewModel import im.vector.app.features.crypto.keysbackup.settings.KeysBackupSettingsViewModel
import im.vector.app.features.crypto.quads.SharedSecureStorageViewModel import im.vector.app.features.crypto.quads.SharedSecureStorageViewModel
import im.vector.app.features.crypto.verification.choose.VerificationChooseMethodViewModel
import im.vector.app.features.crypto.verification.emoji.VerificationEmojiCodeViewModel
import im.vector.app.features.devtools.RoomDevToolViewModel import im.vector.app.features.devtools.RoomDevToolViewModel
import im.vector.app.features.discovery.DiscoverySettingsViewModel
import im.vector.app.features.discovery.change.SetIdentityServerViewModel
import im.vector.app.features.home.HomeDetailViewModel
import im.vector.app.features.home.PromoteRestrictedViewModel import im.vector.app.features.home.PromoteRestrictedViewModel
import im.vector.app.features.home.UnknownDeviceDetectorSharedViewModel
import im.vector.app.features.home.UnreadMessagesSharedViewModel
import im.vector.app.features.home.room.breadcrumbs.BreadcrumbsViewModel
import im.vector.app.features.home.room.detail.RoomDetailViewModel
import im.vector.app.features.home.room.detail.composer.TextComposerViewModel
import im.vector.app.features.home.room.detail.search.SearchViewModel
import im.vector.app.features.home.room.detail.timeline.action.MessageActionsViewModel
import im.vector.app.features.home.room.detail.timeline.edithistory.ViewEditHistoryViewModel
import im.vector.app.features.home.room.detail.timeline.reactions.ViewReactionsViewModel import im.vector.app.features.home.room.detail.timeline.reactions.ViewReactionsViewModel
import im.vector.app.features.home.room.detail.upgrade.MigrateRoomViewModel import im.vector.app.features.home.room.detail.upgrade.MigrateRoomViewModel
import im.vector.app.features.home.room.list.RoomListViewModel import im.vector.app.features.home.room.list.RoomListViewModel
import im.vector.app.features.homeserver.HomeServerCapabilitiesViewModel
import im.vector.app.features.invite.InviteUsersToRoomViewModel
import im.vector.app.features.login.LoginViewModel
import im.vector.app.features.login2.LoginViewModel2
import im.vector.app.features.login2.created.AccountCreatedViewModel
import im.vector.app.features.matrixto.MatrixToBottomSheetViewModel
import im.vector.app.features.rageshake.BugReportViewModel
import im.vector.app.features.reactions.EmojiSearchResultViewModel
import im.vector.app.features.room.RequireActiveMembershipViewModel import im.vector.app.features.room.RequireActiveMembershipViewModel
import im.vector.app.features.roomdirectory.RoomDirectoryViewModel import im.vector.app.features.roomdirectory.RoomDirectoryViewModel
import im.vector.app.features.roomdirectory.createroom.CreateRoomViewModel import im.vector.app.features.roomdirectory.createroom.CreateRoomViewModel
@ -391,6 +412,104 @@ interface MavericksViewModelModule {
@MavericksViewModelKey(RequireActiveMembershipViewModel::class) @MavericksViewModelKey(RequireActiveMembershipViewModel::class)
fun requireActiveMembershipViewModelFactory(factory: RequireActiveMembershipViewModel.Factory): MavericksAssistedViewModelFactory<*, *> fun requireActiveMembershipViewModelFactory(factory: RequireActiveMembershipViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(EmojiSearchResultViewModel::class)
fun emojiSearchResultViewModelFactory(factory: EmojiSearchResultViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(BugReportViewModel::class)
fun bugReportViewModelFactory(factory: BugReportViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(MatrixToBottomSheetViewModel::class)
fun matrixToBottomSheetViewModelFactory(factory: MatrixToBottomSheetViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(AccountCreatedViewModel::class)
fun accountCreatedViewModelFactory(factory: AccountCreatedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(LoginViewModel2::class)
fun loginViewModel2Factory(factory: LoginViewModel2.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(LoginViewModel::class)
fun loginViewModelFactory(factory: LoginViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(HomeServerCapabilitiesViewModel::class)
fun homeServerCapabilitiesViewModelFactory(factory: HomeServerCapabilitiesViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(InviteUsersToRoomViewModel::class)
fun inviteUsersToRoomViewModelFactory(factory: InviteUsersToRoomViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(ViewEditHistoryViewModel::class)
fun viewEditHistoryViewModelFactory(factory: ViewEditHistoryViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(MessageActionsViewModel::class)
fun messageActionsViewModelFactory(factory: MessageActionsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(VerificationChooseMethodViewModel::class)
fun verificationChooseMethodViewModelFactory(factory: VerificationChooseMethodViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(VerificationEmojiCodeViewModel::class)
fun verificationEmojiCodeViewModelFactory(factory: VerificationEmojiCodeViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(SearchViewModel::class)
fun searchViewModelFactory(factory: SearchViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(UnreadMessagesSharedViewModel::class)
fun unreadMessagesSharedViewModelFactory(factory: UnreadMessagesSharedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(UnknownDeviceDetectorSharedViewModel::class)
fun unknownDeviceDetectorSharedViewModelFactory(factory: UnknownDeviceDetectorSharedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(DiscoverySettingsViewModel::class)
fun discoverySettingsViewModelFactory(factory: DiscoverySettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(TextComposerViewModel::class)
fun textComposerViewModelFactory(factory: TextComposerViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(SetIdentityServerViewModel::class)
fun setIdentityServerViewModelFactory(factory: SetIdentityServerViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(BreadcrumbsViewModel::class)
fun breadcrumbsViewModelFactory(factory: BreadcrumbsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(HomeDetailViewModel::class)
fun homeDetailViewModelFactory(factory: HomeDetailViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
} }

View File

@ -40,7 +40,6 @@ import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class VerificationChooseMethodFragment @Inject constructor( class VerificationChooseMethodFragment @Inject constructor(
val verificationChooseMethodViewModelFactory: VerificationChooseMethodViewModel.Factory,
val controller: VerificationChooseMethodController val controller: VerificationChooseMethodController
) : VectorBaseFragment<BottomSheetVerificationChildFragmentBinding>(), ) : VectorBaseFragment<BottomSheetVerificationChildFragmentBinding>(),
VerificationChooseMethodController.Listener { VerificationChooseMethodController.Listener {

View File

@ -15,7 +15,6 @@
*/ */
package im.vector.app.features.crypto.verification.choose package im.vector.app.features.crypto.verification.choose
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext import com.airbnb.mvrx.ViewModelContext
@ -23,6 +22,8 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.HasScreenInjector import im.vector.app.core.di.HasScreenInjector
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -50,6 +51,10 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
private val session: Session private val session: Session
) : VectorViewModel<VerificationChooseMethodViewState, EmptyAction, EmptyViewEvents>(initialState), VerificationService.Listener { ) : VectorViewModel<VerificationChooseMethodViewState, EmptyAction, EmptyViewEvents>(initialState), VerificationService.Listener {
init {
session.cryptoService().verificationService().addListener(this)
}
override fun transactionCreated(tx: VerificationTransaction) { override fun transactionCreated(tx: VerificationTransaction) {
transactionUpdated(tx) transactionUpdated(tx)
} }
@ -81,26 +86,13 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
} }
@AssistedFactory @AssistedFactory
interface Factory { interface Factory : MavericksAssistedViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> {
fun create(initialState: VerificationChooseMethodViewState): VerificationChooseMethodViewModel override fun create(initialState: VerificationChooseMethodViewState): VerificationChooseMethodViewModel
} }
init { companion object : MavericksViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> by hiltMavericksViewModelFactory() {
session.cryptoService().verificationService().addListener(this)
}
override fun onCleared() { override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState {
session.cryptoService().verificationService().removeListener(this)
super.onCleared()
}
companion object : MavericksViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> {
override fun create(viewModelContext: ViewModelContext, state: VerificationChooseMethodViewState): VerificationChooseMethodViewModel? {
val fragment: VerificationChooseMethodFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.verificationChooseMethodViewModelFactory.create(state)
}
override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState? {
val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args() val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args()
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession() val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
val verificationService = session.cryptoService().verificationService() val verificationService = session.cryptoService().verificationService()
@ -121,5 +113,10 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
} }
} }
override fun onCleared() {
session.cryptoService().verificationService().removeListener(this)
super.onCleared()
}
override fun handle(action: EmptyAction) {} override fun handle(action: EmptyAction) {}
} }

View File

@ -31,7 +31,6 @@ import im.vector.app.features.crypto.verification.VerificationBottomSheetViewMod
import javax.inject.Inject import javax.inject.Inject
class VerificationEmojiCodeFragment @Inject constructor( class VerificationEmojiCodeFragment @Inject constructor(
val viewModelFactory: VerificationEmojiCodeViewModel.Factory,
val controller: VerificationEmojiCodeController val controller: VerificationEmojiCodeController
) : VectorBaseFragment<BottomSheetVerificationChildFragmentBinding>(), ) : VectorBaseFragment<BottomSheetVerificationChildFragmentBinding>(),
VerificationEmojiCodeController.Listener { VerificationEmojiCodeController.Listener {

View File

@ -28,6 +28,8 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.HasScreenInjector import im.vector.app.core.di.HasScreenInjector
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -151,16 +153,11 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
} }
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<VerificationEmojiCodeViewModel,VerificationEmojiCodeViewState> {
fun create(initialState: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel override fun create(initialState: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel
} }
companion object : MavericksViewModelFactory<VerificationEmojiCodeViewModel, VerificationEmojiCodeViewState> { companion object : MavericksViewModelFactory<VerificationEmojiCodeViewModel, VerificationEmojiCodeViewState> by hiltMavericksViewModelFactory() {
override fun create(viewModelContext: ViewModelContext, state: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel? {
val factory = (viewModelContext as FragmentViewModelContext).fragment<VerificationEmojiCodeFragment>().viewModelFactory
return factory.create(state)
}
override fun initialState(viewModelContext: ViewModelContext): VerificationEmojiCodeViewState? { override fun initialState(viewModelContext: ViewModelContext): VerificationEmojiCodeViewState? {
val args = viewModelContext.args<VerificationBottomSheet.VerificationArgs>() val args = viewModelContext.args<VerificationBottomSheet.VerificationArgs>()

View File

@ -45,8 +45,7 @@ import org.matrix.android.sdk.api.session.terms.TermsService
import javax.inject.Inject import javax.inject.Inject
class DiscoverySettingsFragment @Inject constructor( class DiscoverySettingsFragment @Inject constructor(
private val controller: DiscoverySettingsController, private val controller: DiscoverySettingsController
val viewModelFactory: DiscoverySettingsViewModel.Factory
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(), ) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
DiscoverySettingsController.Listener { DiscoverySettingsController.Listener {

View File

@ -17,16 +17,16 @@ package im.vector.app.features.discovery
import com.airbnb.mvrx.Async import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
@ -49,18 +49,11 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
) : VectorViewModel<DiscoverySettingsState, DiscoverySettingsAction, DiscoverySettingsViewEvents>(initialState) { ) : VectorViewModel<DiscoverySettingsState, DiscoverySettingsAction, DiscoverySettingsViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory : MavericksAssistedViewModelFactory<DiscoverySettingsViewModel, DiscoverySettingsState> {
fun create(initialState: DiscoverySettingsState): DiscoverySettingsViewModel override fun create(initialState: DiscoverySettingsState): DiscoverySettingsViewModel
} }
companion object : MavericksViewModelFactory<DiscoverySettingsViewModel, DiscoverySettingsState> { companion object : MavericksViewModelFactory<DiscoverySettingsViewModel, DiscoverySettingsState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: DiscoverySettingsState): DiscoverySettingsViewModel? {
val fragment: DiscoverySettingsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
private val identityService = session.identityService() private val identityService = session.identityService()
private val termsService: TermsService = session private val termsService: TermsService = session

View File

@ -41,7 +41,6 @@ import org.matrix.android.sdk.api.session.terms.TermsService
import javax.inject.Inject import javax.inject.Inject
class SetIdentityServerFragment @Inject constructor( class SetIdentityServerFragment @Inject constructor(
val viewModelFactory: SetIdentityServerViewModel.Factory,
val colorProvider: ColorProvider val colorProvider: ColorProvider
) : VectorBaseFragment<FragmentSetIdentityServerBinding>() { ) : VectorBaseFragment<FragmentSetIdentityServerBinding>() {

View File

@ -15,8 +15,6 @@
*/ */
package im.vector.app.features.discovery.change package im.vector.app.features.discovery.change
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
@ -24,6 +22,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.HasScreenInjector import im.vector.app.core.di.HasScreenInjector
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
@ -42,26 +42,20 @@ class SetIdentityServerViewModel @AssistedInject constructor(
VectorViewModel<SetIdentityServerState, SetIdentityServerAction, SetIdentityServerViewEvents>(initialState) { VectorViewModel<SetIdentityServerState, SetIdentityServerAction, SetIdentityServerViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<SetIdentityServerViewModel,SetIdentityServerState> {
fun create(initialState: SetIdentityServerState): SetIdentityServerViewModel override fun create(initialState: SetIdentityServerState): SetIdentityServerViewModel
} }
companion object : MavericksViewModelFactory<SetIdentityServerViewModel, SetIdentityServerState> { companion object : MavericksViewModelFactory<SetIdentityServerViewModel, SetIdentityServerState> by hiltMavericksViewModelFactory() {
override fun initialState(viewModelContext: ViewModelContext): SetIdentityServerState? { override fun initialState(viewModelContext: ViewModelContext): SetIdentityServerState {
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession() val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
return SetIdentityServerState( return SetIdentityServerState(
homeServerUrl = session.sessionParams.homeServerUrl, homeServerUrl = session.sessionParams.homeServerUrl,
defaultIdentityServerUrl = session.identityService().getDefaultIdentityServer() defaultIdentityServerUrl = session.identityService().getDefaultIdentityServer()
) )
} }
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: SetIdentityServerState): SetIdentityServerViewModel? {
val fragment: SetIdentityServerFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
} }
var currentWantedUrl: String? = null var currentWantedUrl: String? = null

View File

@ -94,8 +94,6 @@ data class HomeActivityArgs(
class HomeActivity : class HomeActivity :
VectorBaseActivity<ActivityHomeBinding>(), VectorBaseActivity<ActivityHomeBinding>(),
ToolbarConfigurable, ToolbarConfigurable,
UnknownDeviceDetectorSharedViewModel.Factory,
UnreadMessagesSharedViewModel.Factory,
NavigationInterceptor, NavigationInterceptor,
SpaceInviteBottomSheet.InteractionListener, SpaceInviteBottomSheet.InteractionListener,
MatrixToBottomSheet.InteractionListener { MatrixToBottomSheet.InteractionListener {
@ -115,8 +113,6 @@ class HomeActivity :
@Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var vectorPreferences: VectorPreferences
@Inject lateinit var popupAlertManager: PopupAlertManager @Inject lateinit var popupAlertManager: PopupAlertManager
@Inject lateinit var shortcutsHandler: ShortcutsHandler @Inject lateinit var shortcutsHandler: ShortcutsHandler
@Inject lateinit var unknownDeviceViewModelFactory: UnknownDeviceDetectorSharedViewModel.Factory
@Inject lateinit var unreadMessagesSharedViewModelFactory: UnreadMessagesSharedViewModel.Factory
@Inject lateinit var permalinkHandler: PermalinkHandler @Inject lateinit var permalinkHandler: PermalinkHandler
@Inject lateinit var avatarRenderer: AvatarRenderer @Inject lateinit var avatarRenderer: AvatarRenderer
@Inject lateinit var initSyncStepFormatter: InitSyncStepFormatter @Inject lateinit var initSyncStepFormatter: InitSyncStepFormatter
@ -175,14 +171,6 @@ class HomeActivity :
injector.inject(this) injector.inject(this)
} }
override fun create(initialState: UnknownDevicesState): UnknownDeviceDetectorSharedViewModel {
return unknownDeviceViewModelFactory.create(initialState)
}
override fun create(initialState: UnreadMessagesState): UnreadMessagesSharedViewModel {
return unreadMessagesSharedViewModelFactory.create(initialState)
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)

View File

@ -64,7 +64,6 @@ import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
import javax.inject.Inject import javax.inject.Inject
class HomeDetailFragment @Inject constructor( class HomeDetailFragment @Inject constructor(
val homeDetailViewModelFactory: HomeDetailViewModel.Factory,
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val colorProvider: ColorProvider, private val colorProvider: ColorProvider,
private val alertManager: PopupAlertManager, private val alertManager: PopupAlertManager,

View File

@ -26,6 +26,8 @@ import dagger.assisted.AssistedInject
import im.vector.app.AppStateHandler import im.vector.app.AppStateHandler
import im.vector.app.RoomGroupingMethod import im.vector.app.RoomGroupingMethod
import im.vector.app.core.di.HasScreenInjector import im.vector.app.core.di.HasScreenInjector
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.core.platform.VectorViewModel
import im.vector.app.features.call.dialpad.DialPadLookup import im.vector.app.features.call.dialpad.DialPadLookup
import im.vector.app.features.call.lookup.CallProtocolsChecker import im.vector.app.features.call.lookup.CallProtocolsChecker
@ -69,24 +71,18 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
CallProtocolsChecker.Listener { CallProtocolsChecker.Listener {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<HomeDetailViewModel,HomeDetailViewState> {
fun create(initialState: HomeDetailViewState): HomeDetailViewModel override fun create(initialState: HomeDetailViewState): HomeDetailViewModel
} }
companion object : MavericksViewModelFactory<HomeDetailViewModel, HomeDetailViewState> { companion object : MavericksViewModelFactory<HomeDetailViewModel, HomeDetailViewState> by hiltMavericksViewModelFactory(){
override fun initialState(viewModelContext: ViewModelContext): HomeDetailViewState? { override fun initialState(viewModelContext: ViewModelContext): HomeDetailViewState {
val uiStateRepository = (viewModelContext.activity as HasScreenInjector).injector().uiStateRepository() val uiStateRepository = (viewModelContext.activity as HasScreenInjector).injector().uiStateRepository()
return HomeDetailViewState( return HomeDetailViewState(
currentTab = HomeTab.RoomList(uiStateRepository.getDisplayMode()) currentTab = HomeTab.RoomList(uiStateRepository.getDisplayMode())
) )
} }
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: HomeDetailViewState): HomeDetailViewModel? {
val fragment: HomeDetailFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.homeDetailViewModelFactory.create(state)
}
} }
init { init {

View File

@ -16,17 +16,16 @@
package im.vector.app.features.home package im.vector.app.features.home
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.Async import com.airbnb.mvrx.Async
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.platform.VectorViewModelAction import im.vector.app.core.platform.VectorViewModelAction
@ -66,21 +65,11 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(@Assisted
} }
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<UnknownDeviceDetectorSharedViewModel,UnknownDevicesState> {
fun create(initialState: UnknownDevicesState): UnknownDeviceDetectorSharedViewModel override fun create(initialState: UnknownDevicesState): UnknownDeviceDetectorSharedViewModel
} }
companion object : MavericksViewModelFactory<UnknownDeviceDetectorSharedViewModel, UnknownDevicesState> { companion object : MavericksViewModelFactory<UnknownDeviceDetectorSharedViewModel, UnknownDevicesState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: UnknownDevicesState): UnknownDeviceDetectorSharedViewModel? {
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")
}
}
private val ignoredDeviceList = ArrayList<String>() private val ignoredDeviceList = ArrayList<String>()

View File

@ -16,16 +16,15 @@
package im.vector.app.features.home package im.vector.app.features.home
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.AppStateHandler import im.vector.app.AppStateHandler
import im.vector.app.RoomGroupingMethod 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.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -61,21 +60,11 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) { VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<UnreadMessagesSharedViewModel,UnreadMessagesState> {
fun create(initialState: UnreadMessagesState): UnreadMessagesSharedViewModel override fun create(initialState: UnreadMessagesState): UnreadMessagesSharedViewModel
} }
companion object : MavericksViewModelFactory<UnreadMessagesSharedViewModel, UnreadMessagesState> { companion object : MavericksViewModelFactory<UnreadMessagesSharedViewModel, UnreadMessagesState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: UnreadMessagesState): UnreadMessagesSharedViewModel? {
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")
}
}
override fun handle(action: EmptyAction) {} override fun handle(action: EmptyAction) {}

View File

@ -31,8 +31,7 @@ import im.vector.app.features.home.room.detail.RoomDetailSharedActionViewModel
import javax.inject.Inject import javax.inject.Inject
class BreadcrumbsFragment @Inject constructor( class BreadcrumbsFragment @Inject constructor(
private val breadcrumbsController: BreadcrumbsController, private val breadcrumbsController: BreadcrumbsController
val breadcrumbsViewModelFactory: BreadcrumbsViewModel.Factory
) : VectorBaseFragment<FragmentBreadcrumbsBinding>(), ) : VectorBaseFragment<FragmentBreadcrumbsBinding>(),
BreadcrumbsController.Listener { BreadcrumbsController.Listener {

View File

@ -22,6 +22,8 @@ import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -33,21 +35,14 @@ import org.matrix.android.sdk.flow.flow
class BreadcrumbsViewModel @AssistedInject constructor(@Assisted initialState: BreadcrumbsViewState, class BreadcrumbsViewModel @AssistedInject constructor(@Assisted initialState: BreadcrumbsViewState,
private val session: Session) : private val session: Session) :
VectorViewModel<BreadcrumbsViewState, EmptyAction, EmptyViewEvents>(initialState) { VectorViewModel<BreadcrumbsViewState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory : MavericksAssistedViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> {
fun create(initialState: BreadcrumbsViewState): BreadcrumbsViewModel override fun create(initialState: BreadcrumbsViewState): BreadcrumbsViewModel
} }
companion object : MavericksViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> { companion object : MavericksViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: BreadcrumbsViewState): BreadcrumbsViewModel? {
val fragment: BreadcrumbsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.breadcrumbsViewModelFactory.create(state)
}
}
init { init {
observeBreadcrumbs() observeBreadcrumbs()

View File

@ -237,7 +237,6 @@ class RoomDetailFragment @Inject constructor(
private val permalinkHandler: PermalinkHandler, private val permalinkHandler: PermalinkHandler,
private val notificationDrawerManager: NotificationDrawerManager, private val notificationDrawerManager: NotificationDrawerManager,
val roomDetailViewModelFactory: RoomDetailViewModel.Factory, val roomDetailViewModelFactory: RoomDetailViewModel.Factory,
val textComposerViewModelFactory: TextComposerViewModel.Factory,
private val eventHtmlRenderer: EventHtmlRenderer, private val eventHtmlRenderer: EventHtmlRenderer,
private val vectorPreferences: VectorPreferences, private val vectorPreferences: VectorPreferences,
private val colorProvider: ColorProvider, private val colorProvider: ColorProvider,

View File

@ -23,6 +23,8 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
@ -703,16 +705,9 @@ class TextComposerViewModel @AssistedInject constructor(
} }
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<TextComposerViewModel,TextComposerViewState> {
fun create(initialState: TextComposerViewState): TextComposerViewModel override fun create(initialState: TextComposerViewState): TextComposerViewModel
} }
companion object : MavericksViewModelFactory<TextComposerViewModel, TextComposerViewState> { companion object : MavericksViewModelFactory<TextComposerViewModel, TextComposerViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: TextComposerViewState): TextComposerViewModel {
val fragment: RoomDetailFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.textComposerViewModelFactory.create(state)
}
}
} }

View File

@ -47,7 +47,6 @@ data class SearchArgs(
) : Parcelable ) : Parcelable
class SearchFragment @Inject constructor( class SearchFragment @Inject constructor(
val viewModelFactory: SearchViewModel.Factory,
private val controller: SearchResultController private val controller: SearchResultController
) : VectorBaseFragment<FragmentSearchBinding>(), ) : VectorBaseFragment<FragmentSearchBinding>(),
StateView.EventCallback, StateView.EventCallback,

View File

@ -16,16 +16,15 @@
package im.vector.app.features.home.room.detail.search package im.vector.app.features.home.room.detail.search
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject 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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
@ -46,18 +45,11 @@ class SearchViewModel @AssistedInject constructor(
private var nextBatch: String? = null private var nextBatch: String? = null
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<SearchViewModel,SearchViewState> {
fun create(initialState: SearchViewState): SearchViewModel override fun create(initialState: SearchViewState): SearchViewModel
} }
companion object : MavericksViewModelFactory<SearchViewModel, SearchViewState> { companion object : MavericksViewModelFactory<SearchViewModel, SearchViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: SearchViewState): SearchViewModel? {
val fragment: SearchFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
override fun handle(action: SearchAction) { override fun handle(action: SearchAction) {
when (action) { when (action) {

View File

@ -36,7 +36,6 @@ class MessageActionsBottomSheet :
VectorBaseBottomSheetDialogFragment<BottomSheetGenericListBinding>(), VectorBaseBottomSheetDialogFragment<BottomSheetGenericListBinding>(),
MessageActionsEpoxyController.MessageActionsEpoxyControllerListener { MessageActionsEpoxyController.MessageActionsEpoxyControllerListener {
@Inject lateinit var messageActionViewModelFactory: MessageActionsViewModel.Factory
@Inject lateinit var messageActionsEpoxyController: MessageActionsEpoxyController @Inject lateinit var messageActionsEpoxyController: MessageActionsEpoxyController
private val viewModel: MessageActionsViewModel by fragmentViewModel(MessageActionsViewModel::class) private val viewModel: MessageActionsViewModel by fragmentViewModel(MessageActionsViewModel::class)

View File

@ -15,14 +15,14 @@
*/ */
package im.vector.app.features.home.room.detail.timeline.action package im.vector.app.features.home.room.detail.timeline.action
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.Lazy import dagger.Lazy
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.extensions.canReact import im.vector.app.core.extensions.canReact
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
@ -85,17 +85,11 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
private val eventIdFlow = MutableStateFlow(initialState.eventId) private val eventIdFlow = MutableStateFlow(initialState.eventId)
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<MessageActionsViewModel,MessageActionState> {
fun create(initialState: MessageActionState): MessageActionsViewModel override fun create(initialState: MessageActionState): MessageActionsViewModel
} }
companion object : MavericksViewModelFactory<MessageActionsViewModel, MessageActionState> { companion object : MavericksViewModelFactory<MessageActionsViewModel, MessageActionState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: MessageActionState): MessageActionsViewModel? {
val fragment: MessageActionsBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.messageActionViewModelFactory.create(state)
}
}
init { init {
observeEvent() observeEvent()

View File

@ -40,7 +40,6 @@ class ViewEditHistoryBottomSheet :
private val viewModel: ViewEditHistoryViewModel by fragmentViewModel(ViewEditHistoryViewModel::class) private val viewModel: ViewEditHistoryViewModel by fragmentViewModel(ViewEditHistoryViewModel::class)
@Inject lateinit var viewEditHistoryViewModelFactory: ViewEditHistoryViewModel.Factory
@Inject lateinit var epoxyController: ViewEditHistoryEpoxyController @Inject lateinit var epoxyController: ViewEditHistoryEpoxyController
override fun injectWith(injector: ScreenComponent) { override fun injectWith(injector: ScreenComponent) {

View File

@ -15,16 +15,15 @@
*/ */
package im.vector.app.features.home.room.detail.timeline.edithistory package im.vector.app.features.home.room.detail.timeline.edithistory
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -47,18 +46,11 @@ class ViewEditHistoryViewModel @AssistedInject constructor(
?: throw IllegalStateException("Shouldn't use this ViewModel without a room") ?: throw IllegalStateException("Shouldn't use this ViewModel without a room")
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<ViewEditHistoryViewModel,ViewEditHistoryViewState> {
fun create(initialState: ViewEditHistoryViewState): ViewEditHistoryViewModel override fun create(initialState: ViewEditHistoryViewState): ViewEditHistoryViewModel
} }
companion object : MavericksViewModelFactory<ViewEditHistoryViewModel, ViewEditHistoryViewState> { companion object : MavericksViewModelFactory<ViewEditHistoryViewModel, ViewEditHistoryViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: ViewEditHistoryViewState): ViewEditHistoryViewModel? {
val fragment: ViewEditHistoryBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewEditHistoryViewModelFactory.create(state)
}
}
init { init {
loadHistory() loadHistory()

View File

@ -16,20 +16,19 @@
package im.vector.app.features.homeserver package im.vector.app.features.homeserver
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.HasScreenInjector import im.vector.app.core.di.HasScreenInjector
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.getElementWellknown
import im.vector.app.features.raw.wellknown.isE2EByDefault import im.vector.app.features.raw.wellknown.isE2EByDefault
import im.vector.app.features.userdirectory.UserListFragment
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
@ -44,18 +43,13 @@ class HomeServerCapabilitiesViewModel @AssistedInject constructor(
) : VectorViewModel<HomeServerCapabilitiesViewState, EmptyAction, EmptyViewEvents>(initialState) { ) : VectorViewModel<HomeServerCapabilitiesViewState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<HomeServerCapabilitiesViewModel,HomeServerCapabilitiesViewState> {
fun create(initialState: HomeServerCapabilitiesViewState): HomeServerCapabilitiesViewModel override fun create(initialState: HomeServerCapabilitiesViewState): HomeServerCapabilitiesViewModel
} }
companion object : MavericksViewModelFactory<HomeServerCapabilitiesViewModel, HomeServerCapabilitiesViewState> { companion object : MavericksViewModelFactory<HomeServerCapabilitiesViewModel, HomeServerCapabilitiesViewState> by hiltMavericksViewModelFactory() {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: HomeServerCapabilitiesViewState): HomeServerCapabilitiesViewModel? {
val fragment: UserListFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.homeServerCapabilitiesViewModelFactory.create(state)
}
override fun initialState(viewModelContext: ViewModelContext): HomeServerCapabilitiesViewState? { override fun initialState(viewModelContext: ViewModelContext): HomeServerCapabilitiesViewState {
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getSafeActiveSession() val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getSafeActiveSession()
return HomeServerCapabilitiesViewState( return HomeServerCapabilitiesViewState(
capabilities = session?.getHomeServerCapabilities() ?: HomeServerCapabilities() capabilities = session?.getHomeServerCapabilities() ?: HomeServerCapabilities()
@ -64,6 +58,7 @@ class HomeServerCapabilitiesViewModel @AssistedInject constructor(
} }
init { init {
initAdminE2eByDefault() initAdminE2eByDefault()
} }

View File

@ -53,11 +53,10 @@ import javax.inject.Inject
@Parcelize @Parcelize
data class InviteUsersToRoomArgs(val roomId: String) : Parcelable data class InviteUsersToRoomArgs(val roomId: String) : Parcelable
class InviteUsersToRoomActivity : SimpleFragmentActivity(), InviteUsersToRoomViewModel.Factory { class InviteUsersToRoomActivity : SimpleFragmentActivity() {
private val viewModel: InviteUsersToRoomViewModel by viewModel() private val viewModel: InviteUsersToRoomViewModel by viewModel()
private lateinit var sharedActionViewModel: UserListSharedActionViewModel private lateinit var sharedActionViewModel: UserListSharedActionViewModel
@Inject lateinit var inviteUsersToRoomViewModelFactory: InviteUsersToRoomViewModel.Factory
@Inject lateinit var errorFormatter: ErrorFormatter @Inject lateinit var errorFormatter: ErrorFormatter
override fun injectWith(injector: ScreenComponent) { override fun injectWith(injector: ScreenComponent) {
@ -65,8 +64,6 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity(), InviteUsersToRoomVie
injector.inject(this) injector.inject(this)
} }
override fun create(initialState: InviteUsersToRoomViewState) = inviteUsersToRoomViewModelFactory.create(initialState)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -16,14 +16,13 @@
package im.vector.app.features.invite package im.vector.app.features.invite
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
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.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
import im.vector.app.features.userdirectory.PendingSelection import im.vector.app.features.userdirectory.PendingSelection
@ -43,21 +42,11 @@ class InviteUsersToRoomViewModel @AssistedInject constructor(@Assisted
private val room = session.getRoom(initialState.roomId)!! private val room = session.getRoom(initialState.roomId)!!
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<InviteUsersToRoomViewModel,InviteUsersToRoomViewState> {
fun create(initialState: InviteUsersToRoomViewState): InviteUsersToRoomViewModel override fun create(initialState: InviteUsersToRoomViewState): InviteUsersToRoomViewModel
} }
companion object : MavericksViewModelFactory<InviteUsersToRoomViewModel, InviteUsersToRoomViewState> { companion object : MavericksViewModelFactory<InviteUsersToRoomViewModel, InviteUsersToRoomViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: InviteUsersToRoomViewState): InviteUsersToRoomViewModel? {
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")
}
}
override fun handle(action: InviteUsersToRoomAction) { override fun handle(action: InviteUsersToRoomAction) {
when (action) { when (action) {

View File

@ -57,8 +57,6 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), ToolbarCo
private val loginViewModel: LoginViewModel by viewModel() private val loginViewModel: LoginViewModel by viewModel()
@Inject lateinit var loginViewModelFactory: LoginViewModel.Factory
@CallSuper @CallSuper
override fun injectWith(injector: ScreenComponent) { override fun injectWith(injector: ScreenComponent) {
injector.inject(this) injector.inject(this)

View File

@ -32,6 +32,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.configureAndStart import im.vector.app.core.extensions.configureAndStart
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -72,10 +74,12 @@ class LoginViewModel @AssistedInject constructor(
) : VectorViewModel<LoginViewState, LoginAction, LoginViewEvents>(initialState) { ) : VectorViewModel<LoginViewState, LoginAction, LoginViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory:MavericksAssistedViewModelFactory<LoginViewModel,LoginViewState> {
fun create(initialState: LoginViewState): LoginViewModel override fun create(initialState: LoginViewState): LoginViewModel
} }
companion object : MavericksViewModelFactory<LoginViewModel, LoginViewState> by hiltMavericksViewModelFactory()
init { init {
getKnownCustomHomeServersUrls() getKnownCustomHomeServersUrls()
} }
@ -86,18 +90,6 @@ class LoginViewModel @AssistedInject constructor(
} }
} }
companion object : MavericksViewModelFactory<LoginViewModel, LoginViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: LoginViewState): LoginViewModel? {
return when (val activity: FragmentActivity = (viewModelContext as ActivityViewModelContext).activity()) {
is LoginActivity -> activity.loginViewModelFactory.create(state)
is SoftLogoutActivity -> activity.loginViewModelFactory.create(state)
else -> error("Invalid Activity")
}
}
}
// Store the last action, to redo it after user has trusted the untrusted certificate // Store the last action, to redo it after user has trusted the untrusted certificate
private var lastAction: LoginAction? = null private var lastAction: LoginAction? = null
private var currentHomeServerConnectionConfig: HomeServerConnectionConfig? = null private var currentHomeServerConnectionConfig: HomeServerConnectionConfig? = null

View File

@ -64,8 +64,6 @@ open class LoginActivity2 : VectorBaseActivity<ActivityLoginBinding>(), ToolbarC
private val loginViewModel: LoginViewModel2 by viewModel() private val loginViewModel: LoginViewModel2 by viewModel()
@Inject lateinit var loginViewModelFactory: LoginViewModel2.Factory
@CallSuper @CallSuper
override fun injectWith(injector: ScreenComponent) { override fun injectWith(injector: ScreenComponent) {
injector.inject(this) injector.inject(this)

View File

@ -29,6 +29,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.configureAndStart import im.vector.app.core.extensions.configureAndStart
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.tryAsync import im.vector.app.core.extensions.tryAsync
@ -72,10 +74,12 @@ class LoginViewModel2 @AssistedInject constructor(
) : VectorViewModel<LoginViewState2, LoginAction2, LoginViewEvents2>(initialState) { ) : VectorViewModel<LoginViewState2, LoginAction2, LoginViewEvents2>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<LoginViewModel2,LoginViewState2> {
fun create(initialState: LoginViewState2): LoginViewModel2 override fun create(initialState: LoginViewState2): LoginViewModel2
} }
companion object : MavericksViewModelFactory<LoginViewModel2, LoginViewState2> by hiltMavericksViewModelFactory()
init { init {
getKnownCustomHomeServersUrls() getKnownCustomHomeServersUrls()
} }
@ -86,18 +90,6 @@ class LoginViewModel2 @AssistedInject constructor(
} }
} }
companion object : MavericksViewModelFactory<LoginViewModel2, LoginViewState2> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: LoginViewState2): LoginViewModel2? {
return when (val activity: FragmentActivity = (viewModelContext as ActivityViewModelContext).activity()) {
is LoginActivity2 -> activity.loginViewModelFactory.create(state)
// TODO is SoftLogoutActivity -> activity.loginViewModelFactory.create(state)
else -> error("Invalid Activity")
}
}
}
// Store the last action, to redo it after user has trusted the untrusted certificate // Store the last action, to redo it after user has trusted the untrusted certificate
private var lastAction: LoginAction2? = null private var lastAction: LoginAction2? = null
private var currentHomeServerConnectionConfig: HomeServerConnectionConfig? = null private var currentHomeServerConnectionConfig: HomeServerConnectionConfig? = null

View File

@ -49,7 +49,6 @@ import javax.inject.Inject
* - the account has been created and we propose the user to set an avatar and a display name * - the account has been created and we propose the user to set an avatar and a display name
*/ */
class AccountCreatedFragment @Inject constructor( class AccountCreatedFragment @Inject constructor(
val accountCreatedViewModelFactory: AccountCreatedViewModel.Factory,
private val avatarRenderer: AvatarRenderer, private val avatarRenderer: AvatarRenderer,
private val dateFormatter: VectorDateFormatter, private val dateFormatter: VectorDateFormatter,
private val matrixItemColorProvider: MatrixItemColorProvider, private val matrixItemColorProvider: MatrixItemColorProvider,

View File

@ -16,13 +16,12 @@
package im.vector.app.features.login2.created package im.vector.app.features.login2.created
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject 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.core.platform.VectorViewModel
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -40,18 +39,11 @@ class AccountCreatedViewModel @AssistedInject constructor(
) : VectorViewModel<AccountCreatedViewState, AccountCreatedAction, AccountCreatedViewEvents>(initialState) { ) : VectorViewModel<AccountCreatedViewState, AccountCreatedAction, AccountCreatedViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<AccountCreatedViewModel,AccountCreatedViewState> {
fun create(initialState: AccountCreatedViewState): AccountCreatedViewModel override fun create(initialState: AccountCreatedViewState): AccountCreatedViewModel
} }
companion object : MavericksViewModelFactory<AccountCreatedViewModel, AccountCreatedViewState> { companion object : MavericksViewModelFactory<AccountCreatedViewModel, AccountCreatedViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: AccountCreatedViewState): AccountCreatedViewModel? {
val fragment: AccountCreatedFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.accountCreatedViewModelFactory.create(state)
}
}
init { init {
setState { setState {

View File

@ -49,9 +49,6 @@ class MatrixToBottomSheet :
@Inject lateinit var avatarRenderer: AvatarRenderer @Inject lateinit var avatarRenderer: AvatarRenderer
@Inject
lateinit var matrixToBottomSheetViewModelFactory: MatrixToBottomSheetViewModel.Factory
override fun injectWith(injector: ScreenComponent) { override fun injectWith(injector: ScreenComponent) {
injector.inject(this) injector.inject(this)
} }

View File

@ -16,18 +16,17 @@
package im.vector.app.features.matrixto package im.vector.app.features.matrixto
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -54,10 +53,12 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
VectorViewModel<MatrixToBottomSheetState, MatrixToAction, MatrixToViewEvents>(initialState) { VectorViewModel<MatrixToBottomSheetState, MatrixToAction, MatrixToViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<MatrixToBottomSheetViewModel,MatrixToBottomSheetState> {
fun create(initialState: MatrixToBottomSheetState): MatrixToBottomSheetViewModel override fun create(initialState: MatrixToBottomSheetState): MatrixToBottomSheetViewModel
} }
companion object : MavericksViewModelFactory<MatrixToBottomSheetViewModel, MatrixToBottomSheetState> by hiltMavericksViewModelFactory()
init { init {
when (initialState.linkType) { when (initialState.linkType) {
is PermalinkData.RoomLink -> { is PermalinkData.RoomLink -> {
@ -245,14 +246,6 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
return session.peekRoom(roomIdOrAlias) return session.peekRoom(roomIdOrAlias)
} }
companion object : MavericksViewModelFactory<MatrixToBottomSheetViewModel, MatrixToBottomSheetState> {
override fun create(viewModelContext: ViewModelContext, state: MatrixToBottomSheetState): MatrixToBottomSheetViewModel? {
val fragment: MatrixToBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.matrixToBottomSheetViewModelFactory.create(state)
}
}
override fun handle(action: MatrixToAction) { override fun handle(action: MatrixToAction) {
when (action) { when (action) {
is MatrixToAction.StartChattingWithUser -> handleStartChatting(action) is MatrixToAction.StartChattingWithUser -> handleStartChatting(action)

View File

@ -44,8 +44,6 @@ class BugReportActivity : VectorBaseActivity<ActivityBugReportBinding>() {
override fun getBinding() = ActivityBugReportBinding.inflate(layoutInflater) override fun getBinding() = ActivityBugReportBinding.inflate(layoutInflater)
@Inject lateinit var bugReportViewModelFactory: BugReportViewModel.Factory
private val viewModel: BugReportViewModel by viewModel() private val viewModel: BugReportViewModel by viewModel()
private var reportType: ReportType = ReportType.BUG_REPORT private var reportType: ReportType = ReportType.BUG_REPORT

View File

@ -16,14 +16,13 @@
package im.vector.app.features.rageshake package im.vector.app.features.rageshake
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
@ -36,18 +35,11 @@ class BugReportViewModel @AssistedInject constructor(
) : VectorViewModel<BugReportState, EmptyAction, EmptyViewEvents>(initialState) { ) : VectorViewModel<BugReportState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<BugReportViewModel,BugReportState> {
fun create(initialState: BugReportState): BugReportViewModel override fun create(initialState: BugReportState): BugReportViewModel
} }
companion object : MavericksViewModelFactory<BugReportViewModel, BugReportState> { companion object : MavericksViewModelFactory<BugReportViewModel, BugReportState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: BugReportState): BugReportViewModel? {
val activity: BugReportActivity = (viewModelContext as ActivityViewModelContext).activity()
return activity.bugReportViewModelFactory.create(state)
}
}
init { init {
fetchHomeserverVersion() fetchHomeserverVersion()

View File

@ -60,7 +60,6 @@ class EmojiReactionPickerActivity : VectorBaseActivity<ActivityEmojiReactionPick
override fun getTitleRes() = R.string.title_activity_emoji_reaction_picker override fun getTitleRes() = R.string.title_activity_emoji_reaction_picker
@Inject lateinit var emojiSearchResultViewModelFactory: EmojiSearchResultViewModel.Factory
@Inject lateinit var emojiCompatFontProvider: EmojiCompatFontProvider @Inject lateinit var emojiCompatFontProvider: EmojiCompatFontProvider
@Inject lateinit var emojiDataSource: EmojiDataSource @Inject lateinit var emojiDataSource: EmojiDataSource

View File

@ -15,14 +15,13 @@
*/ */
package im.vector.app.features.reactions package im.vector.app.features.reactions
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.MavericksState import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.reactions.data.EmojiDataSource import im.vector.app.features.reactions.data.EmojiDataSource
@ -40,18 +39,11 @@ class EmojiSearchResultViewModel @AssistedInject constructor(
VectorViewModel<EmojiSearchResultViewState, EmojiSearchAction, EmptyViewEvents>(initialState) { VectorViewModel<EmojiSearchResultViewState, EmojiSearchAction, EmptyViewEvents>(initialState) {
@AssistedFactory @AssistedFactory
interface Factory { interface Factory: MavericksAssistedViewModelFactory<EmojiSearchResultViewModel,EmojiSearchResultViewState> {
fun create(initialState: EmojiSearchResultViewState): EmojiSearchResultViewModel override fun create(initialState: EmojiSearchResultViewState): EmojiSearchResultViewModel
} }
companion object : MavericksViewModelFactory<EmojiSearchResultViewModel, EmojiSearchResultViewState> { companion object : MavericksViewModelFactory<EmojiSearchResultViewModel, EmojiSearchResultViewState> by hiltMavericksViewModelFactory()
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: EmojiSearchResultViewState): EmojiSearchResultViewModel? {
val activity: EmojiReactionPickerActivity = (viewModelContext as ActivityViewModelContext).activity()
return activity.emojiSearchResultViewModelFactory.create(state)
}
}
override fun handle(action: EmojiSearchAction) { override fun handle(action: EmojiSearchAction) {
when (action) { when (action) {

View File

@ -42,20 +42,14 @@ import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject import javax.inject.Inject
class RoomMemberListFragment @Inject constructor( class RoomMemberListFragment @Inject constructor(
val viewModelFactory: RoomMemberListViewModel.Factory,
private val roomMemberListController: RoomMemberListController, private val roomMemberListController: RoomMemberListController,
private val avatarRenderer: AvatarRenderer private val avatarRenderer: AvatarRenderer
) : VectorBaseFragment<FragmentRoomMemberListBinding>(), ) : VectorBaseFragment<FragmentRoomMemberListBinding>(),
RoomMemberListController.Callback, RoomMemberListController.Callback {
RoomMemberListViewModel.Factory {
private val viewModel: RoomMemberListViewModel by fragmentViewModel() private val viewModel: RoomMemberListViewModel by fragmentViewModel()
private val roomProfileArgs: RoomProfileArgs by args() private val roomProfileArgs: RoomProfileArgs by args()
override fun create(initialState: RoomMemberListViewState): RoomMemberListViewModel {
return viewModelFactory.create(initialState)
}
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomMemberListBinding { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomMemberListBinding {
return FragmentRoomMemberListBinding.inflate(inflater, container, false) return FragmentRoomMemberListBinding.inflate(inflater, container, false)
} }

View File

@ -52,7 +52,6 @@ import java.util.UUID
import javax.inject.Inject import javax.inject.Inject
class RoomSettingsFragment @Inject constructor( class RoomSettingsFragment @Inject constructor(
val viewModelFactory: RoomSettingsViewModel.Factory,
private val controller: RoomSettingsController, private val controller: RoomSettingsController,
colorProvider: ColorProvider, colorProvider: ColorProvider,
private val avatarRenderer: AvatarRenderer private val avatarRenderer: AvatarRenderer
@ -60,8 +59,7 @@ class RoomSettingsFragment @Inject constructor(
VectorBaseFragment<FragmentRoomSettingGenericBinding>(), VectorBaseFragment<FragmentRoomSettingGenericBinding>(),
RoomSettingsController.Callback, RoomSettingsController.Callback,
OnBackPressed, OnBackPressed,
GalleryOrCameraDialogHelper.Listener, GalleryOrCameraDialogHelper.Listener {
RoomSettingsViewModel.Factory {
private val viewModel: RoomSettingsViewModel by fragmentViewModel() private val viewModel: RoomSettingsViewModel by fragmentViewModel()
private lateinit var roomProfileSharedActionViewModel: RoomProfileSharedActionViewModel private lateinit var roomProfileSharedActionViewModel: RoomProfileSharedActionViewModel
@ -77,10 +75,6 @@ class RoomSettingsFragment @Inject constructor(
override fun getMenuRes() = R.menu.vector_room_settings override fun getMenuRes() = R.menu.vector_room_settings
override fun create(initialState: RoomSettingsViewState): RoomSettingsViewModel {
return viewModelFactory.create(initialState)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
roomProfileSharedActionViewModel = activityViewModelProvider.get(RoomProfileSharedActionViewModel::class.java) roomProfileSharedActionViewModel = activityViewModelProvider.get(RoomProfileSharedActionViewModel::class.java)

View File

@ -52,7 +52,6 @@ import javax.inject.Inject
class UserListFragment @Inject constructor( class UserListFragment @Inject constructor(
private val userListController: UserListController, private val userListController: UserListController,
private val dimensionConverter: DimensionConverter, private val dimensionConverter: DimensionConverter,
val homeServerCapabilitiesViewModelFactory: HomeServerCapabilitiesViewModel.Factory
) : VectorBaseFragment<FragmentUserListBinding>(), ) : VectorBaseFragment<FragmentUserListBinding>(),
UserListController.Callback { UserListController.Callback {