package Ġcom . b alys v . ver yn iced rink s . presentation . my ratings Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . transition . Transition Manager Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroid . util . Attribute Set Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Toast . LENGTH _ LONG Ċ import Ġandroid . widget . Toast . makeText Ċ import Ġcom . b alys v . ver yn iced rink s . R Ċ import Ġcom . b alys v . ver yn iced rink s . inter actor .* Ċ import Ġcom . b alys v . ver yn iced rink s . get D agger Component Ċ import Ġcom . b alys v . ver yn iced rink s . inflate Ċ import Ġcom . b alys v . ver yn iced rink s . presentation . rate wh is ky . Rate Wh is ky Activity Ċ import Ġcom . b alys v . ver yn iced rink s . presentation . wh is ky search . Wh is ky Search Activity Ċ import Ġcom . h ann es dor fm ann . mos by 3 . m vi . layout . M vi Relative Layout Ċ import Ġcom . h ann es dor fm ann . mos by 3 . mvp . M vp View Ċ import Ġcom . jak ew h art on . r xb ind ing 2 . view . Rx View Ċ import Ġio . reactivex . Observable Ċ import Ġkotlinx . android . synt hetic . main . my _ ratings _ item . view .* Ċ import Ġkotlinx . android . synt hetic . main . my _ ratings _ layout . view .* Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ Ċ interface ĠMy Ratings View Ġ: ĠM vp View Ġ{ ĊĠ Ġfun Ġload R ated Wh isk ies Intent (): ĠObservable < Unit > ĊĊĠ Ġfun Ġrender ( view State : ĠMy Ratings ViewState ) Ċ } Ċ Ċ class ĠMy Ratings Layout ( context : ĠContext ?, Ġattrs : ĠAttributeSet ?) ĊĠ Ġ: ĠM vi Relative Layout < My Ratings View , ĠMy Ratings Presenter >( context , Ġattrs ), ĠMy Ratings View Ġ{ ĊĊĠ Ġ@ Inject ĊĠ Ġlateinit Ġvar Ġpresenter : ĠMy Ratings Presenter ĊĊĠ Ġprivate Ġval Ġadapter Ġ= ĠMy Ratings Adapter () ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġcontext ?. get D agger Component < My Ratings Activity . Component >() ?. inject ( this ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġcreate Presenter (): ĠMy Ratings Presenter Ġ{ ĊĠĠĠ Ġreturn Ġpresenter ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Finish Inf late () Ġ{ ĊĠĠĠ Ġsuper . on Finish Inf late () ĊĊĠĠĠ ĠRx View . click s ( this . my _ ratings _ fab ) ĊĠĠĠĠĠ Ġ. subscribe ({ Ġcontext . startActivity ( Wh is ky Search Activity . intent ( context )) Ġ}) ĊĊĠĠĠ Ġthis . my _ ratings _ recycler _ view . layout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠ Ġthis . my _ ratings _ recycler _ view . adapter Ġ= Ġadapter ĊĠĠĠ Ġadapter . on ClickListener Ġ= Ġ{ ĊĠĠĠĠĠ Ġcontext . startActivity ( Rate Wh is ky Activity . intent ( context , Ġit . wh is ky . id )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġload R ated Wh isk ies Intent (): ĠObservable < Unit > Ġ{ ĊĠĠĠ Ġreturn ĠRx View . attach Events ( this ). map Ġ{ ĠUnit Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġrender ( view State : ĠMy Ratings ViewState ) Ġ{ ĊĠĠĠ ĠTim ber . e (" My Ratings View : ĠR ENDER ING Ġ${ view State . java Class . simple Name }") ĊĊĠĠĠ Ġwhen Ġ( view State ) Ġ{ ĊĊĠĠĠĠĠ ĠMy Ratings Loading Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠTransition Manager . begin Delayed Transition ( this ) ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ progress _ bar . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ recycler _ view . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ random _ fact . visibility Ġ= ĠG ONE ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġis ĠMy Ratings Loading Fact Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠTransition Manager . begin Delayed Transition ( this ) ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ progress _ bar . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ recycler _ view . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ random _ fact . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ random _ fact . text Ġ= Ġview State . random Fact . text ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġis ĠMy Ratings Loaded Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠTransition Manager . begin Delayed Transition ( this ) ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ progress _ bar . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ random _ fact . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ recycler _ view . visibility Ġ= ĠVIS IBLE ĊĠĠĠĠĠĠĠ Ġadapter . items Ġ= Ġview State . r ated Wh isk ies ĊĠĠĠĠĠĠĠ Ġadapter . notify DataSet Changed () ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġis ĠMy Ratings Error Ġ-> Ġ{ ĊĠĠĠĠĠĠĠ ĠTransition Manager . begin Delayed Transition ( this ) ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ progress _ bar . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ recycler _ view . visibility Ġ= ĠG ONE ĊĠĠĠĠĠĠĠ Ġthis . my _ ratings _ random _ fact . visibility Ġ= ĠG ONE ĊĊĠĠĠĠĠĠĠ Ġmake Text ( context , Ġ" Failed Ġloading Ġratings Ġ${ view State . error . message }", ĠLEN GTH _ LONG ). show () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġclass ĠMy Ratings Adapter Ġ: ĠRecyclerView . Adapter < ViewHolder >() Ġ{ ĊĠĠĠ Ġlateinit Ġvar ĠonClick Listener : Ġ( R ated Wh is ky ) Ġ-> ĠUnit ĊĠĠĠ Ġvar Ġitems : ĠList < R ated Wh is ky > Ġ= ĠlistOf () ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠ Ġholder . bind ( items [ position ], ĠonClick Listener ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠ Ġreturn Ġitems . size ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠViewHolder Ġ{ ĊĠĠĠĠĠ Ġreturn ĠViewHolder ( parent . inflate ( R . layout . my _ ratings _ item )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġclass ĠViewHolder ( item View : ĠView ) Ġ: ĠRecyclerView . ViewHolder ( item View ) Ġ{ ĊĠĠĠ Ġfun Ġbind ( item : ĠR ated Wh is ky , ĠonClick Listener : Ġ( R ated Wh is ky ) Ġ-> ĠUnit ) Ġ= Ġwith ( item View ) Ġ{ ĊĠĠĠĠĠ ĠitemView . my _ ratings _ item _ name . text Ġ= Ġitem . wh is ky . name ĊĠĠĠĠĠ ĠitemView . my _ ratings _ item _ nic eness . text Ġ= Ġitem . rating . nic eness . toString () ĊĠĠĠĠĠ Ġset OnClickListener Ġ{ ĠonClick Listener ( item ) Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ }