package Ġcom . s ah ar w . my music player . presentation . activities . files . mvp Ċ Ċ import Ġandroid . util . Log Ċ import Ġcom . s ah ar w . my music player . entities . data . base . Media Item Ċ import Ġcom . s ah ar w . my music player . presentation . base . I Model Ċ import Ġcom . s ah ar w . my music player . presentation . base . IP res enter Ċ import Ġcom . s ah ar w . my music player . presentation . base . I View Ċ import Ġcom . s ah ar w . my music player . service . Music Service Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġio . reactivex . subjects . Publish Subject Ċ import Ġjava . lang . ref . Weak Reference Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġs ah ar w Ġon Ġ 1 0 / 0 5 / 2 0 1 8 . Ċ Ġ*/ Ċ class ĠFiles Presenter ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġview : ĠI View , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġmodel : ĠI Model , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġon MediaPlayer Prepared Subject : ĠPublish Subject < Boolean >, ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġmusic Serv Weak Ref : ĠWeak Reference < Music Service >) Ġ: ĠIP res enter Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠTAG Ġ= Ġ" Files Presenter " ĊĊĠĠĠ Ġoverride Ġfun Ġon Presenter Create () Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" on Presenter Create ") ĊĊĠĠĠĠĠĠĠ Ġ// Ġinit Ġview ĊĠĠĠĠĠĠĠ Ġview . on View Create () ĊĠĠĠĠĠĠĠ Ġ( view Ġas ĠFiles View ). m On Item Click Subject . observe On ( Schedulers . single ()). subscribe Ġ{ Ġon Media Item Clicked ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġon MediaPlayer Prepared Subject . observe On ( Schedulers . single ()). subscribe Ġ{ Ġview . show Media Controller () Ġ} ĊĊĠĠĠĠĠĠĠ Ġ// Ġinit Ġmodel ĊĠĠĠĠĠĠĠ Ġmodel . on Model Create () ĊĊĠĠĠĠĠĠĠ Ġ// Ġregister Ġfor Ġupdating Ġsong Ġtitle ĊĠĠĠĠĠĠĠ Ġmusic Serv Weak Ref . get ()?. song Name Subject !!. subscribe On ( Schedulers . single ()). subscribe Ġ{ view . set Song Title ( it )} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Presenter Resume () Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" on Presenter Resume ") ĊĠĠĠĠĠĠĠ Ġview . on View Resume () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Presenter Pause () Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" on Presenter Pause ") ĊĠĠĠĠĠĠĠ Ġview . on View Pause () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Presenter Destroy () Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" on Presenter Destroy ") ĊĠĠĠĠĠĠĠ Ġview . on View Destroy () ĊĠĠĠĠĠĠĠ Ġmodel . on Model Destroy () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Media Item Clicked ( media Item : ĠMedia Item ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" on Media Item Clicked : Ġmedia Item : Ġ$ media Item ") ĊĠĠĠĠĠĠĠ Ġif ( media Item Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( view Ġas ĠFiles View ). show Media Controller () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ( model Ġas ĠFiles Model ). toggle Music Service ( media Item ) ĊĠĠĠĠĠĠĠ Ġ} else Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . e ( TAG , Ġ" on Media Item Clicked : Ġmedia Item Ġis Ġnull !") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }