package Ġcom . s anti . rick ym ort y api . ui . favorites Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . s anti . rick ym ort y api . R Ċ import Ġcom . s anti . rick ym ort y api . databinding . F avorites Fragment Binding Ċ import Ġcom . s anti . rick ym ort y api . model . local . Location And Character Ċ import Ġcom . s anti . rick ym ort y api . view model . MainActivity ViewModel Ċ import Ġkotlinx . coroutines . Job ĊĊ Ċ class ĠF avorites Fragment : ĠFragment (), ĠF avorites Adapter . Character Db Item Listener Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠF avorites Fragment Binding ĊĠĠĠ Ġprivate Ġval ĠviewModel : ĠMainActivity ViewModel Ġby Ġactivity ViewModels () ĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠF avorites Fragment Binding . inflate ( in flater , Ġcontainer , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . root ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġbinding . recyclerview . layout Manager Ġ= ĠLinearLayoutManager ( activity ) ĊĠĠĠĠĠĠĠ ĠviewModel . favorites . observe ( view Lifecycle Owner , Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif ( it != null ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . recyclerview . adapter Ġ= ĠF avorites Adapter ( it , Ġthis ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġget F avorites () ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġfun Ġget F avorites (){ ĊĠĠĠĠĠĠĠ ĠviewModel . getF avorites () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonClick ed Db Character ( location And Character : ĠLocation And Character ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . from DB To Selected ( location And Character ) ĊĠĠĠĠĠĠĠ Ġfind Nav Controller (). navigate ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . action _ favorites Fragment _ to _ character Detail Fragment ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ }