package Ġcom . sil k ys ys . um co . ui . explore Ċ Ċ import Ġandroid . view . View Ċ import Ġandroid . view . View . IN VISIBLE Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . sil k ys ys . um co . R Ċ import Ġcom . sil k ys ys . um co . data . model . categories . all . All Categories Response Ċ import Ġcom . sil k ys ys . um co . data . network . Resource Ċ import Ġcom . sil k ys ys . um co . databinding . Fragment Explore Binding Ċ import Ġcom . sil k ys ys . um co . ui . adapter . explore . Explore Adapter Ċ import Ġcom . sil k ys ys . um co . ui . search . Search Activity Ċ import Ġcom . sil k ys ys . um co . util . Base Fragment Ċ import Ġcom . sil k ys ys . um co . util . handle ApiError Ċ import Ġcom . sil k ys ys . um co . util . startActivity Ċ import Ġdagger . h ilt . android . Android EntryPoint ĊĊ Ċ @ Android EntryPoint Ċ class ĠExplo re Fragment Ġ: ĠBase Fragment < Fragment Explore Binding >( Fragment Explore Binding :: inflate ), ĊĠĠĠ ĠView . OnClickListener Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠExplo re ViewModel ĊĊĠĠĠ Ġoverride Ġfun ĠFragment Explore Binding . initialize () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Provider ( this @ Explore Fragment )[ Explore ViewModel :: class . java ] ĊĠĠĠĠĠĠĠ ĠviewModel . init Get Categories () ĊĠĠĠĠĠĠĠ ĠviewModel . categories Response . observe ( view Lifecycle Owner ) Ġ{ Ġresponse Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġupdate Ui ( response ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbinding . iv Search . setOnClickListener ( this @ Explore Fragment ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonClick ( item : ĠView ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( item . id Ġ== ĠR . id . iv _ search ) Ġrequire Context (). startActivity ( Search Activity :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġupdate Ui ( response : ĠResource < All Categories Response > ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . progress Bar . visibility Ġ= ĠIN VISIBLE ĊĠĠĠĠĠĠĠ Ġif Ġ( response Ġis ĠResource . Success ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcategories Ġ= Ġresponse . value . data ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( categories Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠBased Ġon Ġtitle Ġonly ( true Ġor Ġfalse ) Ġwe Ġdisplay Ġrequired Ġlayout ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . rv Category . adapter Ġ= ĠExplo re Adapter ( categories ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġif Ġ( response Ġis ĠResource . Failure ) Ġhandle ApiError ( response ) ĊĠĠĠ Ġ} Ċ }