package Ġcom . scri bd . arm ad illo test app . presentation . analytics Ċ Ċ import Ġandroid . util . Log Ċ import Ġcom . scri bd . arm ad illo . analytics . Playback ActionListener Ċ import Ġcom . scri bd . arm ad illo . models . Arm ad illo State Ċ import Ġcom . scri bd . arm ad illo . time . Interval Ċ import Ġcom . scri bd . arm ad illo . time . Millisecond Ċ import Ġio . reactivex . dis pos ables . Composite Disposable Ċ import Ġio . reactivex . subjects . Publish Subject Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ class ĠArm ad illo Playback ActionListener Ġ: ĠPlay back ActionListener Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġdis pos ables Ġ= ĠComposite Disposable () ĊĠĠĠ Ġprivate Ġval Ġpublish Subject Ġ= ĠPublish Subject . create < Arm ad illo State >() ĊĊĠĠĠ Ġprivate Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠTAG Ġ= Ġ" Playback ActionListener " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Poll ( state : ĠArm ad illo State ) Ġ= Ġpublish Subject . onNext ( state ) ĊĊĠĠĠ Ġoverride Ġfun Ġon New Audio book ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinit Poll () ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on New Audio book : Ġ" Ġ+ Ġstate . toString ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Loading Start ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Load Start : Ġ$ state ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Loading End ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Load End : Ġ$ state ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Play ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Play : Ġ$ state ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Pause : Ġ$ state ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Stop ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Stop : Ġ$ state ") ĊĠĠĠĠĠĠĠ Ġdis pos ables . clear () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Dis continu ity ( state : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Ġdis continu ity ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Fast Forward ( before State : ĠArm ad illo State , Ġafter State : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Fast Forward : Ġ$ after State ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Rew ind ( before State : ĠArm ad illo State , Ġafter State : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Rew ind : Ġ$ after State ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Skip To Next ( before State : ĠArm ad illo State , Ġafter State : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Skip To Next : Ġ$ after State ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Skip To Previous ( before State : ĠArm ad illo State , Ġafter State : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Skip To Previous : Ġ$ after State ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Seek ( seek Target : ĠInterval < Millisecond >, Ġbefore State : ĠArm ad illo State , Ġafter State : ĠArm ad illo State ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Seek To : Ġ$ after State ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Skip Distance Change ( state : ĠArm ad illo State , Ġold Distance : ĠInterval < Millisecond >, Ġnew Distance : ĠInterval < Millisecond >) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Skip Distance : Ġ$ new Distance ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Speed Change ( state : ĠArm ad illo State , Ġold Speed : ĠFloat , Ġnew Speed : ĠFloat ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Speed Change : Ġ$ new Speed ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Poll () Ġ{ ĊĠĠĠĠĠĠĠ Ġdis pos ables . clear () ĊĠĠĠĠĠĠĠ Ġdis pos ables . add ( publish Subject ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. sample ( 5 , ĠTimeUnit . SECONDS ) Ġ// Ġlooks Ġinto Ġthe Ġsequence Ġof Ġelements Ġand Ġemits Ġthe Ġlast Ġitem Ġthat Ġwas Ġproduced Ġwithin Ġthe Ġduration ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. subscribe Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠLog . v ( TAG , Ġ" on Poll : Ġ" Ġ+ Ġit . toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ }