package Ġcom . h xb reak . animal cross ing tools . ui . v ill ager Ċ Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . recyclerview . widget . Grid LayoutManager Ċ import Ġandroidx . recyclerview . widget . St agger ed Grid LayoutManager Ċ import Ġandroidx . transition . Transition Set Ċ import Ġcom . google . android . material . transition . Material Arc Motion Ċ import Ġcom . google . android . material . transition . Material Container Transform Ċ import Ġcom . google . android . material . transition . Material Shared Axis Ċ import Ġcom . h xb reak . animal cross ing tools . R Ċ import Ġcom . h xb reak . animal cross ing tools . adapter . Common Item Decoration Ċ import Ġcom . h xb reak . animal cross ing tools . adapter . Selection Adapter Ċ import Ġcom . h xb reak . animal cross ing tools . ui . Back Ab le App bar Fragment Ċ import Ġdagger . h ilt . android . Android EntryPoint Ċ import Ġkotlinx . android . synt hetic . main . fragment _ v ill ager .* Ċ import Ġjava . lang . Exception Ċ Ċ @ Android EntryPoint Ċ class ĠV ill ager Fragment Ġ: ĠBack Ab le App bar Fragment (){ ĊĊĠĠĠ Ġprivate Ġval ĠviewModel Ġby Ġview Models < V ill ager ViewModel >() ĊĊĠĠĠ Ġprivate Ġval Ġtransition Set Ġ= ĠTransition Set () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġval Ġforward Ġ= ĠMaterial Shared Axis ( Material Shared Axis . X , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġenter Transition Ġ= Ġforward ĊĊĠĠĠĠĠĠĠ Ġval Ġbackward Ġ= ĠMaterial Shared Axis ( Material Shared Axis . X , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn Transition Ġ= Ġbackward ĊĠĠĠĠĠĠĠ Ġval Ġtransform Ġ= ĠMaterial Container Transform () ĊĠĠĠĠĠĠĠ Ġtransform . scri m Color Ġ= ĠColor . TRANSP ARENT ĊĠĠĠĠĠĠĠ Ġtransform . set Path Motion ( Material Arc Motion ()) ĊĠĠĠĠĠĠĠ Ġtransition Set . duration Ġ= Ġ 3 0 0 ĊĠĠĠĠĠĠĠ Ġtransition Set . add Transition ( transform ) ĊĠĠĠĠĠĠĠ Ġshared Element Enter Transition Ġ= Ġtransition Set ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ v ill ager , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġvar Ġadapter : ĠSelection Adapter ? Ġ= Ġnull ĊĊĠĠĠ Ġfun Ġrequire Adapter () Ġ= Ġadapter Ġ?: Ġthrow ĠIllegalStateException (" adapter Ġis Ġnull ") ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġrequire Toolbar (). title Ġ= Ġ"" ĊĠĠĠĠĠĠĠ Ġrequire Toolbar Title (). setText ( getString ( R . string . v ill ager _ catalog )) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠSelection Adapter () ĊĠĠĠĠĠĠĠ ĠviewModel . loading . observe ( view Lifecycle Owner ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrefresh _ layout . is Refresh ing Ġ= Ġit Ġ== Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġrefresh _ layout . setOn Refresh Listener Ġ{ ĠviewModel . refresh . value Ġ= Ġtrue Ġ} ĊĠĠĠĠĠĠĠ ĠviewModel . error . observe ( view Lifecycle Owner ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it Ġis ĠException ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcommon _ layout . set Exception ( it ){ ĠviewModel . refresh . value Ġ= Ġtrue Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} else { ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcommon _ layout . clear State () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġrequire Adapter (). register ( V ill ager View Binder ( viewModel , Ġview Lifecycle Owner )) ĊĠĠĠĠĠĠĠ ĠviewModel . v ill agers . observe ( view Lifecycle Owner ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrequire Adapter (). submit List ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġre cycler _ view . layout Manager Ġ= ĠSt agger ed Grid LayoutManager ( 3 , ĠGrid LayoutManager . VERTICAL ) ĊĠĠĠĠĠĠĠ Ġre cycler _ view . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġre cycler _ view . addItem Decoration ( Common Item Decoration ( require Context ())) ĊĠĠĠ Ġ} Ċ Ċ }