package Ġcom . application . ar che lon . screens . survey . new _ event Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view .* Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . application . ar che lon . R Ċ import Ġcom . application . ar che lon . adapters . Menu List Option Adapter Ċ import Ġcom . application . ar che lon . interfaces . On Navigation ItemClickListener Ċ import Ġcom . application . ar che lon . models . Navigation Item Ċ import Ġcom . application . ar che lon . models . Navigation ItemType Ċ import Ġcom . application . ar che lon . extensions . replace Fragment Ċ import Ġcom . application . ar che lon . screens . survey . New Survey ViewModel Ċ import Ġcom . application . ar che lon . screens . survey . new _ event . in und ation _ or _ w ash . Event In und ation Or W ash Fragment Ċ import Ġcom . application . ar che lon . utils . Activity Util . show NotImplemented Toast Ċ import Ġkotlinx . android . synt hetic . main . fragment _ simple _ menu . view .* Ċ Ċ /** Ċ Ġ* ĠNew Event Menu Fragment Ċ Ġ* ĠThis Ġis Ġthe Ġfragment Ġrepresenting Ġthe Ġlist Ġof Ġoptions Ġfor Ġa Ġnew Ġevent Ġ( e . g . Ġevent Ġtypes ). Ċ Ġ*/ Ċ Ċ class ĠNew Event Menu Fragment Ġ: ĠFragment (), ĊĠĠĠ ĠOn Navigation ItemClickListener Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview Layout : ĠView ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠNew Survey ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠMenu List Option Adapter ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġactivity ?. run Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Provider ( this ). get ( New Survey ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġprepare Observer s () ĊĠĠĠĠĠĠĠ Ġload View ( in flater . inflate ( R . layout . fragment _ simple _ menu , Ġcontainer , Ġfalse )) ĊĠĠĠĠĠĠĠ ĠviewModel . setCurrent Title ( view Layout . context . getString ( R . string . new _ survey _ event _ new )) ĊĠĠĠĠĠĠĠ Ġreturn Ġview Layout ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Navigation Item Click ( view : ĠView , Ġitem : ĠNavigation Item ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠHandle Ġitem Ġselection Ġfor Ġeach Ġevent Ġtype ĊĠĠĠĠĠĠĠ Ġwhen Ġ( item . id ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation ItemType . SUR VE Y _ EVENT _ IN UND ATION _ OR _ W ASH Ġ-> Ġhandle New Event In und ation Or W ash () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġshow NotImplemented Toast ( view . context , Ġitem . title ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġload View ( view : ĠView ) Ġ{ ĊĠĠĠĠĠĠĠ Ġview Layout Ġ= Ġview ĊĠĠĠĠĠĠĠ Ġview Layout . menu Options . layout Manager Ġ= ĠLinearLayoutManager ( view Layout . context ) ĊĠĠĠĠĠĠĠ ĠviewModel . set New EventType Options ( view Layout . context ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġprepare Observer s () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . new EventType Options . observe ( view Lifecycle Owner , ĠObserver Ġ{ Ġoptions Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠMenu List Option Adapter ( options , Ġthis ); ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Layout . menu Options . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġhandle New Event In und ation Or W ash () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity ?. replace Fragment ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent In und ation Or W ash Fragment . newInstance (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . content Container , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent In und ation Or W ash Fragment . TAG ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance (): ĠNew Event Menu Fragment Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠNew Event Menu Fragment () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }