package Ġcom . example . weather app . presenter Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . example . weather app . Weather Application Ċ import Ġcom . example . weather app . callback . Api CallBack Ċ import Ġcom . example . weather app . converter . Weather Converter Ċ import Ġcom . example . weather app . location . Device Location Ċ import Ġcom . example . weather app . recycler . forecast . Forecast RecyclerView Item Ċ import Ġcom . example . weather app . repository . Repository Ċ import Ġcom . example . weather app . view . I Weather View Ċ import Ġcom . google . gson . JsonObject Ċ import Ġjava . util .* Ċ Ċ class ĠFore cast Presenter ( private Ġvar Ġview : ĠI Weather View ) Ġ: ĠIF ore cast Presenter Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġget LiveData (): ĠLive Data < List < Forecast RecyclerView Item >> Ġ= Ġforecast Items ĊĊĠĠĠ Ġcompanion Ġobject ĠCache Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġforecast Items LiveData Ġ= ĠMutable LiveData < List < Forecast RecyclerView Item >>() ĊĠĠĠĠĠĠĠ Ġfun Ġclear Cache () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġforecast Items LiveData . post Value ( ArrayList < Forecast RecyclerView Item >()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġforecast Items : ĠLive Data < List < Forecast RecyclerView Item >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġforecast Items LiveData ĊĊĊĠĠĠ Ġoverride Ġfun Ġload Weather Forecast ( device Location : ĠDevice Location ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! forecast Items LiveData . value . isNull OrEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠRepository . get Weather Forecast By Coordinate ( device Location . latitude , Ġdevice Location . longitude , Ġobject Ġ: ĠApi CallBack Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon CallBack Forecast ( jsonObject : ĠJsonObject ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġweather List Ġ= ĠWeather Converter . convert Json To Forecast Weather List ( jsonObject ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlist Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠWeather Converter . convert Forecast Weather List To Recycler ItemList ( weather List ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġforecast Items LiveData . post Value ( list ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġview . on Load Weather ( list ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon CallBack Today ( jsonObject : ĠJsonObject ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ Ċ }