package Ġcom . void sam ur ai . lord o ftime . fragments Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . void sam ur ai . lord o ftime . MainActivity Ċ import Ġcom . void sam ur ai . lord o ftime . R Ċ import Ġcom . void sam ur ai . lord o ftime . databinding . Fragment Colors List Binding Ċ import Ġcom . void sam ur ai . lord o ftime . fragments . adapters . Colors Adapter Ċ import Ġcom . void sam ur ai . lord o ftime . fragments . dialogs . Color Dialog Fragment ĊĊ Ċ class ĠColors List Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcolor Adapter : ĠColors Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcolor List : ĠRecyclerView ĊĊĠĠĠ Ġprivate Ġfun Ġfill Edit List ( query : Map < String , String > ){ ĊĠĠĠĠĠĠĠ Ġcolor Adapter Ġ= ĠColors Adapter ( require Activity (), query . toList ()) ĊĠĠĠĠĠĠĠ Ġcolor List . adapter = Ġcolor Adapter ĊĠĠĠĠĠĠĠ Ġcolor List . layout Manager = ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠ Ġcolor List . smooth Scroll To Position ( color List . adapter !!. item Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġvar Ġ_ binding : Fragment Colors List Binding ?= null ĊĠĠĠ Ġprivate Ġval Ġbinding Ġget () =_ binding !! ĊĊĠĠĠ Ġprivate Ġvar Ġdata : Mutable LiveData < Map < String , String >> Ġ= ĠMutable LiveData () ĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ binding = ĠFragment Colors List Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġdata =( activity Ġas ĠMainActivity ). get Colors () ĊĠĠĠĠĠĠĠ Ġcolor List = binding . colors List ĊĠĠĠĠĠĠĠ Ġ( activity Ġas ĠMainActivity ). get Colors (). observe ( view Lifecycle Owner ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfill Edit List ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . color Fab . setOnClickListener { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Dialog () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĠĠĠ Ġoverride Ġfun Ġon Destroy View () Ġ{ ĊĠĠĠĠĠĠĠ Ġ( activity Ġas ĠMainActivity ). get Colors (). remove Observer s ( view Lifecycle Owner ) ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġ_ binding = null ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Dialog (){ ĊĊĠĠĠĠĠĠĠ Ġval Ġft Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠColor Dialog Fragment ( R . layout . dialog _ fragment _ edit _ color _ category , ĠColor Dialog Fragment . SAVE ) ĊĠĠĠĠĠĠĠ Ġft . show ( require Activity (). support FragmentManager ," K ol or ") ĊĠĠĠ Ġ} Ċ }