package Ġcom . pr ush . just another player . ui . album details Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġcom . google . android . ex op layer 2 . util . Util Ċ import Ġcom . pr ush . just another player . R Ċ import Ġcom . pr ush . just another player . base . Header Recycler Fragment Ċ import Ġcom . pr ush . just another player . base . Recycler Adapter Ċ import Ġcom . pr ush . just another player . di . Injection Ċ import Ġcom . pr ush . just another player . model . Album Ċ import Ġcom . pr ush . just another player . model . Track Ċ import Ġcom . pr ush . just another player . services . Audio Player Service Ċ import Ġcom . pr ush . just another player . utils .* Ċ import Ġkotlinx . android . synt hetic . main . header _ re cy ler view _ layout .* Ċ Ċ class ĠAlbum Details Fragment Ġ: ĠHeader Recycler Fragment (), ĠAlbum Details Contract . View , ĊĠĠĠ ĠRe cycler Adapter . On Item Inter acted Listener Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠRe cycler Adapter < Track > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlist Presenter : ĠAlbum Tracks List Presenter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġalbum Details Presenter : ĠAlbum Details Presenter ĊĠĠĠ Ġprivate Ġvar Ġalbum Id : ĠLong Ġ= Ġ 0 ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ( arguments Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġalbum Id Ġ= Ġrequire Arguments (). getLong ( AL BU M _ ID ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġalbum Details Presenter Ġ= ĠAlbum Details Presenter ( Injection . provide Album Repository (), Ġthis ) ĊĠĠĠĠĠĠĠ Ġlist Presenter Ġ= ĠAlbum Tracks List Presenter () ĊĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠRe cycler Adapter ( list Presenter , Ġthis ) ĊĠĠĠĠĠĠĠ Ġbase RecyclerView . adapter Ġ= Ġadapter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonStart () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onStart () ĊĠĠĠĠĠĠĠ Ġalbum Details Presenter . fetch Album Details ( album Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġdisplay Album Details ( album : ĠAlbum ) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġheader Album Art ImageView . setImage Resource ( R . drawable . ic _ album ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ( album . album Name . isNotEmpty () Ġ&& Ġcontext Ġ!= Ġnull ) Ġ{ ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġload Album Art ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget View Activity (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġalbum . album Id , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġheader Album Art ImageView , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġalbum . default Album Art Res ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcol lap sing Toolbar Layout . title Ġ= Ġalbum . album Name ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlist Presenter . set Items List ( album . tracks List , Ġadapter ) ĊĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Item Click ( selected Track Position : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ// TODO : Ġshuffle Ġwhen Ġselected Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġalbum Details Presenter . prepare Track Playback ( selected Track Position ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġstart Track Playback ( selected Track Position : ĠInt ) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( getView Activity (), ĠAudio Player Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġintent . action Ġ= ĠAudio Player Service . Playback Controls . PLAY . name ĊĠĠĠĠĠĠĠ Ġintent . putExtra ( PLAY _ CONTEXT _ TYPE , ĠP LAY _ CONTEXT . AL BU M _ TRACK S ) ĊĠĠĠĠĠĠĠ Ġif Ġ( selected Track Position Ġ== Ġ- 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġintent . putExtra ( SH UFF LE _ TRACK S , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġintent . putExtra ( SELECTED _ TRACK _ POSITION , Ġselected Track Position ) ĊĊĠĠĠĠĠĠĠ Ġintent . putExtra ( SELECTED _ AL BU M _ ID , Ġalbum Id ) ĊĠĠĠĠĠĠĠ ĠUtil . start Foreground Service ( getView Activity (), Ġintent ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon ContextMenu Clicked ( position : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on ContextMenu Clicked ( position ) ĊĠĠĠĠĠĠĠ Ġalbum Details Presenter . prepare Track ContextMenu ( position ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget View Activity (): ĠAppCompatActivity Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġactivity Ġas ĠAppCompatActivity ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget ApplicationContext (): ĠContext Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ( activity Ġas ĠAppCompatActivity ). application Context ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshould Display Home As Up Enabled (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠAL BU M _ ID Ġ= Ġ" Album Id " ĊĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance ( album Id : ĠLong ): ĠAlbum Details Fragment Ġ{ ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠAlbum Details Fragment (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġarguments Ġ= ĠBundle (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Long ( AL BU M _ ID , Ġalbum Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }