package Ġcom . example . images Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . Android ViewModel Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . android . vol ley . Request Ċ import Ġcom . android . vol ley . Response Ċ import Ġcom . android . vol ley . toolbox . String Request Ċ import Ġcom . google . gson . Gson Ċ Ċ class ĠGallery ViewModel ( application : ĠApplication ) Ġ: ĠAndroid ViewModel ( application ) Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġ_ photos : Mutable LiveData < List < Photo Item >> Ġ= ĠMutable LiveData < List < Photo Item >>() ĊĊĠĠĠ Ġval Ġphotos : ĠLive Data < List < Photo Item >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ photos ĊĊĠĠĠ Ġfun Ġload Images (){ ĊĠĠĠĠĠĠĠ Ġvar Ġkey Words Ġ= ĠarrayOf (" dog ", Ġ" animal ", Ġ" be auty "," g irl "," flow ers "," young Ġg irl ") ĊĠĠĠĠĠĠĠ Ġvar Ġurl Ġ= Ġ" https :// pix ab ay . com / api /? key = 1 6 1 6 6 2 8 9 - 9 4 2 1 7 df edd 1 0 7 2 7 e 3 6 0 4 e 9 1 1 9 & q =${ key Words . random ()} & per _ page = 1 0 0 " ĊĊĠĠĠĠĠĠĠ Ġval Ġstring Request Ġ= ĠString Request ( Request . Method . GET , Ġurl , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponse . Listener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ photos . value Ġ= ĠGson (). fromJson ( it , Pix ab ay :: class . java ). hits . toList () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠResponse . Error Listener Ġ{ ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ ĠVol ley Singleton . getInstance ( getApplication ()). request Queue . add ( string Request ) ĊĊĊĠĠĠ Ġ} Ċ Ċ }