package Ġcom . then ews app . the d ail yn ew sc ast . activities . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . then ews app . the d ail yn ew sc ast . activities . UI model . News UI Model Ċ import Ġcom . then ews app . the d ail yn ew sc ast . activities . models . Data Item Ċ import Ġcom . then ews app . the d ail yn ew sc ast . activities . models . News Response Model Ċ import Ġcom . then ews app . the d ail yn ew sc ast . activities . repository . News Repository Ċ import Ġretrofit 2 . Call Ċ import Ġretrofit 2 . Callback Ċ import Ġretrofit 2 . Response Ċ Ċ class ĠNews Polit ics ViewModel () Ġ: ĠViewModel (), ĠCallback < News Response Model > Ġ{ ĊĠĠĠ Ġprivate Ġval Ġnews Repository Ġ= ĠNews Repository ( this ) ĊĠĠĠ Ġprivate Ġval Ġmutable LiveData Ġ= ĠMutable LiveData < News UI Model >() ĊĠĠĠ Ġval Ġlive Data For News : ĠLive Data < News UI Model > Ġ= Ġmutable LiveData ĊĊĠĠĠ Ġoverride Ġfun Ġon Failure ( call : ĠCall < News Response Model >, Ġt : ĠThrowable ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable LiveData . value Ġ= ĠNews UI Model . Failure ( t . message !! ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Response ( ĊĠĠĠĠĠĠĠ Ġcall : ĠCall < News Response Model >, ĊĠĠĠĠĠĠĠ Ġresponse : ĠResponse < News Response Model > ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġresponse . body ()?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmutable LiveData . value Ġ= ĠNews UI Model . Success ( it . data Ġas ĠList < Data Item >) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcall Api () Ġ{ ĊĠĠĠĠĠĠĠ Ġnews Repository . get ListOf News () ĊĠĠĠ Ġ} Ċ } ĊĊĊĊĊĊ