package Ġestimator . k is steam . com . estimator client Ċ Ċ import Ġandroid . arch . lifecycle . Observer Ċ import Ġandroid . arch . lifecycle . ViewModel Providers Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . view . View Ċ import Ġestimator . k is steam . com . estimator client . view . recycler . Rooms RecyclerView Adapter Ċ import Ġestimator . k is steam . com . estimator client . view model . Rooms ViewModel Ċ import Ġkotlinx . android . synt hetic . main . activity _ rooms .* ĊĊ Ċ /** Ċ Ġ* ĠCreated Ġby : Ġan na Ċ Ġ* ĠDate : Ġ 3 / 1 7 / 1 8 . Ċ Ġ*/ Ċ class ĠRoom s Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊ ĉ private Ġval ĠviewModel Class Ġ= ĠRoom s ViewModel :: class . java ĊĊ ĉ private Ġval Ġre cyclerView Adapter Ġ= ĠRoom s RecyclerView Adapter () ĊĊ ĉ private Ġfun Ġget Rooms ViewModel () Ġ= ĠViewModel Providers Ċĉĉ ĉ . of ( this ) Ċĉĉ ĉ . get ( viewModel Class ) ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ fun Ġcreate Intent ( context : ĠContext ) Ġ= Ċĉĉĉ ĉ Intent ( context , ĠRoom s Activity :: class . java ) Ċĉĉĉĉĉ ĉ . add Flags ( Intent . FLAG _ ACTIVITY _ CLEAR _ TOP ) Ċ ĉ } ĊĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ rooms ) Ċĉ ĉ this . recycler Rooms . layout Manager Ġ= ĠLinearLayoutManager ( this ) Ċĉ ĉ this . recycler Rooms . adapter Ġ= Ġthis . re cyclerView Adapter Ċĉ ĉ progress Bar . visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ btn Create Room . setOnClickListener Ġ{ Ċĉĉ ĉ startActivity ( Intent ( this , ĠCreate Room Activity :: class . java )) Ċĉ ĉ } Ċĉ ĉ get Rooms ViewModel () Ċĉĉĉ ĉ . room LiveData Ċĉĉĉ ĉ . observe ( this , ĠObserver Ġ{ Ċĉĉĉĉ ĉ if Ġ( it Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ if Ġ( it . isEmpty ()) Ġ{ Ċĉĉĉĉĉĉ ĉ placeholder . visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉĉ ĉ placeholder . visibility Ġ= ĠView . IN VISIBLE Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ progress Bar . visibility Ġ= ĠView . GONE Ċĉĉĉĉĉ ĉ this . re cyclerView Adapter . setData ( it ) Ċĉĉĉĉĉ ĉ this . re cyclerView Adapter . notify DataSet Changed () Ċĉĉĉĉ ĉ } Ġelse Ġ{ Ċĉĉĉĉĉ ĉ progress Bar . visibility Ġ= ĠView . VISIBLE Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ }) Ċĉ ĉ re cyclerView Adapter Ċĉĉĉ ĉ . clicked Room Ċĉĉĉ ĉ . observe ( this , ĠObserver Ġ{ Ċĉĉĉĉ ĉ if Ġ( it Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ startActivity ( Estimation Activity . create Intent ( this , Ġit )) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ }) Ċ ĉ } Ċ }