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.crypto.keysbackup.settings.KeysBackupSettingsViewModel
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.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.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.upgrade.MigrateRoomViewModel
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.roomdirectory.RoomDirectoryViewModel
import im.vector.app.features.roomdirectory.createroom.CreateRoomViewModel
@ -391,6 +412,104 @@ interface MavericksViewModelModule {
@MavericksViewModelKey(RequireActiveMembershipViewModel::class)
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
class VerificationChooseMethodFragment @Inject constructor(
val verificationChooseMethodViewModelFactory: VerificationChooseMethodViewModel.Factory,
val controller: VerificationChooseMethodController
) : VectorBaseFragment<BottomSheetVerificationChildFragmentBinding>(),
VerificationChooseMethodController.Listener {

View File

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

View File

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

View File

@ -28,6 +28,8 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
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.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -151,16 +153,11 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
}
@AssistedFactory
interface Factory {
fun create(initialState: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel
interface Factory: MavericksAssistedViewModelFactory<VerificationEmojiCodeViewModel,VerificationEmojiCodeViewState> {
override fun create(initialState: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel
}
companion object : MavericksViewModelFactory<VerificationEmojiCodeViewModel, VerificationEmojiCodeViewState> {
override fun create(viewModelContext: ViewModelContext, state: VerificationEmojiCodeViewState): VerificationEmojiCodeViewModel? {
val factory = (viewModelContext as FragmentViewModelContext).fragment<VerificationEmojiCodeFragment>().viewModelFactory
return factory.create(state)
}
companion object : MavericksViewModelFactory<VerificationEmojiCodeViewModel, VerificationEmojiCodeViewState> by hiltMavericksViewModelFactory() {
override fun initialState(viewModelContext: ViewModelContext): VerificationEmojiCodeViewState? {
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
class DiscoverySettingsFragment @Inject constructor(
private val controller: DiscoverySettingsController,
val viewModelFactory: DiscoverySettingsViewModel.Factory
private val controller: DiscoverySettingsController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
DiscoverySettingsController.Listener {

View File

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

View File

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

View File

@ -15,8 +15,6 @@
*/
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.ViewModelContext
import dagger.assisted.Assisted
@ -24,6 +22,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.R
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.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -42,26 +42,20 @@ class SetIdentityServerViewModel @AssistedInject constructor(
VectorViewModel<SetIdentityServerState, SetIdentityServerAction, SetIdentityServerViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: SetIdentityServerState): SetIdentityServerViewModel
interface Factory: MavericksAssistedViewModelFactory<SetIdentityServerViewModel,SetIdentityServerState> {
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()
return SetIdentityServerState(
homeServerUrl = session.sessionParams.homeServerUrl,
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

View File

@ -94,8 +94,6 @@ data class HomeActivityArgs(
class HomeActivity :
VectorBaseActivity<ActivityHomeBinding>(),
ToolbarConfigurable,
UnknownDeviceDetectorSharedViewModel.Factory,
UnreadMessagesSharedViewModel.Factory,
NavigationInterceptor,
SpaceInviteBottomSheet.InteractionListener,
MatrixToBottomSheet.InteractionListener {
@ -115,8 +113,6 @@ class HomeActivity :
@Inject lateinit var vectorPreferences: VectorPreferences
@Inject lateinit var popupAlertManager: PopupAlertManager
@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 avatarRenderer: AvatarRenderer
@Inject lateinit var initSyncStepFormatter: InitSyncStepFormatter
@ -175,14 +171,6 @@ class HomeActivity :
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?) {
super.onCreate(savedInstanceState)
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)

View File

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

View File

@ -26,6 +26,8 @@ import dagger.assisted.AssistedInject
import im.vector.app.AppStateHandler
import im.vector.app.RoomGroupingMethod
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.features.call.dialpad.DialPadLookup
import im.vector.app.features.call.lookup.CallProtocolsChecker
@ -69,24 +71,18 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
CallProtocolsChecker.Listener {
@AssistedFactory
interface Factory {
fun create(initialState: HomeDetailViewState): HomeDetailViewModel
interface Factory: MavericksAssistedViewModelFactory<HomeDetailViewModel,HomeDetailViewState> {
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()
return HomeDetailViewState(
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 {

View File

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

View File

@ -16,16 +16,15 @@
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.MavericksViewModelFactory
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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -61,21 +60,11 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: UnreadMessagesState): UnreadMessagesSharedViewModel
interface Factory: MavericksAssistedViewModelFactory<UnreadMessagesSharedViewModel,UnreadMessagesState> {
override fun create(initialState: UnreadMessagesState): UnreadMessagesSharedViewModel
}
companion object : MavericksViewModelFactory<UnreadMessagesSharedViewModel, UnreadMessagesState> {
@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")
}
}
companion object : MavericksViewModelFactory<UnreadMessagesSharedViewModel, UnreadMessagesState> by hiltMavericksViewModelFactory()
override fun handle(action: EmptyAction) {}

View File

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

View File

@ -22,6 +22,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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
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,
private val session: Session) :
VectorViewModel<BreadcrumbsViewState, EmptyAction, EmptyViewEvents>(initialState) {
VectorViewModel<BreadcrumbsViewState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: BreadcrumbsViewState): BreadcrumbsViewModel
interface Factory : MavericksAssistedViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> {
override fun create(initialState: BreadcrumbsViewState): BreadcrumbsViewModel
}
companion object : MavericksViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: BreadcrumbsViewState): BreadcrumbsViewModel? {
val fragment: BreadcrumbsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.breadcrumbsViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<BreadcrumbsViewModel, BreadcrumbsViewState> by hiltMavericksViewModelFactory()
init {
observeBreadcrumbs()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,16 +15,15 @@
*/
package im.vector.app.features.home.room.detail.timeline.edithistory
import androidx.lifecycle.viewModelScope
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.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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
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")
@AssistedFactory
interface Factory {
fun create(initialState: ViewEditHistoryViewState): ViewEditHistoryViewModel
interface Factory: MavericksAssistedViewModelFactory<ViewEditHistoryViewModel,ViewEditHistoryViewState> {
override fun create(initialState: ViewEditHistoryViewState): ViewEditHistoryViewModel
}
companion object : MavericksViewModelFactory<ViewEditHistoryViewModel, ViewEditHistoryViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: ViewEditHistoryViewState): ViewEditHistoryViewModel? {
val fragment: ViewEditHistoryBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewEditHistoryViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<ViewEditHistoryViewModel, ViewEditHistoryViewState> by hiltMavericksViewModelFactory()
init {
loadHistory()

View File

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

View File

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

View File

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

View File

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

View File

@ -32,6 +32,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.R
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.exhaustive
import im.vector.app.core.platform.VectorViewModel
@ -72,10 +74,12 @@ class LoginViewModel @AssistedInject constructor(
) : VectorViewModel<LoginViewState, LoginAction, LoginViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: LoginViewState): LoginViewModel
interface Factory:MavericksAssistedViewModelFactory<LoginViewModel,LoginViewState> {
override fun create(initialState: LoginViewState): LoginViewModel
}
companion object : MavericksViewModelFactory<LoginViewModel, LoginViewState> by hiltMavericksViewModelFactory()
init {
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
private var lastAction: LoginAction? = null
private var currentHomeServerConnectionConfig: HomeServerConnectionConfig? = null

View File

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

View File

@ -29,6 +29,8 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.R
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.exhaustive
import im.vector.app.core.extensions.tryAsync
@ -72,10 +74,12 @@ class LoginViewModel2 @AssistedInject constructor(
) : VectorViewModel<LoginViewState2, LoginAction2, LoginViewEvents2>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: LoginViewState2): LoginViewModel2
interface Factory: MavericksAssistedViewModelFactory<LoginViewModel2,LoginViewState2> {
override fun create(initialState: LoginViewState2): LoginViewModel2
}
companion object : MavericksViewModelFactory<LoginViewModel2, LoginViewState2> by hiltMavericksViewModelFactory()
init {
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
private var lastAction: LoginAction2? = 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
*/
class AccountCreatedFragment @Inject constructor(
val accountCreatedViewModelFactory: AccountCreatedViewModel.Factory,
private val avatarRenderer: AvatarRenderer,
private val dateFormatter: VectorDateFormatter,
private val matrixItemColorProvider: MatrixItemColorProvider,

View File

@ -16,13 +16,12 @@
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.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 kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
@ -40,18 +39,11 @@ class AccountCreatedViewModel @AssistedInject constructor(
) : VectorViewModel<AccountCreatedViewState, AccountCreatedAction, AccountCreatedViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: AccountCreatedViewState): AccountCreatedViewModel
interface Factory: MavericksAssistedViewModelFactory<AccountCreatedViewModel,AccountCreatedViewState> {
override fun create(initialState: AccountCreatedViewState): AccountCreatedViewModel
}
companion object : MavericksViewModelFactory<AccountCreatedViewModel, AccountCreatedViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: AccountCreatedViewState): AccountCreatedViewModel? {
val fragment: AccountCreatedFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.accountCreatedViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<AccountCreatedViewModel, AccountCreatedViewState> by hiltMavericksViewModelFactory()
init {
setState {

View File

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

View File

@ -16,18 +16,17 @@
package im.vector.app.features.matrixto
import androidx.lifecycle.viewModelScope
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.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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
@ -54,10 +53,12 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
VectorViewModel<MatrixToBottomSheetState, MatrixToAction, MatrixToViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: MatrixToBottomSheetState): MatrixToBottomSheetViewModel
interface Factory: MavericksAssistedViewModelFactory<MatrixToBottomSheetViewModel,MatrixToBottomSheetState> {
override fun create(initialState: MatrixToBottomSheetState): MatrixToBottomSheetViewModel
}
companion object : MavericksViewModelFactory<MatrixToBottomSheetViewModel, MatrixToBottomSheetState> by hiltMavericksViewModelFactory()
init {
when (initialState.linkType) {
is PermalinkData.RoomLink -> {
@ -245,14 +246,6 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
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) {
when (action) {
is MatrixToAction.StartChattingWithUser -> handleStartChatting(action)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,6 @@ import java.util.UUID
import javax.inject.Inject
class RoomSettingsFragment @Inject constructor(
val viewModelFactory: RoomSettingsViewModel.Factory,
private val controller: RoomSettingsController,
colorProvider: ColorProvider,
private val avatarRenderer: AvatarRenderer
@ -60,8 +59,7 @@ class RoomSettingsFragment @Inject constructor(
VectorBaseFragment<FragmentRoomSettingGenericBinding>(),
RoomSettingsController.Callback,
OnBackPressed,
GalleryOrCameraDialogHelper.Listener,
RoomSettingsViewModel.Factory {
GalleryOrCameraDialogHelper.Listener {
private val viewModel: RoomSettingsViewModel by fragmentViewModel()
private lateinit var roomProfileSharedActionViewModel: RoomProfileSharedActionViewModel
@ -77,10 +75,6 @@ class RoomSettingsFragment @Inject constructor(
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?) {
super.onViewCreated(view, savedInstanceState)
roomProfileSharedActionViewModel = activityViewModelProvider.get(RoomProfileSharedActionViewModel::class.java)

View File

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