package Ġcom . mar ce lo . pri val ia . movies app . presentation . present ers Ċ Ċ import Ġcom . mar ce lo . pri val ia . movies app . domain . inter actors . Most Pop ular Movies Interactor Ċ import Ġcom . mar ce lo . pri val ia . movies app . domain . inter actors . Most Pop ular Movies Interactor Interface Ċ import Ġcom . mar ce lo . pri val ia . movies app . domain . model . Movie Ċ import Ġcom . mar ce lo . pri val ia . movies app . presentation . ui . fragments . Most Pop ular Movies Presenter Interface Ċ Ċ import Ġcom . mar ce lo . pri val ia . movies app . presentation . ui . interfaces . Most Pop ular Movies View Ċ Ċ class ĠMost Pop ular Movies Presenter ( private Ġval Ġmost Pop ular Movies View : ĠMost Pop ular Movies View ): ĠMost Pop ular Movies Presenter Interface Ġ{ ĊĊĠĠĠ Ġprivate Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠMO ST _ POP ULAR _ VIEW : ĠInt Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠSEARCH _ VIEW : ĠInt Ġ= Ġ 2 ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġinter actor : ĠMost Pop ular Movies Interactor Interface Ġ= ĠMost Pop ular Movies Interactor ( this ) ĊĠĠĠ Ġprivate Ġvar Ġmost Pop ular Page : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġprivate Ġvar Ġsearch Page : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġprivate Ġvar Ġended Most Pop ular List : ĠBoolean Ġ= Ġfalse ĊĠĠĠ Ġprivate Ġvar Ġended Search List : ĠBoolean Ġ= Ġfalse ĊĠĠĠ Ġprivate Ġvar Ġactive Result : ĠInt Ġ= ĠMO ST _ POP ULAR _ VIEW ĊĠĠĠ Ġprivate Ġvar Ġquery : ĠString Ġ= Ġ"" ĊĊĠĠĠ Ġfun Ġload Most Pop ular Movies () Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Loading () ĊĠĠĠĠĠĠĠ Ġactive Result Ġ= ĠMO ST _ POP ULAR _ VIEW ĊĠĠĠĠĠĠĠ Ġsearch Page Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġif (! ended Most Pop ular List ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinter actor . load Most Pop ular Movies ( most Pop ular Page ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Most Pop ular Error ( message : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Error ( message ) ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Bottom ProgressBar () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Most Pop ular Successful ( movie List : ĠMutable List < Movie >, Ġtotal _ pages : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Page ++ ĊĠĠĠĠĠĠĠ Ġif ( most Pop ular Page Ġ>= Ġtotal _ pages ){ Ġended Most Pop ular List Ġ= Ġtrue Ġ} ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . load Most Pop ular Movies Successful ( movie List ) ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Bottom ProgressBar () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsearch Movies ( new Text : ĠString ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġactive Result Ġ= ĠSEARCH _ VIEW ĊĠĠĠĠĠĠĠ Ġquery Ġ= Ġnew Text !! ĊĠĠĠĠĠĠĠ Ġreset List () ĊĠĠĠĠĠĠĠ Ġif ( new Text !!. length Ġ> Ġ 0 ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Loading () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinter actor . search Movies ( search Page , Ġnew Text , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsearch Movie Error ( message : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Error ( message ) ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Bottom ProgressBar () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsearch Movie Successful ( movie List : ĠMutable List < Movie >, Ġtotal _ pages : ĠInt , Ġtotal _ results : ĠInt , Ġis New Search : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif ( search Page Ġ>= Ġtotal _ pages ){ Ġended Search List Ġ= Ġtrue Ġ} ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Bottom ProgressBar () ĊĠĠĠĠĠĠĠ Ġif ( isNew Search ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsearch Page Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . search Movie Successful ( movie List , Ġis New Search ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġload More Results () Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen ( active Result ){ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMO ST _ POP ULAR _ VIEW -> Ġload Most Pop ular Movies () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠSEARCH _ VIEW -> Ġload More SearchResults () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġload More SearchResults () Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Bottom ProgressBar () ĊĠĠĠĠĠĠĠ Ġsearch Page ++ ĊĠĠĠĠĠĠĠ Ġinter actor . search Movies ( search Page , Ġquery , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġreset List (){ ĊĠĠĠĠĠĠĠ Ġsearch Page Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġmost Pop ular Page Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . reset List () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Empty View () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Search Message () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Empty View () Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Loading () ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . show Empty View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġhide Empty View () Ġ{ ĊĠĠĠĠĠĠĠ Ġmost Pop ular Movies View . hide Empty View () ĊĠĠĠ Ġ} Ċ }