package Ġcom . lev im ore ira . team men ager app . organization . views ĊĊ Ċ import Ġandroid . arch . lifecycle . Lifecycle Owner Ċ import Ġandroid . arch . lifecycle . Observer Ċ import Ġandroid . arch . lifecycle . ViewModel Provider Ċ import Ġandroid . arch . lifecycle . ViewModel Providers Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . os . Proxy FileDescriptor Callback Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . navigation . find Nav Controller Ċ import Ġcom . lev im ore ira . team men ager app . R Ċ import Ġcom . lev im ore ira . team men ager app . application . entities . Organization Ċ import Ġcom . lev im ore ira . team men ager app . main . On Activity Callback Ċ import Ġcom . lev im ore ira . team men ager app . organization . adapters . Organization ListAdapter Ċ import Ġcom . lev im ore ira . team men ager app . organization . view model . Organization List ViewModel Ċ import Ġdagger . android . support . D agger Fragment Ċ import Ġkotlinx . android . synt hetic . main . fragment _ organization .* Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠA Ġsimple Ġ[ Fragment ] Ġsubclass . Ċ Ġ* Ċ Ġ*/ Ċ class ĠOrganization List Fragment Ġ: ĠD agger Fragment (), ĠLifecycle Owner Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Provider . Factory ĊĊĠĠĠ Ġlateinit Ġvar ĠviewModel : ĠOrganization List ViewModel ĊĊĠĠĠ Ġlateinit Ġvar Ġadapter : ĠOrganization ListAdapter ĊĊĠĠĠ Ġvar Ġorganization List Ġ= Ġmutable ListOf < Organization >() ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Providers . of ( this , ĠviewModel Factory ). get ( Organization List ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠOrganization ListAdapter ( organization List ) ĊĠĠĠĠĠĠĠ Ġ// ĠInf late Ġthe Ġlayout Ġfor Ġthis Ġfragment ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ organization , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġadapter . click Listener Ġ= Ġ{ Ġperson Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this . context , Ġperson . name , ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġorganization RecyclerView . layout Manager Ġ= ĠLinearLayoutManager ( this . context ) ĊĠĠĠĠĠĠĠ Ġorganization RecyclerView . adapter Ġ= Ġadapter ĊĊĠĠĠĠĠĠĠ Ġadd Organization . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . find Nav Controller (). navigate ( R . id . action _ organization List Fragment _ to _ organization Add Fragment ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . getAll Organizations (). observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġorganization List . clear () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġorganization List . addAll ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . notify DataSet Changed () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠTAG Ġ= Ġ" Organization List Fragment " ĊĠĠĠ Ġ} Ċ Ċ } Ċ