package Ġcom . app . sky ss _ comp anion . view . stop _ place Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . app . sky ss _ comp anion . databinding . Stop Place Fragment Binding Ċ import Ġdagger . h ilt . android . Android EntryPoint Ċ import Ġcom . app . sky ss _ comp anion . R Ċ Ċ @ Android EntryPoint Ċ class ĠStop Place Fragment Ġ: ĠFragment () Ġ{ ĊĠĠĠ Ġval ĠTAG Ġ= Ġ" Search Stops Fragment " ĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠStop Place ViewModel Ġby Ġview Models () ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠStop Place Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes Adapter : ĠStop Place Line Code Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes Filter Adapter : ĠStop Place Filter Line Code Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġre cyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlayout Manager : ĠLinearLayoutManager ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes RecyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes LayoutManager : ĠLinearLayoutManager ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes Filter LayoutManager : ĠLinearLayoutManager ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġline Codes Filter RecyclerView : ĠRecyclerView ĊĠĠĠ Ġprivate Ġvar Ġ_ binding : ĠStop Place Fragment Binding ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġval Ġbinding Ġget () Ġ= Ġ_ binding !! ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ binding Ġ= ĠStop Place Fragment Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Activity Created ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠStop Place Adapter ( require Context (), Ġ:: navigate To Time Table ) ĊĠĠĠĠĠĠĠ Ġline Codes Adapter Ġ= ĠStop Place Line Code Adapter ( require Context (), ĠonTap Ġ= Ġ{ index Ġ-> ĠviewModel . add Line Code To Filter ( index )}) ĊĠĠĠĠĠĠĠ Ġline Codes Filter Adapter Ġ= ĠStop Place Filter Line Code Adapter ( require Context (), ĠonTap Ġ= Ġ{ index Ġ-> ĠviewModel . remove Line Code From Filter ( index )}) ĊĠĠĠĠĠĠĠ Ġre cyclerView Ġ= Ġbinding . stop Place Recycler view ĊĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( require Context ()) ĊĠĠĠĠĠĠĠ Ġre cyclerView . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġre cyclerView . layout Manager Ġ= Ġlayout Manager ĊĠĠĠĠĠĠĠ Ġline Codes RecyclerView Ġ= Ġbinding . stop Place Line codes Recycler view ĊĠĠĠĠĠĠĠ Ġline Codes Filter RecyclerView Ġ= Ġbinding . stop Place Recycler view Line code Filter ĊĠĠĠĠĠĠĠ Ġval Ġidentifier Ġ= Ġarguments ?. getString (" STOP _ IDENTIFIER ") ĊĊĠĠĠĠĠĠĠ Ġline Codes LayoutManager Ġ= ĠLinearLayoutManager ( context , ĠLinearLayoutManager . HORIZONTAL , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġline Codes Filter LayoutManager Ġ= ĠLinearLayoutManager ( context , ĠLinearLayoutManager . HORIZONTAL , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġline Codes RecyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= Ġline Codes LayoutManager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġline Codes Adapter ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġline Codes Filter RecyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= Ġline Codes Filter LayoutManager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġline Codes Filter Adapter ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġif ( identifier Ġ!= Ġnull ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Active . setOnClickListener Ġ{ ĠviewModel . remove F avor ited ( identifier ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Inactive . setOnClickListener Ġ{ ĠviewModel . add F avor ited ( identifier ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . check Is F avor ited ( identifier ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . fetch Stop Place ( identifier ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . stop Group . observe ( view Lifecycle Owner , Ġ{ Ġstop Group Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Text view Name . text Ġ= Ġstop Group . description ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . filtered Stop Place List Items . observe ( view Lifecycle Owner , Ġ{ Ġlist Items Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . setData ( list Items ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . line Code Filter . observe ( view Lifecycle Owner , Ġ{ Ġfilter Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif ( filter . isEmpty ()) Ġline Codes Filter RecyclerView . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġline Codes Filter RecyclerView . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġline Codes Filter Adapter . setData ( filter ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . line Codes . observe ( view Lifecycle Owner , Ġ{ Ġline Codes Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġline Codes Adapter . setData ( line Codes ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel . isLoading . observe ( view Lifecycle Owner , Ġ{ Ġvalue Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( value ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . progress Bar . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Text view Name . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif (! value ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . progress Bar . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Text view Name . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . is Book marked . observe ( view Lifecycle Owner , Ġ{ Ġvalue Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( value ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Active . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Inactive . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Active . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Bookmark Inactive . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġbinding . stop Place Back Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). pop Back Stack () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . stop Place Image button Refresh . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġidentifier ?. let Ġ{ ĠviewModel . fetch Stop Place ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġnavigate To Time Table ( stop Identifier : ĠString ?, Ġroute Direction Identifier : ĠString ?, Ġstop Name : ĠString ?, Ġdirection Name : ĠString ?, ĠlineNumber : ĠString ? ){ ĊĠĠĠĠĠĠĠ Ġif ( stop Identifier Ġ!= Ġnull Ġ&& Ġroute Direction Identifier Ġ!= Ġnull ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . putString (" STOP _ IDENTIFIER ", Ġstop Identifier ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . putString (" ROUTE _ DIRECTION _ IDENTIFIER ", Ġroute Direction Identifier ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . putString (" STOP GROUP _ NAME ", Ġstop Name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . putString (" ROUTE _ DIRECTION _ NAME ", Ġdirection Name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . putString (" LINE _ NUMBER ", ĠlineNumber ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( R . id . action _ stop Place Fragment _ to _ route Direction Time Table Fragment , Ġbundle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }