Add @JvmStatic for performance reasons.

See https://github.com/airbnb/MvRx/wiki/Advanced-Concepts#mvrxviewmodel
This commit is contained in:
Benoit Marty 2019-12-18 16:03:10 +01:00
parent 9d26ba3186
commit c48a439eea
6 changed files with 6 additions and 0 deletions

View file

@ -102,6 +102,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
val quickEmojis = listOf("👍", "👎", "😄", "🎉", "😕", "❤️", "🚀", "👀")
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: MessageActionState): MessageActionsViewModel? {
val fragment: MessageActionsBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.messageActionViewModelFactory.create(state)

View file

@ -61,6 +61,7 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted
companion object : MvRxViewModelFactory<ViewEditHistoryViewModel, ViewEditHistoryViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: ViewEditHistoryViewState): ViewEditHistoryViewModel? {
val fragment: ViewEditHistoryBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewEditHistoryViewModelFactory.create(state)

View file

@ -68,6 +68,7 @@ class ViewReactionsViewModel @AssistedInject constructor(@Assisted
companion object : MvRxViewModelFactory<ViewReactionsViewModel, DisplayReactionsViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: DisplayReactionsViewState): ViewReactionsViewModel? {
val fragment: ViewReactionsBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.viewReactionsViewModelFactory.create(state)

View file

@ -37,6 +37,7 @@ class RoomListQuickActionsViewModel @AssistedInject constructor(@Assisted initia
companion object : MvRxViewModelFactory<RoomListQuickActionsViewModel, RoomListQuickActionsState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: RoomListQuickActionsState): RoomListQuickActionsViewModel? {
val fragment: RoomListQuickActionsBottomSheet = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.roomListActionsViewModelFactory.create(state)

View file

@ -42,6 +42,7 @@ class EmojiSearchResultViewModel @AssistedInject constructor(
companion object : MvRxViewModelFactory<EmojiSearchResultViewModel, EmojiSearchResultViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: EmojiSearchResultViewState): EmojiSearchResultViewModel? {
val activity: EmojiReactionPickerActivity = (viewModelContext as ActivityViewModelContext).activity()
return activity.emojiSearchResultViewModelFactory.create(state)

View file

@ -40,6 +40,7 @@ class PushGatewaysViewModel @AssistedInject constructor(@Assisted initialState:
companion object : MvRxViewModelFactory<PushGatewaysViewModel, PushGatewayViewState> {
@JvmStatic
override fun create(viewModelContext: ViewModelContext, state: PushGatewayViewState): PushGatewaysViewModel? {
val fragment: PushGatewaysFragment = (viewModelContext as FragmentViewModelContext).fragment()
return fragment.pushGatewaysViewModelFactory.create(state)