package Ġorg . step ik . android . view . course _ list . ui . fragment Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġkotlinx . android . synt hetic . main . empty _ search .* Ċ import Ġkotlinx . android . synt hetic . main . error _ no _ connection _ with _ button .* Ċ import Ġkotlinx . android . synt hetic . main . fragment _ course _ list .* Ċ import Ġkotlinx . android . synt hetic . main . view _ centered _ toolbar .* Ċ import Ġorg . step ic . d roid . R Ċ import Ġorg . step ic . d roid . an alytic . An alytic Ċ import Ġorg . step ic . d roid . base . App Ċ import Ġorg . step ic . d roid . core . Screen Manager Ċ import Ġorg . step ic . d roid . model . Collection Description Colors Ċ import Ġorg . step ic . d roid . ui . util . init Center ed Toolbar Ċ import Ġorg . step ik . android . domain . course . an alytic . Course View Source Ċ import Ġorg . step ik . android . domain . course _ payments . mapper . Default Promo Code Mapper Ċ import Ġorg . step ik . android . domain . last _ step . model . Last Step Ċ import Ġorg . step ik . android . model . Course Ċ import Ġorg . step ik . android . presentation . course _ continue . model . Course Continue Interaction Source Ċ import Ġorg . step ik . android . presentation . course _ list . Course List Collection Presenter Ċ import Ġorg . step ik . android . presentation . course _ list . Course List CollectionView Ċ import Ġorg . step ik . android . presentation . course _ list . Course ListView Ċ import Ġorg . step ik . android . view . base . ui . extension . enforce Single Scroll Direction Ċ import Ġorg . step ik . android . view . catalog . mapper . Course Count Mapper Ċ import Ġorg . step ik . android . view . course . mapper . Display Price Mapper Ċ import Ġorg . step ik . android . view . course _ list . delegate . Course Continue View Delegate Ċ import Ġorg . step ik . android . view . course _ list . delegate . Course ListView Delegate Ċ import Ġorg . step ik . android . view . course _ list . ui . adapter . decorator . Course List Collection Header Decoration Ċ import Ġorg . step ik . android . view . ui . delegate . ViewState Delegate Ċ import Ġru . nob ird . app . core . model . Pagination Direction Ċ import Ġru . nob ird . android . view . base . ui . extension . argument Ċ import Ġru . nob ird . android . view . base . ui . extension . setOn Pagination Listener Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠCourse List Collection Fragment Ġ: ĠFragment ( R . layout . fragment _ course _ list ), ĠCourse List CollectionView Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance ( course Collection Id : ĠLong ): ĠFragment Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCourse List Collection Fragment (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthis . course Collection Id Ġ= Ġcourse Collection Id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġvar Ġcourse Collection Id Ġby Ġargument < Long >() ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġan alytic : ĠAn alytic ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġscreen Manager : ĠScreen Manager ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Provider . Factory ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġcourse Count Mapper : ĠCourse Count Mapper ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġdefault Promo Code Mapper : ĠDefault Promo Code Mapper ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġdisplay Price Mapper : ĠDisplay Price Mapper ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcourse ListView Delegate : ĠCourse ListView Delegate ĊĠĠĠ Ġprivate Ġval Ġcourse List Presenter : ĠCourse List Collection Presenter Ġby Ġview Models Ġ{ ĠviewModel Factory Ġ} ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcourse List Collection Header Decoration : ĠCourse List Collection Header Decoration ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġinject Component () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġinit Center ed Toolbar ( R . string . catalog _ title , Ġtrue ) ĊĊĠĠĠĠĠĠĠ Ġcourse List Collection Header Decoration Ġ= ĠCourse List Collection Header Decoration () ĊĠĠĠĠĠĠĠ Ġwith ( course List Courses Recycler ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠGrid LayoutManager ( context , Ġresources . getInteger ( R . integer . course _ list _ columns )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġitem Animator Ġ= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Item Decoration ( course List Collection Header Decoration ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset On Pagination Listener Ġ{ Ġpage Direction Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( page Direction Ġ== ĠPagination Direction . NEXT ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse List Presenter . fetch Next Page () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġenforce Single Scroll Direction () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġgo To Catalog . setOnClickListener Ġ{ Ġscreen Manager . show Catalog ( require Context ()) Ġ} ĊĠĠĠĠĠĠĠ Ġcourse List Swipe Refresh . setOn Refresh Listener Ġ{ Ġcourse List Presenter . fetch Courses ( course Collection Id Ġ= Ġcourse Collection Id , Ġforce Update Ġ= Ġtrue ) Ġ} ĊĠĠĠĠĠĠĠ Ġtry Again . setOnClickListener Ġ{ Ġcourse List Presenter . fetch Courses ( course Collection Id Ġ= Ġcourse Collection Id , Ġforce Update Ġ= Ġtrue ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġview State Delegate Ġ= ĠView State Delegate < Course ListView . State >() ĊĠĠĠĠĠĠĠ Ġview State Delegate . add State < Course ListView . State . Idle >() ĊĠĠĠĠĠĠĠ Ġview State Delegate . add State < Course ListView . State . Loading >( course List Courses Recycler ) ĊĠĠĠĠĠĠĠ Ġview State Delegate . add State < Course ListView . State . Content >( course List Courses Recycler ) ĊĠĠĠĠĠĠĠ Ġview State Delegate . add State < Course ListView . State . Empty >( course List Courses Empty ) ĊĠĠĠĠĠĠĠ Ġview State Delegate . add State < Course ListView . State . Network Error >( course List Courses Loading Error Vertical ) ĊĊĠĠĠĠĠĠĠ Ġcourse ListView Delegate Ġ= ĠCourse ListView Delegate ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġan alytic Ġ= Ġan alytic , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Continue View Delegate Ġ= ĠCourse Continue View Delegate ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġactivity Ġ= Ġrequire Activity (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġan alytic Ġ= Ġan alytic , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscreen Manager Ġ= Ġscreen Manager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse List Swipe Refresh Ġ= Ġcourse List Swipe Refresh , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Items RecyclerView Ġ= Ġcourse List Courses Recycler , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse ListView State Delegate Ġ= Ġview State Delegate , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Continue Course Clicked Ġ= Ġ{ Ġcourse ListItem Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse List Presenter ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. continue Course ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Ġ= Ġcourse ListItem . course , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġview Source Ġ= ĠCourse View Source . Collection ( course Collection Id ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġinteraction Source Ġ= ĠCourse Continue Interaction Source . CO URSE _ WIDGET ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdefault Promo Code Mapper Ġ= Ġdefault Promo Code Mapper , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdisplay Price Mapper Ġ= Ġdisplay Price Mapper , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Course List Clicked Ġ= Ġ{ Ġscreen Manager . show Courses Collection ( require Context (), Ġit . id ) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Author Click Ġ= Ġ{ Ġscreen Manager . open Profile ( require Context (), Ġit ) Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Count Mapper Ġ= Ġcourse Count Mapper , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Vertical Course Collection Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcourse List Courses Recycler . set Padding ( 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresources . get Dimension Pixel Offset ( R . dim en . vertical _ course _ collection _ padding ), ĊĠĠĠĠĠĠĠĠĠĠĠĠ 0 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresources . get Dimension Pixel Offset ( R . dim en . vertical _ course _ collection _ padding ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcourse List Presenter . fetch Courses ( course Collection Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinject Component () Ġ{ ĊĠĠĠĠĠĠĠ ĠApp . component () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. course List Collection Component Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. inject ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠsetState ( state : ĠCourse List CollectionView . State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( state ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse List CollectionView . State . Idle , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse List CollectionView . State . Loading Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse ListView Delegate . setState ( Course ListView . State . Loading ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse List CollectionView . State . Data Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse List Collection Header Decoration . collection Description Colors Ġ= ĠCollection Description Colors . of Collection ( state . course Collection ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse List Collection Header Decoration . header Text Ġ= Ġstate . course Collection . description . take If Ġ{ Ġit . isNotEmpty () Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcentered Toolbar Title . text Ġ= Ġstate . course Collection . title ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse ListView Delegate . setState ( state . course ListView State ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse List CollectionView . State . Network Error Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse ListView Delegate . setState ( Course ListView . State . Network Error ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Course ( course : ĠCourse , Ġsource : ĠCourse View Source , Ġis Adaptive : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse ListView Delegate . show Course ( course , Ġsource , Ġis Adaptive ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Steps ( course : ĠCourse , Ġsource : ĠCourse View Source , Ġlast Step : ĠLast Step ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse ListView Delegate . show Steps ( course , Ġsource , Ġlast Step ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġset Blocking Loading ( isLoading : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse ListView Delegate . set Blocking Loading ( isLoading ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Network Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse ListView Delegate . show Network Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonStart () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onStart () ĊĠĠĠĠĠĠĠ Ġcourse List Presenter . attach View ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Stop () Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse List Presenter . detach View ( this ) ĊĠĠĠĠĠĠĠ Ġsuper . on Stop () ĊĠĠĠ Ġ} Ċ }