Create a generic class for ViewModel

This commit is contained in:
Benoit Marty 2020-12-02 15:47:21 +01:00
parent ee96d5c68f
commit f5af15454e
3 changed files with 34 additions and 18 deletions

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2020 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.core.ui.bottomsheet
import com.airbnb.mvrx.MvRxState
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
abstract class BottomSheetGenericViewModel<State : MvRxState>(initialState: State) :
VectorViewModel<State, EmptyAction, EmptyViewEvents>(initialState) {
override fun handle(action: EmptyAction) {
// No op
}
}

View File

@ -16,14 +16,7 @@
package im.vector.app.features.roomprofile.settings.historyvisibility
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericViewModel
class RoomHistoryVisibilityViewModel(initialState: RoomHistoryVisibilityState)
: VectorViewModel<RoomHistoryVisibilityState, EmptyAction, EmptyViewEvents>(initialState) {
override fun handle(action: EmptyAction) {
// No op
}
}
: BottomSheetGenericViewModel<RoomHistoryVisibilityState>(initialState)

View File

@ -16,14 +16,7 @@
package im.vector.app.features.roomprofile.settings.joinrule
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.ui.bottomsheet.BottomSheetGenericViewModel
class RoomJoinRuleViewModel(initialState: RoomJoinRuleState)
: VectorViewModel<RoomJoinRuleState, EmptyAction, EmptyViewEvents>(initialState) {
override fun handle(action: EmptyAction) {
// No op
}
}
: BottomSheetGenericViewModel<RoomJoinRuleState>(initialState)