package Ġcom . re vol gen x . an ilib . user . view model Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . re vol gen x . an ilib . common . view model . Base ViewModel Ċ import Ġcom . re vol gen x . an ilib . common . repository . util . Resource Ċ import Ġcom . re vol gen x . an ilib . infrastructure . service . toggle . Toggle Service Ċ import Ġcom . re vol gen x . an ilib . user . data . field . User Toggle Follow Field Ċ import Ġcom . re vol gen x . an ilib . user . data . model . User Model Ċ Ċ class ĠUser Container Shared VM ( private Ġval Ġtoggle Service : ĠToggle Service ) Ġ: ĠBase ViewModel () Ġ{ ĊĠĠĠ Ġvar ĠuserId : ĠInt ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġset ( value ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfield Ġ= Ġvalue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoggle Follow Field . userId Ġ= Ġvalue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġvar ĠuserName : ĠString ? Ġ= Ġnull ĊĠĠĠĠĠĠĠ Ġset ( value ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfield Ġ= Ġvalue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoggle Follow Field . userName Ġ= Ġvalue ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġhas UserData Ġget () Ġ= Ġ( userId Ġ?: ĠuserName ) Ġ!= Ġnull ĊĠĠĠ Ġprivate Ġval Ġtoggle Follow Field Ġ= ĠUser Toggle Follow Field () ĊĊĠĠĠ Ġval Ġuser LiveData Ġ= ĠMutable LiveData < Resource < User Model >>() ĊĠĠĠ Ġval Ġtoggle Follow LiveData Ġ= ĠMutable LiveData < Resource < User Model >>() ĊĊĠĠĠ Ġfun Ġtoggle Follow () Ġ{ ĊĠĠĠĠĠĠĠ Ġtoggle Service . toggle User Follow ( toggle Follow Field , Ġcomposite Disposable ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġuser LiveData . value ?. data ?. is Following Ġ= Ġit . data ?. is Following Ġ== Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtoggle Follow LiveData . value Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }