class AddLendingViewModel : AndroidViewModel
Part of viewmodels.
The viewmodel that is used for the AddLending Screen, it enables the input of properties for the creation of new LendingObject, is aware of changes via two-way databinding and allows the creation when all conditions are satisfied.
Inherits from AndroidViewModel so that it remains unaffected by rotations
Factory |
Factory for constructing AddLendingViewModel with parameters class Factory : Factory |
<init> |
AddLendingViewModel AddLendingViewModel(: Application, : String, : String) |
colorSetter |
: SelectedColor the parent fragment, sets the type button background color var colorSetter: SelectedColor? |
description |
: String the new object's description var description: String? |
id |
: String the logged in user's id val id: String |
name |
: String the new object's name var name: String? |
navigateBack |
: OnShareListener the parent fragment, does the back navigation var navigateBack: OnShareListener? |
share |
: Boolean value continually updated to reflect whether the object can be created, or not var share: ObservableBoolean |
type |
: LendObjectType the new object's type var type: LendObjectType? |
onCleared |
Cancel all co-routines when the ViewModel is cleared fun onCleared(): Unit |
onShareBtnClick |
Method that's responsible for initiating the back navigation if all conditions are met it delegates to the parent fragment navigateBack, which is known under the OnShareListener interface fun onShareBtnClick(: View): Unit |
onTypeButtonClicked |
Method that's responsible for setting the type It also sets buttons color, indicating that it has been selected this is delegated to parent fragment colorSetter, which is known under the SelectedColor interface fun onTypeButtonClicked(: View): Unit |