package Ġid . ak . movies h ight light . presentation . discover čĊč Ċ import Ġandroid . content . Context č Ċ import Ġandroid . content . Intent č Ċ import Ġandroid . view . LayoutInflater č Ċ import Ġandroid . view . ViewGroup č Ċ import Ġandroidx . recyclerview . widget . RecyclerView č Ċ import Ġcom . bump tech . glide . G lide č Ċ import Ġid . ak . movies h ight light . databinding . List Movie Grid Binding č Ċ import Ġid . ak . movies h ight light . domain . ui . Discover Item č Ċ import Ġid . ak . movies h ight light . presentation . details . Details Activity čĊč Ċ class ĠDis cover Adapter ( čĊ ĉ private Ġval Ġcontext : ĠContext , čĊ ĉ private Ġval Ġitems : ĠList < Discover Item >, čĊ ĉ private Ġval Ġis Movie : ĠBoolean č Ċ ) Ġ: ĠRecyclerView . Adapter < Discover Adapter . Discover ViewHolder >() Ġ{ čĊčĊ ĉ override Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ) Ġ= ĠDis cover ViewHolder ( čĊĉ ĉ List Movie Grid Binding . inflate ( LayoutInflater . from ( context ), Ġparent , Ġfalse ) čĊ ĉ ) čĊčĊ ĉ override Ġfun Ġon Bind ViewHolder ( holder : ĠDis cover ViewHolder , Ġposition : ĠInt ) Ġ{ čĊĉ ĉ holder . bind Item ( items [ position ]) čĊ ĉ } čĊčĊ ĉ override Ġfun ĠgetItem Count (): ĠInt Ġ= Ġitems . size čĊčĊ ĉ inner Ġclass ĠDis cover ViewHolder ( private Ġval Ġbinding : ĠList Movie Grid Binding ) Ġ: čĊĉ ĉ RecyclerView . ViewHolder ( binding . root ) Ġ{ čĊčĊĉ ĉ fun Ġbind Item ( item : ĠDis cover Item ) Ġ{ čĊĉĉ ĉ with ( binding ) Ġ{ čĊĉĉĉ ĉ G lide . with ( context ) čĊĉĉĉĉ ĉ . load ( item . poster Url ) čĊĉĉĉĉ ĉ . into ( iv Post er ) čĊčĊĉĉĉ ĉ tv Title . text Ġ= Ġitem . title čĊĉĉĉ ĉ rating . rating Ġ= Ġitem . rating . toFloat () Ġ/ Ġ 2 čĊĉĉĉ ĉ tv Rating . text Ġ= Ġitem . rating . toString () čĊčĊĉĉĉ ĉ root . setOnClickListener Ġ{ čĊĉĉĉĉ ĉ val Ġi Ġ= ĠIntent ( context , ĠDetails Activity :: class . java ). apply Ġ{ čĊĉĉĉĉĉ ĉ putExtra (" id ", Ġitem . id ) čĊĉĉĉĉĉ ĉ putExtra (" is Movie ", Ġis Movie ) čĊĉĉĉĉ ĉ } čĊĉĉĉĉ ĉ context . startActivity ( i ) čĊĉĉĉ ĉ } čĊĉĉ ĉ } čĊĉ ĉ } čĊ ĉ } č Ċ }