app / com.ocean.ishareeconomy_android.viewmodels / AddLendingViewModel

AddLendingViewModel

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

Types

Factory

Factory for constructing AddLendingViewModel with parameters

class Factory : Factory

Constructors

<init>

AddLendingViewModel

AddLendingViewModel(application: Application, id: String, auth: String)

Properties

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?

Functions

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: 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: View): Unit