Hilt: continue migration VM

This commit is contained in:
ganfra 2021-10-18 18:21:22 +02:00
parent 968c2e70d2
commit 1d73077184
95 changed files with 366 additions and 502 deletions

View file

@ -36,5 +36,5 @@ import com.airbnb.mvrx.MavericksViewModel
* If you already have a ViewModelsModule then all you have to do is add the multibinding entry for your new [MavericksViewModel].
*/
interface MavericksAssistedViewModelFactory<VM : MavericksViewModel<S>, S : MavericksState> {
fun create(state: S): VM
fun create(initialState: S): VM
}

View file

@ -33,11 +33,37 @@ import im.vector.app.features.home.PromoteRestrictedViewModel
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.room.RequireActiveMembershipViewModel
import im.vector.app.features.roomdirectory.RoomDirectoryViewModel
import im.vector.app.features.roomdirectory.createroom.CreateRoomViewModel
import im.vector.app.features.roomdirectory.picker.RoomDirectoryPickerViewModel
import im.vector.app.features.roomdirectory.roompreview.RoomPreviewViewModel
import im.vector.app.features.roommemberprofile.RoomMemberProfileViewModel
import im.vector.app.features.roomprofile.RoomProfileViewModel
import im.vector.app.features.roomprofile.alias.RoomAliasViewModel
import im.vector.app.features.roomprofile.alias.detail.RoomAliasBottomSheetViewModel
import im.vector.app.features.roomprofile.banned.RoomBannedMemberListViewModel
import im.vector.app.features.roomprofile.members.RoomMemberListViewModel
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsViewModel
import im.vector.app.features.roomprofile.permissions.RoomPermissionsViewModel
import im.vector.app.features.roomprofile.settings.RoomSettingsViewModel
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel
import im.vector.app.features.roomprofile.uploads.RoomUploadsViewModel
import im.vector.app.features.settings.account.deactivation.DeactivateAccountViewModel
import im.vector.app.features.settings.crosssigning.CrossSigningSettingsViewModel
import im.vector.app.features.settings.devices.DevicesViewModel
import im.vector.app.features.settings.devtools.AccountDataViewModel
import im.vector.app.features.settings.devtools.GossipingEventsPaperTrailViewModel
import im.vector.app.features.settings.devtools.KeyRequestListViewModel
import im.vector.app.features.settings.homeserver.HomeserverSettingsViewModel
import im.vector.app.features.settings.ignored.IgnoredUsersViewModel
import im.vector.app.features.settings.locale.LocalePickerViewModel
import im.vector.app.features.settings.push.PushGatewaysViewModel
import im.vector.app.features.settings.threepids.ThreePidsSettingsViewModel
import im.vector.app.features.share.IncomingShareViewModel
import im.vector.app.features.signout.soft.SoftLogoutViewModel
import im.vector.app.features.spaces.SpaceListViewModel
import im.vector.app.features.spaces.SpaceMenuViewModel
import im.vector.app.features.spaces.create.CreateSpaceViewModel
import im.vector.app.features.spaces.explore.SpaceDirectoryViewModel
import im.vector.app.features.spaces.invite.SpaceInviteBottomSheetViewModel
@ -235,4 +261,136 @@ interface MavericksViewModelModule {
@MavericksViewModelKey(CreateSpaceViewModel::class)
fun createSpaceViewModelFactory(factory: CreateSpaceViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(SpaceMenuViewModel::class)
fun spaceMenuViewModelFactory(factory: SpaceMenuViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(SoftLogoutViewModel::class)
fun softLogoutViewModelFactory(factory: SoftLogoutViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(IncomingShareViewModel::class)
fun incomingShareViewModelFactory(factory: IncomingShareViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(ThreePidsSettingsViewModel::class)
fun threePidsSettingsViewModelFactory(factory: ThreePidsSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(PushGatewaysViewModel::class)
fun pushGatewaysViewModelFactory(factory: PushGatewaysViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(HomeserverSettingsViewModel::class)
fun homeserverSettingsViewModelFactory(factory: HomeserverSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(LocalePickerViewModel::class)
fun localePickerViewModelFactory(factory: LocalePickerViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(GossipingEventsPaperTrailViewModel::class)
fun gossipingEventsPaperTrailViewModelFactory(factory: GossipingEventsPaperTrailViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(AccountDataViewModel::class)
fun accountDataViewModelFactory(factory: AccountDataViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(DevicesViewModel::class)
fun devicesViewModelFactory(factory: DevicesViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(KeyRequestListViewModel::class)
fun keyRequestListViewModelFactory(factory: KeyRequestListViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(CrossSigningSettingsViewModel::class)
fun crossSigningSettingsViewModelFactory(factory: CrossSigningSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(DeactivateAccountViewModel::class)
fun deactivateAccountViewModelFactory(factory: DeactivateAccountViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomUploadsViewModel::class)
fun roomUploadsViewModelFactory(factory: RoomUploadsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomJoinRuleChooseRestrictedViewModel::class)
fun roomJoinRuleChooseRestrictedViewModelFactory(factory: RoomJoinRuleChooseRestrictedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomSettingsViewModel::class)
fun roomSettingsViewModelFactory(factory: RoomSettingsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomPermissionsViewModel::class)
fun roomPermissionsViewModelFactory(factory: RoomPermissionsViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomMemberListViewModel::class)
fun roomMemberListViewModelFactory(factory: RoomMemberListViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomBannedMemberListViewModel::class)
fun roomBannedMemberListViewModelFactory(factory: RoomBannedMemberListViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomAliasViewModel::class)
fun roomAliasViewModelFactory(factory: RoomAliasViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomAliasBottomSheetViewModel::class)
fun roomAliasBottomSheetViewModelFactory(factory: RoomAliasBottomSheetViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomProfileViewModel::class)
fun roomProfileViewModelFactory(factory: RoomProfileViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomMemberProfileViewModel::class)
fun roomMemberProfileViewModelFactory(factory: RoomMemberProfileViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RoomPreviewViewModel::class)
fun roomPreviewViewModelFactory(factory: RoomPreviewViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(CreateRoomViewModel::class)
fun createRoomViewModelFactory(factory: CreateRoomViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(RequireActiveMembershipViewModel::class)
fun requireActiveMembershipViewModelFactory(factory: RequireActiveMembershipViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
}

View file

@ -38,7 +38,7 @@ class ReAuthViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ReAuthViewModel,ReAuthState> {
override fun create(state: ReAuthState): ReAuthViewModel
override fun create(initialState: ReAuthState): ReAuthViewModel
}
companion object : MavericksViewModelFactory<ReAuthViewModel, ReAuthState> by hiltMavericksViewModelFactory()

View file

@ -344,7 +344,7 @@ class VectorCallViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<VectorCallViewModel,VectorCallViewState> {
override fun create(state: VectorCallViewState): VectorCallViewModel
override fun create(initialState: VectorCallViewState): VectorCallViewModel
}
companion object : MavericksViewModelFactory<VectorCallViewModel, VectorCallViewState> by hiltMavericksViewModelFactory()

View file

@ -49,7 +49,7 @@ class JitsiCallViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<JitsiCallViewModel,JitsiCallViewState> {
override fun create(state: JitsiCallViewState): JitsiCallViewModel
override fun create(initialState: JitsiCallViewState): JitsiCallViewModel
}
private var currentWidgetObserver: Job? = null

View file

@ -41,7 +41,7 @@ class CallTransferViewModel @AssistedInject constructor(@Assisted initialState:
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<CallTransferViewModel,CallTransferViewState> {
override fun create(state: CallTransferViewState): CallTransferViewModel
override fun create(initialState: CallTransferViewState): CallTransferViewModel
}
companion object : MavericksViewModelFactory<CallTransferViewModel, CallTransferViewState> by hiltMavericksViewModelFactory()

View file

@ -48,7 +48,7 @@ class ContactsBookViewModel @AssistedInject constructor(@Assisted
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ContactsBookViewModel,ContactsBookViewState> {
override fun create(state: ContactsBookViewState): ContactsBookViewModel
override fun create(initialState: ContactsBookViewState): ContactsBookViewModel
}
companion object : MavericksViewModelFactory<ContactsBookViewModel, ContactsBookViewState> by hiltMavericksViewModelFactory()

View file

@ -44,7 +44,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<CreateDirectRoomViewModel,CreateDirectRoomViewState> {
override fun create(state: CreateDirectRoomViewState): CreateDirectRoomViewModel
override fun create(initialState: CreateDirectRoomViewState): CreateDirectRoomViewModel
}
companion object : MavericksViewModelFactory<CreateDirectRoomViewModel, CreateDirectRoomViewState> by hiltMavericksViewModelFactory()

View file

@ -42,7 +42,7 @@ class KeysBackupSettingsViewModel @AssistedInject constructor(@Assisted initialS
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<KeysBackupSettingsViewModel,KeysBackupSettingViewState> {
override fun create(state: KeysBackupSettingViewState): KeysBackupSettingsViewModel
override fun create(initialState: KeysBackupSettingViewState): KeysBackupSettingsViewModel
}
companion object : MavericksViewModelFactory<KeysBackupSettingsViewModel, KeysBackupSettingViewState> by hiltMavericksViewModelFactory()

View file

@ -83,7 +83,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SharedSecureStorageViewModel,SharedSecureStorageViewState> {
override fun create(state: SharedSecureStorageViewState): SharedSecureStorageViewModel
override fun create(initialState: SharedSecureStorageViewState): SharedSecureStorageViewModel
}
init {

View file

@ -50,7 +50,7 @@ class RoomDevToolViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory : MavericksAssistedViewModelFactory<RoomDevToolViewModel, RoomDevToolViewState> {
override fun create(state: RoomDevToolViewState): RoomDevToolViewModel
override fun create(initialState: RoomDevToolViewState): RoomDevToolViewModel
}
companion object : MavericksViewModelFactory<RoomDevToolViewModel, RoomDevToolViewState> by hiltMavericksViewModelFactory()

View file

@ -75,7 +75,7 @@ class PromoteRestrictedViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<PromoteRestrictedViewModel,ActiveSpaceViewState> {
override fun create(state: ActiveSpaceViewState): PromoteRestrictedViewModel
override fun create(initialState: ActiveSpaceViewState): PromoteRestrictedViewModel
}
companion object : MavericksViewModelFactory<PromoteRestrictedViewModel, ActiveSpaceViewState> by hiltMavericksViewModelFactory()

View file

@ -24,6 +24,7 @@ import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.viewModel
import com.google.android.material.appbar.MaterialToolbar
import im.vector.app.R
@ -39,15 +40,10 @@ import im.vector.app.features.navigation.Navigator
import im.vector.app.features.room.RequireActiveMembershipAction
import im.vector.app.features.room.RequireActiveMembershipViewEvents
import im.vector.app.features.room.RequireActiveMembershipViewModel
import im.vector.app.features.room.RequireActiveMembershipViewState
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewModel
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewState
import javax.inject.Inject
class RoomDetailActivity :
VectorBaseActivity<ActivityRoomDetailBinding>(),
ToolbarConfigurable,
RequireActiveMembershipViewModel.Factory,
MatrixToBottomSheet.InteractionListener {
override fun getBinding(): ActivityRoomDetailBinding {
@ -76,14 +72,6 @@ class RoomDetailActivity :
private lateinit var sharedActionViewModel: RoomDetailSharedActionViewModel
private val requireActiveMembershipViewModel: RequireActiveMembershipViewModel by viewModel()
@Inject
lateinit var requireActiveMembershipViewModelFactory: RequireActiveMembershipViewModel.Factory
override fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel {
// Due to shortcut, we cannot use MvRx args. Pass the first roomId here
return requireActiveMembershipViewModelFactory.create(initialState.copy(roomId = currentRoomId ?: ""))
}
override fun injectWith(injector: ScreenComponent) {
injector.inject(this)
}
@ -101,6 +89,7 @@ class RoomDetailActivity :
intent?.extras?.getParcelable(EXTRA_ROOM_DETAIL_ARGS)
}
if (roomDetailArgs == null) return
intent.putExtra(Mavericks.KEY_ARG, roomDetailArgs)
currentRoomId = roomDetailArgs.roomId
if (isFirstCreation()) {

View file

@ -73,7 +73,7 @@ class ViewReactionsViewModel @AssistedInject constructor(@Assisted
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ViewReactionsViewModel,DisplayReactionsViewState> {
override fun create(state: DisplayReactionsViewState): ViewReactionsViewModel
override fun create(initialState: DisplayReactionsViewState): ViewReactionsViewModel
}
companion object : MavericksViewModelFactory<ViewReactionsViewModel, DisplayReactionsViewState> by hiltMavericksViewModelFactory()

View file

@ -51,7 +51,7 @@ class MigrateRoomViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<MigrateRoomViewModel,MigrateRoomViewState> {
override fun create(state: MigrateRoomViewState): MigrateRoomViewModel
override fun create(initialState: MigrateRoomViewState): MigrateRoomViewModel
}
companion object : MavericksViewModelFactory<MigrateRoomViewModel, MigrateRoomViewState> by hiltMavericksViewModelFactory()

View file

@ -64,7 +64,7 @@ class RoomListViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<RoomListViewModel, RoomListViewState> {
override fun create(state: RoomListViewState): RoomListViewModel
override fun create(initialState: RoomListViewState): RoomListViewModel
}
private var updatableQuery: UpdatableLivePageResult? = null

View file

@ -16,14 +16,14 @@
package im.vector.app.features.room
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -55,21 +55,11 @@ class RequireActiveMembershipViewModel @AssistedInject constructor(
VectorViewModel<RequireActiveMembershipViewState, RequireActiveMembershipAction, RequireActiveMembershipViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel
interface Factory: MavericksAssistedViewModelFactory<RequireActiveMembershipViewModel,RequireActiveMembershipViewState> {
override fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel
}
companion object : MavericksViewModelFactory<RequireActiveMembershipViewModel, RequireActiveMembershipViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RequireActiveMembershipViewState): RequireActiveMembershipViewModel? {
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<RequireActiveMembershipViewModel, RequireActiveMembershipViewState> by hiltMavericksViewModelFactory()
private val roomIdFlow = MutableStateFlow(Optional.from(initialState.roomId))

View file

@ -17,6 +17,7 @@
package im.vector.app.features.room
import com.airbnb.mvrx.MavericksState
import im.vector.app.features.home.room.detail.RoomDetailArgs
import im.vector.app.features.roommemberprofile.RoomMemberProfileArgs
import im.vector.app.features.roomprofile.RoomProfileArgs
@ -24,7 +25,7 @@ data class RequireActiveMembershipViewState(
val roomId: String? = null
) : MavericksState {
// No constructor for RoomDetailArgs because of intent for Shortcut
constructor(args: RoomDetailArgs) : this(roomId = args.roomId)
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)

View file

@ -52,7 +52,7 @@ class RoomDirectoryViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<RoomDirectoryViewModel,PublicRoomsViewState> {
override fun create(state: PublicRoomsViewState): RoomDirectoryViewModel
override fun create(initialState: PublicRoomsViewState): RoomDirectoryViewModel
}
companion object : MavericksViewModelFactory<RoomDirectoryViewModel, PublicRoomsViewState> by hiltMavericksViewModelFactory() {

View file

@ -59,7 +59,6 @@ data class CreateRoomArgs(
class CreateRoomFragment @Inject constructor(
private val createRoomController: CreateRoomController,
private val createSpaceController: CreateSubSpaceController,
val createRoomViewModelFactory: CreateRoomViewModel.Factory,
colorProvider: ColorProvider
) : VectorBaseFragment<FragmentCreateRoomBinding>(),
CreateRoomController.Listener,

View file

@ -17,17 +17,16 @@
package im.vector.app.features.roomdirectory.createroom
import androidx.core.net.toFile
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.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.raw.wellknown.getElementWellknown
@ -60,10 +59,12 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
) : VectorViewModel<CreateRoomViewState, CreateRoomAction, CreateRoomViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: CreateRoomViewState): CreateRoomViewModel
interface Factory : MavericksAssistedViewModelFactory<CreateRoomViewModel, CreateRoomViewState> {
override fun create(initialState: CreateRoomViewState): CreateRoomViewModel
}
companion object : MavericksViewModelFactory<CreateRoomViewModel, CreateRoomViewState> by hiltMavericksViewModelFactory()
init {
initHomeServerName()
initAdminE2eByDefault()
@ -122,16 +123,6 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
}
}
companion object : MavericksViewModelFactory<CreateRoomViewModel, CreateRoomViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: CreateRoomViewState): CreateRoomViewModel? {
val fragment: CreateRoomFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.createRoomViewModelFactory.create(state)
}
}
override fun handle(action: CreateRoomAction) {
when (action) {
is CreateRoomAction.SetAvatar -> setAvatar(action)

View file

@ -48,7 +48,7 @@ class RoomDirectoryPickerViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<RoomDirectoryPickerViewModel,RoomDirectoryPickerViewState> {
override fun create(state: RoomDirectoryPickerViewState): RoomDirectoryPickerViewModel
override fun create(initialState: RoomDirectoryPickerViewState): RoomDirectoryPickerViewModel
}
companion object : MavericksViewModelFactory<RoomDirectoryPickerViewModel, RoomDirectoryPickerViewState> by hiltMavericksViewModelFactory()

View file

@ -51,7 +51,6 @@ import javax.inject.Inject
* Note: this Fragment is also used for world readable room for the moment
*/
class RoomPreviewNoPreviewFragment @Inject constructor(
val roomPreviewViewModelFactory: RoomPreviewViewModel.Factory,
private val avatarRenderer: AvatarRenderer
) : VectorBaseFragment<FragmentRoomPreviewNoPreviewBinding>() {

View file

@ -16,15 +16,14 @@
package im.vector.app.features.roomdirectory.roompreview
import androidx.lifecycle.viewModelScope
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.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -50,18 +49,11 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val ini
VectorViewModel<RoomPreviewViewState, RoomPreviewAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomPreviewViewState): RoomPreviewViewModel
interface Factory: MavericksAssistedViewModelFactory<RoomPreviewViewModel,RoomPreviewViewState> {
override fun create(initialState: RoomPreviewViewState): RoomPreviewViewModel
}
companion object : MavericksViewModelFactory<RoomPreviewViewModel, RoomPreviewViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomPreviewViewState): RoomPreviewViewModel? {
val fragment: RoomPreviewNoPreviewFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.roomPreviewViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomPreviewViewModel, RoomPreviewViewState> by hiltMavericksViewModelFactory()
init {
// Observe joined room (from the sync)

View file

@ -36,8 +36,7 @@ import javax.inject.Inject
class RoomMemberProfileActivity :
VectorBaseActivity<ActivitySimpleBinding>(),
ToolbarConfigurable,
RequireActiveMembershipViewModel.Factory {
ToolbarConfigurable {
companion object {
fun newIntent(context: Context, args: RoomMemberProfileArgs): Intent {
@ -49,12 +48,6 @@ class RoomMemberProfileActivity :
private val requireActiveMembershipViewModel: RequireActiveMembershipViewModel by viewModel()
@Inject
lateinit var requireActiveMembershipViewModelFactory: RequireActiveMembershipViewModel.Factory
override fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel {
return requireActiveMembershipViewModelFactory.create(initialState)
}
override fun injectWith(injector: ScreenComponent) {
injector.inject(this)

View file

@ -66,7 +66,6 @@ data class RoomMemberProfileArgs(
) : Parcelable
class RoomMemberProfileFragment @Inject constructor(
val viewModelFactory: RoomMemberProfileViewModel.Factory,
private val roomMemberProfileController: RoomMemberProfileController,
private val avatarRenderer: AvatarRenderer,
private val roomDetailPendingActionStore: RoomDetailPendingActionStore

View file

@ -28,6 +28,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.mvrx.runCatchingToAsync
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -60,21 +62,14 @@ import org.matrix.android.sdk.flow.unwrap
class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private val initialState: RoomMemberProfileViewState,
private val stringProvider: StringProvider,
private val session: Session) :
VectorViewModel<RoomMemberProfileViewState, RoomMemberProfileAction, RoomMemberProfileViewEvents>(initialState) {
VectorViewModel<RoomMemberProfileViewState, RoomMemberProfileAction, RoomMemberProfileViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomMemberProfileViewState): RoomMemberProfileViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomMemberProfileViewModel, RoomMemberProfileViewState> {
override fun create(initialState: RoomMemberProfileViewState): RoomMemberProfileViewModel
}
companion object : MavericksViewModelFactory<RoomMemberProfileViewModel, RoomMemberProfileViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomMemberProfileViewState): RoomMemberProfileViewModel? {
val fragment: RoomMemberProfileFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomMemberProfileViewModel, RoomMemberProfileViewState> by hiltMavericksViewModelFactory()
private val room = if (initialState.roomId != null) {
session.getRoom(initialState.roomId)

View file

@ -46,8 +46,7 @@ import javax.inject.Inject
class RoomProfileActivity :
VectorBaseActivity<ActivitySimpleBinding>(),
ToolbarConfigurable,
RequireActiveMembershipViewModel.Factory {
ToolbarConfigurable {
companion object {
@ -71,16 +70,9 @@ class RoomProfileActivity :
private val requireActiveMembershipViewModel: RequireActiveMembershipViewModel by viewModel()
@Inject
lateinit var requireActiveMembershipViewModelFactory: RequireActiveMembershipViewModel.Factory
@Inject
lateinit var roomDetailPendingActionStore: RoomDetailPendingActionStore
override fun create(initialState: RequireActiveMembershipViewState): RequireActiveMembershipViewModel {
return requireActiveMembershipViewModelFactory.create(initialState)
}
override fun injectWith(injector: ScreenComponent) {
injector.inject(this)
}

View file

@ -67,7 +67,6 @@ class RoomProfileFragment @Inject constructor(
private val roomProfileController: RoomProfileController,
private val avatarRenderer: AvatarRenderer,
private val roomDetailPendingActionStore: RoomDetailPendingActionStore,
val roomProfileViewModelFactory: RoomProfileViewModel.Factory
) :
VectorBaseFragment<FragmentMatrixProfileBinding>(),
RoomProfileController.Callback {

View file

@ -17,13 +17,13 @@
package im.vector.app.features.roomprofile
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -53,18 +53,11 @@ class RoomProfileViewModel @AssistedInject constructor(
) : VectorViewModel<RoomProfileViewState, RoomProfileAction, RoomProfileViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomProfileViewState): RoomProfileViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomProfileViewModel, RoomProfileViewState> {
override fun create(initialState: RoomProfileViewState): RoomProfileViewModel
}
companion object : MavericksViewModelFactory<RoomProfileViewModel, RoomProfileViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomProfileViewState): RoomProfileViewModel? {
val fragment: RoomProfileFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.roomProfileViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomProfileViewModel, RoomProfileViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!

View file

@ -44,7 +44,6 @@ import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
class RoomAliasFragment @Inject constructor(
val viewModelFactory: RoomAliasViewModel.Factory,
private val controller: RoomAliasController,
private val avatarRenderer: AvatarRenderer
) :

View file

@ -17,15 +17,15 @@
package im.vector.app.features.roomprofile.alias
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
@ -45,21 +45,14 @@ import org.matrix.android.sdk.flow.unwrap
class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: RoomAliasViewState,
private val session: Session) :
VectorViewModel<RoomAliasViewState, RoomAliasAction, RoomAliasViewEvents>(initialState) {
VectorViewModel<RoomAliasViewState, RoomAliasAction, RoomAliasViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomAliasViewState): RoomAliasViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomAliasViewModel, RoomAliasViewState> {
override fun create(initialState: RoomAliasViewState): RoomAliasViewModel
}
companion object : MavericksViewModelFactory<RoomAliasViewModel, RoomAliasViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomAliasViewState): RoomAliasViewModel? {
val fragment: RoomAliasFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomAliasViewModel, RoomAliasViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!

View file

@ -50,7 +50,6 @@ class RoomAliasBottomSheet :
private lateinit var sharedActionViewModel: RoomAliasBottomSheetSharedActionViewModel
@Inject lateinit var sharedViewPool: RecyclerView.RecycledViewPool
@Inject lateinit var roomAliasBottomSheetViewModelFactory: RoomAliasBottomSheetViewModel.Factory
@Inject lateinit var controller: RoomAliasBottomSheetController
private val viewModel: RoomAliasBottomSheetViewModel by fragmentViewModel(RoomAliasBottomSheetViewModel::class)

View file

@ -15,12 +15,12 @@
*/
package im.vector.app.features.roomprofile.alias.detail
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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -32,18 +32,11 @@ class RoomAliasBottomSheetViewModel @AssistedInject constructor(
) : VectorViewModel<RoomAliasBottomSheetState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomAliasBottomSheetState): RoomAliasBottomSheetViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomAliasBottomSheetViewModel, RoomAliasBottomSheetState> {
override fun create(initialState: RoomAliasBottomSheetState): RoomAliasBottomSheetViewModel
}
companion object : MavericksViewModelFactory<RoomAliasBottomSheetViewModel, RoomAliasBottomSheetState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomAliasBottomSheetState): RoomAliasBottomSheetViewModel? {
val fragment: RoomAliasBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.roomAliasBottomSheetViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomAliasBottomSheetViewModel, RoomAliasBottomSheetState> by hiltMavericksViewModelFactory()
init {
setState {

View file

@ -39,7 +39,6 @@ import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
class RoomBannedMemberListFragment @Inject constructor(
val viewModelFactory: RoomBannedMemberListViewModel.Factory,
private val roomMemberListController: RoomBannedMemberListController,
private val avatarRenderer: AvatarRenderer
) : VectorBaseFragment<FragmentRoomSettingGenericBinding>(),

View file

@ -16,13 +16,13 @@
package im.vector.app.features.roomprofile.banned
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -44,11 +44,11 @@ import org.matrix.android.sdk.flow.unwrap
class RoomBannedMemberListViewModel @AssistedInject constructor(@Assisted initialState: RoomBannedMemberListViewState,
private val stringProvider: StringProvider,
private val session: Session) :
VectorViewModel<RoomBannedMemberListViewState, RoomBannedMemberListAction, RoomBannedMemberListViewEvents>(initialState) {
VectorViewModel<RoomBannedMemberListViewState, RoomBannedMemberListAction, RoomBannedMemberListViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomBannedMemberListViewState): RoomBannedMemberListViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomBannedMemberListViewModel, RoomBannedMemberListViewState> {
override fun create(initialState: RoomBannedMemberListViewState): RoomBannedMemberListViewModel
}
private val room = session.getRoom(initialState.roomId)!!
@ -77,14 +77,7 @@ class RoomBannedMemberListViewModel @AssistedInject constructor(@Assisted initia
}
}
companion object : MavericksViewModelFactory<RoomBannedMemberListViewModel, RoomBannedMemberListViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomBannedMemberListViewState): RoomBannedMemberListViewModel? {
val fragment: RoomBannedMemberListFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomBannedMemberListViewModel, RoomBannedMemberListViewState> by hiltMavericksViewModelFactory()
override fun handle(action: RoomBannedMemberListAction) {
when (action) {

View file

@ -17,13 +17,12 @@
package im.vector.app.features.roomprofile.members
import androidx.lifecycle.asFlow
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -57,24 +56,14 @@ import timber.log.Timber
class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState: RoomMemberListViewState,
private val roomMemberSummaryComparator: RoomMemberSummaryComparator,
private val session: Session) :
VectorViewModel<RoomMemberListViewState, RoomMemberListAction, EmptyViewEvents>(initialState) {
VectorViewModel<RoomMemberListViewState, RoomMemberListAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomMemberListViewState): RoomMemberListViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomMemberListViewModel, RoomMemberListViewState> {
override fun create(initialState: RoomMemberListViewState): RoomMemberListViewModel
}
companion object : MavericksViewModelFactory<RoomMemberListViewModel, RoomMemberListViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomMemberListViewState): RoomMemberListViewModel? {
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<RoomMemberListViewModel, RoomMemberListViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!

View file

@ -36,7 +36,7 @@ class RoomNotificationSettingsViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<RoomNotificationSettingsViewModel,RoomNotificationSettingsViewState> {
override fun create(state: RoomNotificationSettingsViewState): RoomNotificationSettingsViewModel
override fun create(initialState: RoomNotificationSettingsViewState): RoomNotificationSettingsViewModel
}
companion object : MavericksViewModelFactory<RoomNotificationSettingsViewModel, RoomNotificationSettingsViewState> by hiltMavericksViewModelFactory()

View file

@ -39,7 +39,6 @@ import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
class RoomPermissionsFragment @Inject constructor(
val viewModelFactory: RoomPermissionsViewModel.Factory,
private val controller: RoomPermissionsController,
private val avatarRenderer: AvatarRenderer
) :

View file

@ -16,13 +16,13 @@
package im.vector.app.features.roomprofile.permissions
import com.airbnb.mvrx.FragmentViewModelContext
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 im.vector.app.features.powerlevel.PowerLevelsFlowFactory
@ -42,18 +42,11 @@ class RoomPermissionsViewModel @AssistedInject constructor(@Assisted initialStat
VectorViewModel<RoomPermissionsViewState, RoomPermissionsAction, RoomPermissionsViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomPermissionsViewState): RoomPermissionsViewModel
interface Factory: MavericksAssistedViewModelFactory<RoomPermissionsViewModel,RoomPermissionsViewState> {
override fun create(initialState: RoomPermissionsViewState): RoomPermissionsViewModel
}
companion object : MavericksViewModelFactory<RoomPermissionsViewModel, RoomPermissionsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomPermissionsViewState): RoomPermissionsViewModel? {
val fragment: RoomPermissionsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<RoomPermissionsViewModel, RoomPermissionsViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!

View file

@ -24,6 +24,8 @@ import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
@ -50,24 +52,14 @@ import org.matrix.android.sdk.flow.unwrap
class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState: RoomSettingsViewState,
private val vectorPreferences: VectorPreferences,
private val session: Session) :
VectorViewModel<RoomSettingsViewState, RoomSettingsAction, RoomSettingsViewEvents>(initialState) {
VectorViewModel<RoomSettingsViewState, RoomSettingsAction, RoomSettingsViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomSettingsViewState): RoomSettingsViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomSettingsViewModel, RoomSettingsViewState> {
override fun create(initialState: RoomSettingsViewState): RoomSettingsViewModel
}
companion object : MavericksViewModelFactory<RoomSettingsViewModel, RoomSettingsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomSettingsViewState): RoomSettingsViewModel? {
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<RoomSettingsViewModel, RoomSettingsViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!
@ -150,7 +142,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
canChangeJoinRule = powerLevelsHelper.isUserAllowedToSend(session.myUserId, true,
EventType.STATE_ROOM_JOIN_RULES) &&
powerLevelsHelper.isUserAllowedToSend(session.myUserId, true,
EventType.STATE_ROOM_GUEST_ACCESS),
EventType.STATE_ROOM_GUEST_ACCESS),
canAddChildren = powerLevelsHelper.isUserAllowedToSend(session.myUserId, true,
EventType.STATE_SPACE_CHILD)
)

View file

@ -44,23 +44,17 @@ import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRul
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel
import javax.inject.Inject
class RoomJoinRuleActivity : VectorBaseActivity<ActivitySimpleBinding>(),
RoomJoinRuleChooseRestrictedViewModel.Factory {
class RoomJoinRuleActivity : VectorBaseActivity<ActivitySimpleBinding>() {
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
private lateinit var roomProfileArgs: RoomProfileArgs
@Inject
lateinit var allowListViewModelFactory: RoomJoinRuleChooseRestrictedViewModel.Factory
@Inject
lateinit var errorFormatter: ErrorFormatter
val viewModel: RoomJoinRuleChooseRestrictedViewModel by viewModel()
override fun create(initialState: RoomJoinRuleChooseRestrictedState) = allowListViewModelFactory.create(initialState)
override fun injectWith(injector: ScreenComponent) {
injector.inject(this)
}

View file

@ -18,7 +18,6 @@ package im.vector.app.features.roomprofile.settings.joinrule.advanced
import android.graphics.Typeface
import androidx.core.text.toSpannable
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
@ -31,6 +30,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
@ -175,8 +176,8 @@ class RoomJoinRuleChooseRestrictedViewModel @AssistedInject constructor(
}
@AssistedFactory
interface Factory {
fun create(initialState: RoomJoinRuleChooseRestrictedState): RoomJoinRuleChooseRestrictedViewModel
interface Factory : MavericksAssistedViewModelFactory<RoomJoinRuleChooseRestrictedViewModel, RoomJoinRuleChooseRestrictedState> {
override fun create(initialState: RoomJoinRuleChooseRestrictedState): RoomJoinRuleChooseRestrictedViewModel
}
override fun handle(action: RoomJoinRuleChooseRestrictedActions) {
@ -391,14 +392,5 @@ class RoomJoinRuleChooseRestrictedViewModel @AssistedInject constructor(
}
}
companion object : MavericksViewModelFactory<RoomJoinRuleChooseRestrictedViewModel, RoomJoinRuleChooseRestrictedState> {
override fun create(viewModelContext: ViewModelContext, state: RoomJoinRuleChooseRestrictedState): RoomJoinRuleChooseRestrictedViewModel? {
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<RoomJoinRuleChooseRestrictedViewModel, RoomJoinRuleChooseRestrictedState> by hiltMavericksViewModelFactory()
}

View file

@ -42,11 +42,9 @@ import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject
class RoomUploadsFragment @Inject constructor(
private val viewModelFactory: RoomUploadsViewModel.Factory,
private val avatarRenderer: AvatarRenderer,
private val notificationUtils: NotificationUtils
) : VectorBaseFragment<FragmentRoomUploadsBinding>(),
RoomUploadsViewModel.Factory by viewModelFactory {
) : VectorBaseFragment<FragmentRoomUploadsBinding>() {
private val roomProfileArgs: RoomProfileArgs by args()

View file

@ -16,16 +16,15 @@
package im.vector.app.features.roomprofile.uploads
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.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.launch
@ -40,21 +39,11 @@ class RoomUploadsViewModel @AssistedInject constructor(
) : VectorViewModel<RoomUploadsViewState, RoomUploadsAction, RoomUploadsViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: RoomUploadsViewState): RoomUploadsViewModel
interface Factory: MavericksAssistedViewModelFactory<RoomUploadsViewModel,RoomUploadsViewState> {
override fun create(initialState: RoomUploadsViewState): RoomUploadsViewModel
}
companion object : MavericksViewModelFactory<RoomUploadsViewModel, RoomUploadsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomUploadsViewState): RoomUploadsViewModel? {
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<RoomUploadsViewModel, RoomUploadsViewState> by hiltMavericksViewModelFactory()
private val room = session.getRoom(initialState.roomId)!!

View file

@ -36,9 +36,7 @@ import im.vector.app.features.settings.VectorSettingsActivity
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
import javax.inject.Inject
class DeactivateAccountFragment @Inject constructor(
val viewModelFactory: DeactivateAccountViewModel.Factory
) : VectorBaseFragment<FragmentDeactivateAccountBinding>() {
class DeactivateAccountFragment @Inject constructor() : VectorBaseFragment<FragmentDeactivateAccountBinding>() {
private val viewModel: DeactivateAccountViewModel by fragmentViewModel()

View file

@ -15,14 +15,13 @@
*/
package im.vector.app.features.settings.account.deactivation
import androidx.lifecycle.viewModelScope
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.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.auth.ReAuthActivity
@ -49,8 +48,8 @@ class DeactivateAccountViewModel @AssistedInject constructor(@Assisted private v
VectorViewModel<DeactivateAccountViewState, DeactivateAccountAction, DeactivateAccountViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: DeactivateAccountViewState): DeactivateAccountViewModel
interface Factory: MavericksAssistedViewModelFactory<DeactivateAccountViewModel, DeactivateAccountViewState> {
override fun create(initialState: DeactivateAccountViewState): DeactivateAccountViewModel
}
var uiaContinuation: Continuation<UIABaseAuth>? = null
@ -114,12 +113,5 @@ class DeactivateAccountViewModel @AssistedInject constructor(@Assisted private v
}
}
companion object : MavericksViewModelFactory<DeactivateAccountViewModel, DeactivateAccountViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: DeactivateAccountViewState): DeactivateAccountViewModel? {
val fragment: DeactivateAccountFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<DeactivateAccountViewModel, DeactivateAccountViewState> by hiltMavericksViewModelFactory()
}

View file

@ -42,7 +42,6 @@ import javax.inject.Inject
*/
class CrossSigningSettingsFragment @Inject constructor(
private val controller: CrossSigningSettingsController,
val viewModelFactory: CrossSigningSettingsViewModel.Factory
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
CrossSigningSettingsController.InteractionListener {
@ -55,14 +54,14 @@ class CrossSigningSettingsFragment @Inject constructor(
private val reAuthActivityResultLauncher = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
when (activityResult.data?.extras?.getString(ReAuthActivity.RESULT_FLOW_TYPE)) {
LoginFlowTypes.SSO -> {
LoginFlowTypes.SSO -> {
viewModel.handle(CrossSigningSettingsAction.SsoAuthDone)
}
LoginFlowTypes.PASSWORD -> {
val password = activityResult.data?.extras?.getString(ReAuthActivity.RESULT_VALUE) ?: ""
viewModel.handle(CrossSigningSettingsAction.PasswordAuthDone(password))
}
else -> {
else -> {
viewModel.handle(CrossSigningSettingsAction.ReAuthCancelled)
}
}
@ -78,7 +77,7 @@ class CrossSigningSettingsFragment @Inject constructor(
setupRecyclerView()
viewModel.observeViewEvents { event ->
when (event) {
is CrossSigningSettingsViewEvents.Failure -> {
is CrossSigningSettingsViewEvents.Failure -> {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.dialog_title_error)
.setMessage(errorFormatter.toHumanReadable(event.throwable))
@ -86,7 +85,7 @@ class CrossSigningSettingsFragment @Inject constructor(
.show()
Unit
}
is CrossSigningSettingsViewEvents.RequestReAuth -> {
is CrossSigningSettingsViewEvents.RequestReAuth -> {
ReAuthActivity.newIntent(requireContext(),
event.registrationFlowResponse,
event.lastErrorCode,
@ -98,7 +97,7 @@ class CrossSigningSettingsFragment @Inject constructor(
views.waitingView.waitingView.isVisible = true
views.waitingView.waitingStatusText.setTextOrHide(event.status)
}
CrossSigningSettingsViewEvents.HideModalWaitingView -> {
CrossSigningSettingsViewEvents.HideModalWaitingView -> {
views.waitingView.waitingView.isVisible = false
}
}.exhaustive

View file

@ -15,13 +15,13 @@
*/
package im.vector.app.features.settings.crosssigning
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider
@ -61,27 +61,27 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
) { myDevicesInfo, mxCrossSigningInfo ->
myDevicesInfo to mxCrossSigningInfo
}
.execute { data ->
val crossSigningKeys = data.invoke()?.second?.getOrNull()
val xSigningIsEnableInAccount = crossSigningKeys != null
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
.execute { data ->
val crossSigningKeys = data.invoke()?.second?.getOrNull()
val xSigningIsEnableInAccount = crossSigningKeys != null
val xSigningKeysAreTrusted = session.cryptoService().crossSigningService().checkUserTrust(session.myUserId).isVerified()
val xSigningKeyCanSign = session.cryptoService().crossSigningService().canCrossSign()
copy(
crossSigningInfo = crossSigningKeys,
xSigningIsEnableInAccount = xSigningIsEnableInAccount,
xSigningKeysAreTrusted = xSigningKeysAreTrusted,
xSigningKeyCanSign = xSigningKeyCanSign
)
}
copy(
crossSigningInfo = crossSigningKeys,
xSigningIsEnableInAccount = xSigningIsEnableInAccount,
xSigningKeysAreTrusted = xSigningKeysAreTrusted,
xSigningKeyCanSign = xSigningKeyCanSign
)
}
}
var uiaContinuation: Continuation<UIABaseAuth>? = null
var pendingAuth: UIABaseAuth? = null
@AssistedFactory
interface Factory {
fun create(initialState: CrossSigningSettingsViewState): CrossSigningSettingsViewModel
interface Factory : MavericksAssistedViewModelFactory<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> {
override fun create(initialState: CrossSigningSettingsViewState): CrossSigningSettingsViewModel
}
override fun handle(action: CrossSigningSettingsAction) {
@ -154,12 +154,5 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
_viewEvents.post(CrossSigningSettingsViewEvents.Failure(Exception(stringProvider.getString(R.string.failed_to_initialize_cross_signing))))
}
companion object : MavericksViewModelFactory<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: CrossSigningSettingsViewState): CrossSigningSettingsViewModel? {
val fragment: CrossSigningSettingsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<CrossSigningSettingsViewModel, CrossSigningSettingsViewState> by hiltMavericksViewModelFactory()
}

View file

@ -18,17 +18,17 @@ package im.vector.app.features.settings.devices
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
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.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.auth.ReAuthActivity
@ -97,18 +97,11 @@ class DevicesViewModel @AssistedInject constructor(
var pendingAuth: UIABaseAuth? = null
@AssistedFactory
interface Factory {
fun create(initialState: DevicesViewState): DevicesViewModel
interface Factory: MavericksAssistedViewModelFactory<DevicesViewModel,DevicesViewState> {
override fun create(initialState: DevicesViewState): DevicesViewModel
}
companion object : MavericksViewModelFactory<DevicesViewModel, DevicesViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: DevicesViewState): DevicesViewModel? {
val fragment: VectorSettingsDevicesFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.devicesViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<DevicesViewModel, DevicesViewState> by hiltMavericksViewModelFactory()
private val refreshPublisher: PublishSubject<Unit> = PublishSubject.create()

View file

@ -47,7 +47,6 @@ import javax.inject.Inject
* Display the list of the user's device
*/
class VectorSettingsDevicesFragment @Inject constructor(
val devicesViewModelFactory: DevicesViewModel.Factory,
private val devicesController: DevicesController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
DevicesController.Callback {

View file

@ -37,7 +37,6 @@ import org.matrix.android.sdk.internal.di.MoshiProvider
import javax.inject.Inject
class AccountDataFragment @Inject constructor(
val viewModelFactory: AccountDataViewModel.Factory,
private val epoxyController: AccountDataEpoxyController,
private val colorProvider: ColorProvider
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),

View file

@ -17,14 +17,14 @@
package im.vector.app.features.settings.devtools
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
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.extensions.exhaustive
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -61,16 +61,9 @@ class AccountDataViewModel @AssistedInject constructor(@Assisted initialState: A
}
@AssistedFactory
interface Factory {
fun create(initialState: AccountDataViewState): AccountDataViewModel
interface Factory: MavericksAssistedViewModelFactory<AccountDataViewModel,AccountDataViewState> {
override fun create(initialState: AccountDataViewState): AccountDataViewModel
}
companion object : MavericksViewModelFactory<AccountDataViewModel, AccountDataViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: AccountDataViewState): AccountDataViewModel? {
val fragment: AccountDataFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<AccountDataViewModel, AccountDataViewState> by hiltMavericksViewModelFactory()
}

View file

@ -34,7 +34,6 @@ import org.matrix.android.sdk.api.session.events.model.Event
import javax.inject.Inject
class GossipingEventsPaperTrailFragment @Inject constructor(
val viewModelFactory: GossipingEventsPaperTrailViewModel.Factory,
private val epoxyController: GossipingTrailPagedEpoxyController,
private val colorProvider: ColorProvider
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),

View file

@ -19,15 +19,15 @@ package im.vector.app.features.settings.devtools
import androidx.lifecycle.asFlow
import androidx.paging.PagedList
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -60,17 +60,9 @@ class GossipingEventsPaperTrailViewModel @AssistedInject constructor(@Assisted i
override fun handle(action: EmptyAction) {}
@AssistedFactory
interface Factory {
fun create(initialState: GossipingEventsPaperTrailState): GossipingEventsPaperTrailViewModel
interface Factory: MavericksAssistedViewModelFactory<GossipingEventsPaperTrailViewModel,GossipingEventsPaperTrailState> {
override fun create(initialState: GossipingEventsPaperTrailState): GossipingEventsPaperTrailViewModel
}
companion object : MavericksViewModelFactory<GossipingEventsPaperTrailViewModel, GossipingEventsPaperTrailState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: GossipingEventsPaperTrailState): GossipingEventsPaperTrailViewModel? {
val fragment: GossipingEventsPaperTrailFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<GossipingEventsPaperTrailViewModel, GossipingEventsPaperTrailState> by hiltMavericksViewModelFactory()
}

View file

@ -30,7 +30,6 @@ import im.vector.app.databinding.FragmentGenericRecyclerBinding
import javax.inject.Inject
class IncomingKeyRequestListFragment @Inject constructor(
val viewModelFactory: KeyRequestListViewModel.Factory,
private val epoxyController: IncomingKeyRequestPagedController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>() {

View file

@ -17,17 +17,16 @@
package im.vector.app.features.settings.devtools
import androidx.lifecycle.asFlow
import androidx.lifecycle.viewModelScope
import androidx.paging.PagedList
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
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.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -43,7 +42,7 @@ data class KeyRequestListViewState(
class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState: KeyRequestListViewState,
private val session: Session) :
VectorViewModel<KeyRequestListViewState, EmptyAction, EmptyViewEvents>(initialState) {
VectorViewModel<KeyRequestListViewState, EmptyAction, EmptyViewEvents>(initialState) {
init {
refresh()
@ -67,19 +66,9 @@ class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState
override fun handle(action: EmptyAction) {}
@AssistedFactory
interface Factory {
fun create(initialState: KeyRequestListViewState): KeyRequestListViewModel
interface Factory : MavericksAssistedViewModelFactory<KeyRequestListViewModel, KeyRequestListViewState> {
override fun create(initialState: KeyRequestListViewState): KeyRequestListViewModel
}
companion object : MavericksViewModelFactory<KeyRequestListViewModel, KeyRequestListViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: KeyRequestListViewState): KeyRequestListViewModel? {
val context = viewModelContext as FragmentViewModelContext
val factory = (context.fragment as? IncomingKeyRequestListFragment)?.viewModelFactory
?: (context.fragment as? OutgoingKeyRequestListFragment)?.viewModelFactory
return factory?.create(state)
}
}
companion object : MavericksViewModelFactory<KeyRequestListViewModel, KeyRequestListViewState> by hiltMavericksViewModelFactory()
}

View file

@ -17,19 +17,18 @@
package im.vector.app.features.settings.devtools
import android.net.Uri
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewEvents
import im.vector.app.core.platform.VectorViewModel
@ -56,18 +55,11 @@ class KeyRequestViewModel @AssistedInject constructor(
VectorViewModel<KeyRequestViewState, KeyRequestAction, KeyRequestEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: KeyRequestViewState): KeyRequestViewModel
interface Factory: MavericksAssistedViewModelFactory<KeyRequestViewModel,KeyRequestViewState> {
override fun create(initialState: KeyRequestViewState): KeyRequestViewModel
}
companion object : MavericksViewModelFactory<KeyRequestViewModel, KeyRequestViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: KeyRequestViewState): KeyRequestViewModel? {
val fragment: KeyRequestsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<KeyRequestViewModel, KeyRequestViewState> by hiltMavericksViewModelFactory()
override fun handle(action: KeyRequestAction) {
when (action) {

View file

@ -41,8 +41,7 @@ import im.vector.app.databinding.FragmentDevtoolKeyrequestsBinding
import org.matrix.android.sdk.api.extensions.tryOrNull
import javax.inject.Inject
class KeyRequestsFragment @Inject constructor(
val viewModelFactory: KeyRequestViewModel.Factory) : VectorBaseFragment<FragmentDevtoolKeyrequestsBinding>() {
class KeyRequestsFragment @Inject constructor() : VectorBaseFragment<FragmentDevtoolKeyrequestsBinding>() {
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentDevtoolKeyrequestsBinding {
return FragmentDevtoolKeyrequestsBinding.inflate(inflater, container, false)

View file

@ -29,7 +29,6 @@ import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentGenericRecyclerBinding
import javax.inject.Inject
class OutgoingKeyRequestListFragment @Inject constructor(
val viewModelFactory: KeyRequestListViewModel.Factory,
private val epoxyController: OutgoingKeyRequestPagedController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>() {

View file

@ -34,7 +34,6 @@ import javax.inject.Inject
* Display some information about the homeserver
*/
class HomeserverSettingsFragment @Inject constructor(
val homeserverSettingsViewModelFactory: HomeserverSettingsViewModel.Factory,
private val homeserverSettingsController: HomeserverSettingsController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
HomeserverSettingsController.Callback {

View file

@ -16,16 +16,15 @@
package im.vector.app.features.settings.homeserver
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.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import kotlinx.coroutines.launch
@ -37,18 +36,11 @@ class HomeserverSettingsViewModel @AssistedInject constructor(
) : VectorViewModel<HomeServerSettingsViewState, HomeserverSettingsAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: HomeServerSettingsViewState): HomeserverSettingsViewModel
interface Factory: MavericksAssistedViewModelFactory<HomeserverSettingsViewModel,HomeServerSettingsViewState> {
override fun create(initialState: HomeServerSettingsViewState): HomeserverSettingsViewModel
}
companion object : MavericksViewModelFactory<HomeserverSettingsViewModel, HomeServerSettingsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: HomeServerSettingsViewState): HomeserverSettingsViewModel? {
val fragment: HomeserverSettingsFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.homeserverSettingsViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<HomeserverSettingsViewModel, HomeServerSettingsViewState> by hiltMavericksViewModelFactory()
init {
setState {

View file

@ -52,7 +52,7 @@ class IgnoredUsersViewModel @AssistedInject constructor(@Assisted initialState:
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<IgnoredUsersViewModel,IgnoredUsersViewState> {
override fun create(state: IgnoredUsersViewState): IgnoredUsersViewModel
override fun create(initialState: IgnoredUsersViewState): IgnoredUsersViewModel
}
companion object : MavericksViewModelFactory<IgnoredUsersViewModel, IgnoredUsersViewState> by hiltMavericksViewModelFactory()

View file

@ -34,10 +34,8 @@ import java.util.Locale
import javax.inject.Inject
class LocalePickerFragment @Inject constructor(
private val viewModelFactory: LocalePickerViewModel.Factory,
private val controller: LocalePickerController
) : VectorBaseFragment<FragmentLocalePickerBinding>(),
LocalePickerViewModel.Factory by viewModelFactory,
LocalePickerController.Listener {
private val viewModel: LocalePickerViewModel by fragmentViewModel()

View file

@ -16,15 +16,13 @@
package im.vector.app.features.settings.locale
import androidx.lifecycle.viewModelScope
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.FragmentViewModelContext
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 im.vector.app.features.configuration.VectorConfiguration
@ -37,8 +35,8 @@ class LocalePickerViewModel @AssistedInject constructor(
) : VectorViewModel<LocalePickerViewState, LocalePickerAction, LocalePickerViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: LocalePickerViewState): LocalePickerViewModel
interface Factory : MavericksAssistedViewModelFactory<LocalePickerViewModel, LocalePickerViewState> {
override fun create(initialState: LocalePickerViewState): LocalePickerViewModel
}
init {
@ -53,17 +51,7 @@ class LocalePickerViewModel @AssistedInject constructor(
}
}
companion object : MavericksViewModelFactory<LocalePickerViewModel, LocalePickerViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: LocalePickerViewState): LocalePickerViewModel? {
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<LocalePickerViewModel, LocalePickerViewState> by hiltMavericksViewModelFactory()
override fun handle(action: LocalePickerAction) {
when (action) {

View file

@ -36,7 +36,6 @@ import javax.inject.Inject
// Referenced in vector_settings_notifications.xml
class PushGatewaysFragment @Inject constructor(
val pushGatewaysViewModelFactory: PushGatewaysViewModel.Factory,
private val epoxyController: PushGateWayController
) : VectorBaseFragment<FragmentGenericRecyclerBinding>() {

View file

@ -17,14 +17,14 @@
package im.vector.app.features.settings.push
import com.airbnb.mvrx.Async
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
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.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import kotlinx.coroutines.launch
@ -38,21 +38,14 @@ data class PushGatewayViewState(
class PushGatewaysViewModel @AssistedInject constructor(@Assisted initialState: PushGatewayViewState,
private val session: Session) :
VectorViewModel<PushGatewayViewState, PushGatewayAction, PushGatewayViewEvents>(initialState) {
VectorViewModel<PushGatewayViewState, PushGatewayAction, PushGatewayViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: PushGatewayViewState): PushGatewaysViewModel
interface Factory : MavericksAssistedViewModelFactory<PushGatewaysViewModel, PushGatewayViewState> {
override fun create(initialState: PushGatewayViewState): PushGatewaysViewModel
}
companion object : MavericksViewModelFactory<PushGatewaysViewModel, PushGatewayViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: PushGatewayViewState): PushGatewaysViewModel? {
val fragment: PushGatewaysFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.pushGatewaysViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<PushGatewaysViewModel, PushGatewayViewState> by hiltMavericksViewModelFactory()
init {
observePushers()

View file

@ -43,12 +43,10 @@ import org.matrix.android.sdk.api.session.identity.ThreePid
import javax.inject.Inject
class ThreePidsSettingsFragment @Inject constructor(
private val viewModelFactory: ThreePidsSettingsViewModel.Factory,
private val epoxyController: ThreePidsSettingsController
) :
VectorBaseFragment<FragmentGenericRecyclerBinding>(),
OnBackPressed,
ThreePidsSettingsViewModel.Factory by viewModelFactory,
ThreePidsSettingsController.InteractionListener {
private val viewModel: ThreePidsSettingsViewModel by fragmentViewModel()

View file

@ -16,16 +16,15 @@
package im.vector.app.features.settings.threepids
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.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
@ -79,21 +78,11 @@ class ThreePidsSettingsViewModel @AssistedInject constructor(
}
@AssistedFactory
interface Factory {
fun create(initialState: ThreePidsSettingsViewState): ThreePidsSettingsViewModel
interface Factory : MavericksAssistedViewModelFactory<ThreePidsSettingsViewModel, ThreePidsSettingsViewState> {
override fun create(initialState: ThreePidsSettingsViewState): ThreePidsSettingsViewModel
}
companion object : MavericksViewModelFactory<ThreePidsSettingsViewModel, ThreePidsSettingsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: ThreePidsSettingsViewState): ThreePidsSettingsViewModel? {
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<ThreePidsSettingsViewModel, ThreePidsSettingsViewState> by hiltMavericksViewModelFactory()
init {
observeThreePids()

View file

@ -50,7 +50,6 @@ import javax.inject.Inject
* The user can select multiple rooms to send the data to
*/
class IncomingShareFragment @Inject constructor(
val incomingShareViewModelFactory: IncomingShareViewModel.Factory,
private val incomingShareController: IncomingShareController,
private val sessionHolder: ActiveSessionHolder
) :

View file

@ -16,12 +16,12 @@
package im.vector.app.features.share
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.toggle
import im.vector.app.core.platform.VectorViewModel
@ -46,18 +46,11 @@ class IncomingShareViewModel @AssistedInject constructor(
VectorViewModel<IncomingShareViewState, IncomingShareAction, IncomingShareViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: IncomingShareViewState): IncomingShareViewModel
interface Factory: MavericksAssistedViewModelFactory<IncomingShareViewModel,IncomingShareViewState> {
override fun create(initialState: IncomingShareViewState): IncomingShareViewModel
}
companion object : MavericksViewModelFactory<IncomingShareViewModel, IncomingShareViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: IncomingShareViewState): IncomingShareViewModel? {
val fragment: IncomingShareFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.incomingShareViewModelFactory.create(state)
}
}
companion object : MavericksViewModelFactory<IncomingShareViewModel, IncomingShareViewState> by hiltMavericksViewModelFactory()
private val filterStream = MutableStateFlow("")

View file

@ -43,7 +43,6 @@ class SoftLogoutActivity : LoginActivity() {
private val softLogoutViewModel: SoftLogoutViewModel by viewModel()
@Inject lateinit var softLogoutViewModelFactory: SoftLogoutViewModel.Factory
@Inject lateinit var session: Session
@Inject lateinit var errorFormatter: ErrorFormatter

View file

@ -27,6 +27,8 @@ 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.extensions.hasUnsavedKeys
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.login.LoginMode
@ -47,11 +49,11 @@ class SoftLogoutViewModel @AssistedInject constructor(
) : VectorViewModel<SoftLogoutViewState, SoftLogoutAction, SoftLogoutViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: SoftLogoutViewState): SoftLogoutViewModel
interface Factory: MavericksAssistedViewModelFactory<SoftLogoutViewModel,SoftLogoutViewState> {
override fun create(initialState: SoftLogoutViewState): SoftLogoutViewModel
}
companion object : MavericksViewModelFactory<SoftLogoutViewModel, SoftLogoutViewState> {
companion object : MavericksViewModelFactory<SoftLogoutViewModel, SoftLogoutViewState> by hiltMavericksViewModelFactory(){
override fun initialState(viewModelContext: ViewModelContext): SoftLogoutViewState? {
val activity: SoftLogoutActivity = (viewModelContext as ActivityViewModelContext).activity()
@ -65,11 +67,6 @@ class SoftLogoutViewModel @AssistedInject constructor(
)
}
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: SoftLogoutViewState): SoftLogoutViewModel? {
val activity: SoftLogoutActivity = (viewModelContext as ActivityViewModelContext).activity()
return activity.softLogoutViewModelFactory.create(state)
}
}
init {

View file

@ -68,7 +68,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceListViewModel, SpaceListViewState> {
override fun create(state: SpaceListViewState): SpaceListViewModel
override fun create(initialState: SpaceListViewState): SpaceListViewModel
}
companion object : MavericksViewModelFactory<SpaceListViewModel, SpaceListViewState> by hiltMavericksViewModelFactory()

View file

@ -16,18 +16,17 @@
package im.vector.app.features.spaces
import com.airbnb.mvrx.ActivityViewModelContext
import com.airbnb.mvrx.Fail
import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.Loading
import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized
import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.AppStateHandler
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.powerlevel.PowerLevelsFlowFactory
@ -52,21 +51,11 @@ class SpaceMenuViewModel @AssistedInject constructor(
) : VectorViewModel<SpaceMenuState, SpaceLeaveViewAction, EmptyViewEvents>(initialState) {
@AssistedFactory
interface Factory {
fun create(initialState: SpaceMenuState): SpaceMenuViewModel
interface Factory: MavericksAssistedViewModelFactory<SpaceMenuViewModel,SpaceMenuState> {
override fun create(initialState: SpaceMenuState): SpaceMenuViewModel
}
companion object : MavericksViewModelFactory<SpaceMenuViewModel, SpaceMenuState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: SpaceMenuState): SpaceMenuViewModel? {
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<SpaceMenuViewModel, SpaceMenuState> by hiltMavericksViewModelFactory()
init {
val roomSummary = session.getRoomSummary(initialState.spaceId)

View file

@ -46,12 +46,11 @@ data class SpaceBottomSheetSettingsArgs(
val spaceId: String
) : Parcelable
class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpaceSettingsBinding>(), SpaceMenuViewModel.Factory {
class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpaceSettingsBinding>(){
@Inject lateinit var navigator: Navigator
@Inject lateinit var avatarRenderer: AvatarRenderer
@Inject lateinit var bugReporter: BugReporter
@Inject lateinit var viewModelFactory: SpaceMenuViewModel.Factory
private val spaceArgs: SpaceBottomSheetSettingsArgs by args()
@ -139,8 +138,4 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomS
}
}
}
override fun create(initialState: SpaceMenuState): SpaceMenuViewModel {
return viewModelFactory.create(initialState)
}
}

View file

@ -76,7 +76,7 @@ class CreateSpaceViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<CreateSpaceViewModel,CreateSpaceState> {
override fun create(state: CreateSpaceState): CreateSpaceViewModel
override fun create(initialState: CreateSpaceState): CreateSpaceViewModel
}
private fun startListenToIdentityManager() {

View file

@ -52,7 +52,7 @@ class SpaceDirectoryViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceDirectoryViewModel,SpaceDirectoryState> {
override fun create(state: SpaceDirectoryState): SpaceDirectoryViewModel
override fun create(initialState: SpaceDirectoryState): SpaceDirectoryViewModel
}
companion object : MavericksViewModelFactory<SpaceDirectoryViewModel, SpaceDirectoryState> by hiltMavericksViewModelFactory()

View file

@ -96,7 +96,7 @@ class SpaceInviteBottomSheetViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceInviteBottomSheetViewModel,SpaceInviteBottomSheetState> {
override fun create(state: SpaceInviteBottomSheetState): SpaceInviteBottomSheetViewModel
override fun create(initialState: SpaceInviteBottomSheetState): SpaceInviteBottomSheetViewModel
}
companion object : MavericksViewModelFactory<SpaceInviteBottomSheetViewModel, SpaceInviteBottomSheetState> by hiltMavericksViewModelFactory()

View file

@ -127,7 +127,7 @@ class SpaceLeaveAdvancedViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceLeaveAdvancedViewModel, SpaceLeaveAdvanceViewState> {
override fun create(state: SpaceLeaveAdvanceViewState): SpaceLeaveAdvancedViewModel
override fun create(initialState: SpaceLeaveAdvanceViewState): SpaceLeaveAdvancedViewModel
}
companion object : MavericksViewModelFactory<SpaceLeaveAdvancedViewModel, SpaceLeaveAdvanceViewState> by hiltMavericksViewModelFactory()

View file

@ -58,7 +58,7 @@ class SpaceAddRoomsViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceAddRoomsViewModel,SpaceAddRoomsState> {
override fun create(state: SpaceAddRoomsState): SpaceAddRoomsViewModel
override fun create(initialState: SpaceAddRoomsState): SpaceAddRoomsViewModel
}
companion object : MavericksViewModelFactory<SpaceAddRoomsViewModel, SpaceAddRoomsState> by hiltMavericksViewModelFactory()

View file

@ -55,7 +55,7 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceManageRoomsViewModel, SpaceManageRoomViewState> {
override fun create(state: SpaceManageRoomViewState): SpaceManageRoomsViewModel
override fun create(initialState: SpaceManageRoomViewState): SpaceManageRoomsViewModel
}
companion object : MavericksViewModelFactory<SpaceManageRoomsViewModel, SpaceManageRoomViewState> by hiltMavericksViewModelFactory()

View file

@ -33,7 +33,7 @@ class SpaceManageSharedViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpaceManageSharedViewModel,SpaceManageViewState>{
override fun create(state: SpaceManageViewState): SpaceManageSharedViewModel
override fun create(initialState: SpaceManageViewState): SpaceManageSharedViewModel
}
companion object : MavericksViewModelFactory<SpaceManageSharedViewModel, SpaceManageViewState> by hiltMavericksViewModelFactory()

View file

@ -59,11 +59,9 @@ import javax.inject.Inject
class SpaceSettingsFragment @Inject constructor(
private val epoxyController: SpaceSettingsController,
private val colorProvider: ColorProvider,
val viewModelFactory: RoomSettingsViewModel.Factory,
private val avatarRenderer: AvatarRenderer,
private val drawableProvider: DrawableProvider
) : VectorBaseFragment<FragmentRoomSettingGenericBinding>(),
RoomSettingsViewModel.Factory,
SpaceSettingsController.Callback,
GalleryOrCameraDialogHelper.Listener,
OnBackPressed {
@ -81,9 +79,6 @@ class SpaceSettingsFragment @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)

View file

@ -44,12 +44,10 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject
class SpacePeopleFragment @Inject constructor(
private val roomMemberModelFactory: RoomMemberListViewModel.Factory,
private val drawableProvider: DrawableProvider,
private val colorProvider: ColorProvider,
private val epoxyController: SpacePeopleListController
) : VectorBaseFragment<FragmentRecyclerviewWithSearchBinding>(),
RoomMemberListViewModel.Factory,
OnBackPressed, SpacePeopleListController.InteractionListener {
private val viewModel by fragmentViewModel(SpacePeopleViewModel::class)
@ -64,10 +62,6 @@ class SpacePeopleFragment @Inject constructor(
return true
}
override fun create(initialState: RoomMemberListViewState): RoomMemberListViewModel {
return roomMemberModelFactory.create(initialState)
}
override fun invalidate() = withState(membersViewModel) { memberListState ->
views.appBarTitle.text = getString(R.string.bottom_action_people)
val memberCount = (memberListState.roomSummary.invoke()?.otherMemberIds?.size ?: 0) + 1

View file

@ -43,7 +43,7 @@ class SpacePeopleViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpacePeopleViewModel,SpacePeopleViewState> {
override fun create(state: SpacePeopleViewState): SpacePeopleViewModel
override fun create(initialState: SpacePeopleViewState): SpacePeopleViewModel
}
companion object : MavericksViewModelFactory<SpacePeopleViewModel, SpacePeopleViewState> by hiltMavericksViewModelFactory()

View file

@ -61,7 +61,7 @@ class SpacePreviewViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SpacePreviewViewModel,SpacePreviewState> {
override fun create(state: SpacePreviewState): SpacePreviewViewModel
override fun create(initialState: SpacePreviewState): SpacePreviewViewModel
}
companion object : MavericksViewModelFactory<SpacePreviewViewModel, SpacePreviewState> by hiltMavericksViewModelFactory()

View file

@ -38,7 +38,7 @@ class ShareSpaceViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ShareSpaceViewModel,ShareSpaceViewState> {
override fun create(state: ShareSpaceViewState): ShareSpaceViewModel
override fun create(initialState: ShareSpaceViewState): ShareSpaceViewModel
}
companion object : MavericksViewModelFactory<ShareSpaceViewModel, ShareSpaceViewState> by hiltMavericksViewModelFactory()

View file

@ -37,7 +37,7 @@ class ReviewTermsViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ReviewTermsViewModel,ReviewTermsViewState> {
override fun create(state: ReviewTermsViewState): ReviewTermsViewModel
override fun create(initialState: ReviewTermsViewState): ReviewTermsViewModel
}
companion object : MavericksViewModelFactory<ReviewTermsViewModel, ReviewTermsViewState> by hiltMavericksViewModelFactory()

View file

@ -57,7 +57,7 @@ class UserCodeSharedViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<UserCodeSharedViewModel,UserCodeState> {
override fun create(state: UserCodeState): UserCodeSharedViewModel
override fun create(initialState: UserCodeState): UserCodeSharedViewModel
}
override fun handle(action: UserCodeActions) {

View file

@ -64,7 +64,7 @@ class UserListViewModel @AssistedInject constructor(@Assisted initialState: User
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<UserListViewModel,UserListViewState> {
override fun create(state: UserListViewState): UserListViewModel
override fun create(initialState: UserListViewState): UserListViewModel
}
companion object : MavericksViewModelFactory<UserListViewModel, UserListViewState> by hiltMavericksViewModelFactory()

View file

@ -60,7 +60,7 @@ class WidgetViewModel @AssistedInject constructor(@Assisted val initialState: Wi
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<WidgetViewModel,WidgetViewState> {
override fun create(state: WidgetViewState): WidgetViewModel
override fun create(initialState: WidgetViewState): WidgetViewModel
}
companion object : MavericksViewModelFactory<WidgetViewModel, WidgetViewState> by hiltMavericksViewModelFactory()

View file

@ -143,7 +143,7 @@ class RoomWidgetPermissionViewModel @AssistedInject constructor(@Assisted val in
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<RoomWidgetPermissionViewModel,RoomWidgetPermissionViewState> {
override fun create(state: RoomWidgetPermissionViewState): RoomWidgetPermissionViewModel
override fun create(initialState: RoomWidgetPermissionViewState): RoomWidgetPermissionViewModel
}
companion object : MavericksViewModelFactory<RoomWidgetPermissionViewModel, RoomWidgetPermissionViewState> by hiltMavericksViewModelFactory()

View file

@ -70,7 +70,7 @@ class ServerBackupStatusViewModel @AssistedInject constructor(@Assisted initialS
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<ServerBackupStatusViewModel,ServerBackupStatusViewState> {
override fun create(state: ServerBackupStatusViewState): ServerBackupStatusViewModel
override fun create(initialState: ServerBackupStatusViewState): ServerBackupStatusViewModel
}
companion object : MavericksViewModelFactory<ServerBackupStatusViewModel, ServerBackupStatusViewState> by hiltMavericksViewModelFactory()

View file

@ -69,7 +69,7 @@ class SignoutCheckViewModel @AssistedInject constructor(
@AssistedFactory
interface Factory: MavericksAssistedViewModelFactory<SignoutCheckViewModel,SignoutCheckViewState> {
override fun create(state: SignoutCheckViewState): SignoutCheckViewModel
override fun create(initialState: SignoutCheckViewState): SignoutCheckViewModel
}
companion object : MavericksViewModelFactory<SignoutCheckViewModel, SignoutCheckViewState> by hiltMavericksViewModelFactory()