package Ġcom . sum era . sample . ui . infinity Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . sum era . core actor . Core actor Activity Ċ import Ġcom . sum era . core actor . Core actor View Ċ import Ġcom . sum era . core actor . contract . event . Event Ċ import Ġcom . sum era . sample . ui . infinity . adapter . Infinity Loading Adapter Ċ import Ġcom . sum era . sample . ui . infinity . contract . Infinity Loading State Ċ import Ġcom . sum era . sample . ui . infinity . contract . On Bottom Reached Ċ import Ġcom . sum era . sample . ui . infinity . contract . On Item Favorite Clicked Ċ import Ġcom . sum era . sample . ui . infinity . contract . On Retry Loading Ċ import Ġcom . sum era . sample . ui . infinity . contract . On Retry Loading Next Ċ import Ġkotlinx . android . synt hetic . main . activity _ infinity .* Ċ Ċ class ĠInfinity Loading Activity Ġ: ĠCore actor Activity < Infinity Loading State >(), ĠCore actor View < Infinity Loading State > Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġget Intent ( context : ĠContext ): ĠIntent Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠIntent ( context , ĠInfinity Loading Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġcore actor Factory Ġ= ĠInfinity Loading Core actor Factory () ĊĊĠĠĠ Ġoverride Ġval Ġcore actor View Ġ= Ġthis ĊĊĠĠĠ Ġoverride Ġfun Ġlayout Res () Ġ= Ġcom . sum era . sample . R . layout . activity _ infinity ĊĊĠĠĠ Ġprivate Ġval Ġadapter : ĠInfinity Loading Adapter Ġ= ĠInfinity Loading Adapter () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġinfinity _ recycler . layout Manager Ġ= ĠLinearLayoutManager ( this ) ĊĠĠĠĠĠĠĠ Ġinfinity _ recycler . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġinfinity _ placeholder . setOnClickListener Ġ{ Ġsend Action ( On Retry Loading ) Ġ} ĊĠĠĠĠĠĠĠ Ġadapter . on ItemClickListener Ġ= Ġ{ Ġsend Action ( On Item Favorite Clicked ( it )) Ġ} ĊĠĠĠĠĠĠĠ Ġadapter . on Retry Loading Click Lister Ġ= Ġ{ Ġsend Action ( On Retry Loading Next ) Ġ} ĊĠĠĠĠĠĠĠ Ġadapter . on Last Item Is Shown Ġ= Ġ{ Ġsend Action ( On Bottom Reached ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon State ( state : ĠInfinity Loading State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġset Placeholder State ( state ) ĊĠĠĠĠĠĠĠ Ġset Recycler State ( state ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Event ( event : ĠEvent < Infinity Loading State >) Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠNo Ġevents ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġset Placeholder State ( state : ĠInfinity Loading State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtext Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstate . isLoading Ġ-> Ġ" Loading " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstate . error Ġ!= Ġnull Ġ-> Ġ" Error " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġ"" ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġinfinity _ placeholder . text Ġ= Ġtext ĊĠĠĠĠĠĠĠ Ġinfinity _ placeholder . visibility Ġ= Ġif Ġ( text . isEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠView . GONE ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠView . VISIBLE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġset Recycler State ( state : ĠInfinity Loading State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter . state Ġ= Ġstate . next Items State ĊĠĠĠĠĠĠĠ Ġadapter . data Ġ= Ġstate . content ĊĠĠĠ Ġ} Ċ } Ċ