package Ġcom . example . administrator . li ved ata demo . activity Ċ Ċ import Ġandroid . arch . lifecycle . Observer Ċ import Ġandroid . arch . lifecycle . ViewModel Providers Ċ import Ġandroid . databinding . Data Binding Util Ċ import Ġandroid . databinding . Observable Boolean Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . widget . Toast Ċ import Ġcom . example . administrator . li ved ata demo . R Ċ import Ġcom . example . administrator . li ved ata demo . databinding . Activity Main Binding Ċ import Ġcom . example . administrator . li ved ata demo . model . Auto Refresh Ċ import Ġcom . example . administrator . li ved ata demo . model . Data 1 Ċ import Ġcom . example . administrator . li ved ata demo . view model . Main ViewModel Ċ import Ġcom . example . administrator . li ved ata demo . view model . Main ViewModel Factory Ċ Ċ class ĠMainActivity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġvm : ĠMain ViewModel ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġval Ġview Data Binding Ġ= ĠData Binding Util . set ContentView < Activity Main Binding >( this , ĠR . layout . activity _ main ) ĊĠĠĠĠĠĠĠ Ġview Data Binding . rf Ġ= ĠAuto Refresh ( Observable Boolean ( false )) ĊĊĠĠĠĠĠĠĠ Ġvm Ġ= ĠViewModel Providers . of ( this , ĠMain ViewModel Factory ( view Data Binding . rf !! )). get ( Main ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġvm ?. responses ?. observe ( this , ĠObserver < ArrayList < Data 1 >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this , Ġ" å¾ĹåĪ° ç»ĵæŀľ ", ĠToast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvm ?. notify DataSet Changed ( it !! ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġview Data Binding . adapter Ġ= Ġvm ?. adapter ĊĊĠĠĠĠĠĠĠ Ġvm ?. id ?. value Ġ= Ġ" 1 " ĊĠĠĠ Ġ} Ċ } Ċ