package Ġcom . bar uck is . k ript of ol io . ui . add search list Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mediator LiveData Ċ import Ġcom . bar uck is . k ript of ol io . db . Crypt oc urrency Ċ import Ġcom . bar uck is . k ript of ol io . db . My Crypt oc urrency Ċ import Ġcom . bar uck is . k ript of ol io . repository . Crypt oc urrency Repository Ċ import Ġcom . bar uck is . k ript of ol io . ui . common . Base ViewModel Ċ import Ġcom . bar uck is . k ript of ol io . utilities . SERVER _ CALL _ DELAY _ MILLISECONDS Ċ import Ġcom . bar uck is . k ript of ol io . utilities . Time Format Ċ import Ġcom . bar uck is . k ript of ol io . vo . Resource Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠAdd Search ViewModel Ġ@ Inject Ġconstructor ( var Ġcrypt oc urrency Repository : ĠCrypt oc urrency Repository ) Ġ: ĠBase ViewModel () Ġ{ ĊĊĠĠĠ Ġval Ġmedi ator LiveData Crypt oc urrency Resource List Ġ= ĠMed iator LiveData < Resource < List < Crypt oc urrency >> >() ĊĠĠĠ Ġprivate Ġvar Ġlive Data Crypt oc urrency Resource List : ĠLive Data < Resource < List < Crypt oc urrency >>> Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcrypt oc urrency Repository . getAll Crypt oc urrency LiveData Resource List ( crypt oc urrency Repository . getCurrent Fi at Currency Code ()) ĊĊĠĠĠ Ġvar Ġselected Crypt oc urrency : ĠMy Crypt oc urrency ? Ġ= Ġnull ĊĠĠĠ Ġvar Ġis Swipe Refresh ing : ĠBoolean Ġ= Ġfalse ĊĠĠĠ Ġvar Ġlast Updated On Date : ĠString Ġ= Ġ"" ĊĠĠĠ Ġvar Ġis Search MenuItem Enabled : ĠBoolean Ġ= Ġtrue ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġmedi ator LiveData Crypt oc urrency Resource List . add Source ( live Data Crypt oc urrency Resource List ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmedi ator LiveData Crypt oc urrency Resource List . value Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġretry () Ġ{ ĊĠĠĠĠĠĠĠ Ġrefresh Crypt oc urrency Resource List ( SERVER _ CALL _ DELAY _ MILLISECONDS ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrefresh Crypt oc urrency Resource List ( call Delay : ĠLong Ġ= Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmedi ator LiveData Crypt oc urrency Resource List . remove Source ( live Data Crypt oc urrency Resource List ) ĊĠĠĠĠĠĠĠ Ġlive Data Crypt oc urrency Resource List Ġ= Ġcrypt oc urrency Repository . getAll Crypt oc urrency LiveData Resource List ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcrypt oc urrency Repository . getCurrent Fi at Currency Code (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtrue , Ġcall Delay ) ĊĠĠĠĠĠĠĠ Ġmedi ator LiveData Crypt oc urrency Resource List . add Source ( live Data Crypt oc urrency Resource List ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmedi ator LiveData Crypt oc urrency Resource List . value Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsearch ( search Text : ĠString ): ĠLive Data < List < Crypt oc urrency >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcrypt oc urrency Repository . getC rypt oc urrency LiveData ListBy Search ( search Text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠgetCurrent DateFormat (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcrypt oc urrency Repository . getCurrent DateFormat () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠgetCurrent Time Format (): ĠTime Format Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcrypt oc urrency Repository . getCurrent Time Format () ĊĠĠĠ Ġ} Ċ Ċ }