package Ġcom . l ub ul wa . k ul io . ui . main Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . design . widget . Snackbar Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . view . MenuItem Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Toast Ċ import Ġcom . l ub ul wa . k ul io . R Ċ import Ġcom . l ub ul wa . k ul io . base . Base Activity Ċ import Ġcom . l ub ul wa . k ul io . helpers . local . Constants Ċ import Ġcom . l ub ul wa . k ul io . helpers . local . K ul io U tl is Ċ import Ġcom . l ub ul wa . k ul io . model . Air port Ċ import Ġcom . l ub ul wa . k ul io . model . Fl ights Response Ċ import Ġcom . l ub ul wa . k ul io . model . Schedule Ċ import Ġcom . l ub ul wa . k ul io . presenter . Search Fl ights Presenter Ċ import Ġcom . l ub ul wa . k ul io . ui . component . Flight Schedules Adapter Ċ import Ġcom . l ub ul wa . k ul io . ui . component . Infinite Scroll Listener Ċ import Ġcom . l ub ul wa . k ul io . ui . interfaces . Home Contract Ċ import Ġkotlinx . android . synt hetic . main . activity _ search _ fl ights .* Ċ import Ġjava . util . ArrayList Ċ Ċ class ĠSearch Fl ights Activity Ġ: ĠBase Activity (), ĠHome Contract . View , ĠFlight Schedules Adapter . Item Listener Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsearch Fl ights Presenter : ĠSearch Fl ights Presenter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġflight Schedules Adapter : ĠFlight Schedules Adapter ĊĊĠĠĠ Ġprivate Ġvar Ġs chedules ArrayList : ĠArrayList < Schedule > Ġ= ĠArrayList () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpassed Origin Air port : ĠAir port ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpassed Destination Air port : ĠAir port ĊĠĠĠ Ġprivate Ġvar Ġpassed Depart Date : ĠString ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ search _ fl ights ) ĊĊĠĠĠĠĠĠĠ Ġinit Toolbar () ĊĠĠĠĠĠĠĠ Ġinit Stuff () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Toolbar () Ġ{ ĊĠĠĠĠĠĠĠ Ġset Support ActionBar ( toolbar ) ĊĠĠĠĠĠĠĠ Ġsupport ActionBar !!. set Display Home As Up Enabled ( true ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Stuff () Ġ{ ĊĠĠĠĠĠĠĠ Ġsearch Fl ights Presenter Ġ= ĠSearch Fl ights Presenter ( this ) ĊĊĠĠĠĠĠĠĠ Ġ// get Ġintent Ġdata ĊĠĠĠĠĠĠĠ Ġpassed Origin Air port Ġ= Ġintent . get Serializable Extra ( Constants . ORIGIN _ AIR PORT _ INT ENT _ DATA ) Ġas ĠAir port ĊĠĠĠĠĠĠĠ Ġpassed Destination Air port Ġ= Ġintent . get Serializable Extra ( Constants . DEST _ AIR PORT _ INT ENT _ DATA ) Ġas ĠAir port ĊĠĠĠĠĠĠĠ Ġpassed Depart Date Ġ= Ġintent . getString Extra ( Constants . DEP ART _ DATE _ INT ENT _ DATA ) ĊĊĠĠĠĠĠĠĠ Ġtv _ origin _ airport . text Ġ= Ġpassed Origin Air port . airport Code ĊĠĠĠĠĠĠĠ Ġtv _ destination _ airport . text Ġ= Ġpassed Destination Air port . airport Code ĊĊĠĠĠĠĠĠĠ Ġval Ġlayout Manager Ġ= ĠLinearLayoutManager ( this ); ĊĠĠĠĠĠĠĠ Ġrv _ schedules . layout Manager Ġ= Ġlayout Manager ĊĊĠĠĠĠĠĠĠ Ġflight Schedules Adapter Ġ= ĠFlight Schedules Adapter ( this , Ġs chedules ArrayList , Ġthis ) ĊĠĠĠĠĠĠĠ Ġrv _ schedules . adapter Ġ= Ġflight Schedules Adapter ĊĊĠĠĠĠĠĠĠ Ġfetch Scheduled Fl ights () ĊĊĠĠĠĠĠĠĠ Ġrv _ schedules . add On Scroll Listener ( object Ġ: ĠIn finite Scroll Listener (){ ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġload More () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this @ Search Fl ights Activity , ĠgetString ( R . string . list _ load _ more _ msg ), ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfetch Scheduled Fl ights () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch Scheduled Fl ights () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġoffset Ġ= Ġrv _ schedules . adapter !!. item Count ĊĠĠĠĠĠĠĠ Ġsearch Fl ights Presenter . find Scheduled Fl ights ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpassed Origin Air port . airport Code , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpassed Destination Air port . airport Code , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(( if Ġ( passed Depart Date Ġ== Ġnull ) ĠK ul io U tl is . get Tom or rows Date () Ġelse Ġpassed Depart Date ) !! ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoffset , ĊĠĠĠĠĠĠĠĠĠĠĠĠ 2 0 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfind Scheduled Fl ights Started () Ġ{ ĊĠĠĠĠĠĠĠ Ġpb _ loading _ schedules . visibility Ġ= ĠView . VISIBLE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfind Scheduled Fl ights Success ( fl ights Response : ĠF lights Response ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġpb _ loading _ schedules . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ Ġs chedules ArrayList . addAll ( fl ights Response !!. schedule Resource . schedule ) ĊĊĠĠĠĠĠĠĠ Ġflight Schedules Adapter . notify DataSet Changed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfind Scheduled Fl ights Failed ( errorMessage : ĠString , ĠerrorCode : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġpb _ loading _ schedules . visibility Ġ= ĠView . GONE ĊĠĠĠĠĠĠĠ ĠSn ackbar . make ( coordinator Layout , ĠerrorMessage , ĠSn ackbar . LENGTH _ LONG ). show () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Schedule Item Clicked ( schedule Item : ĠSchedule ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( this , ĠMap Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . putExtra ( Constants . ORIGIN _ AIR PORT _ INT ENT _ DATA , Ġpassed Origin Air port ) ĊĠĠĠĠĠĠĠ Ġintent . putExtra ( Constants . DEST _ AIR PORT _ INT ENT _ DATA , Ġpassed Destination Air port ) ĊĠĠĠĠĠĠĠ ĠstartActivity ( intent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Options ItemSelected ( item : ĠMenuItem ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( item . itemId ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġandroid . R . id . home Ġ-> Ġfinish () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġreturn Ġsuper . on Options ItemSelected ( item ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġfalse ĊĠĠĠ Ġ} Ċ Ċ } Ċ