package Ġit . il ker . repeat card . ui . directories Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . View . IN VISIBLE Ċ import Ġandroid . view . View . VISIBLE Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . constraint layout . widget . Constraint Layout Ċ import Ġandroidx . recyclerview . widget . Diff Util Ċ import Ġandroidx . recyclerview . widget . ListAdapter Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġit . il ker . repeat card . R Ċ import Ġit . il ker . repeat card . db . directory . Directory Ċ Ċ class ĠDirect ories Adapter ( private Ġval Ġclick Listener : ĠDirect ories Listener ) Ġ: ĊĠĠĠ ĠList Adapter < Directory , ĠDirect ories ViewHolder >( Directories Diff Util ()) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠDirect ories ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Inflater Ġ= ĠLayoutInflater . from ( parent . context ) ĊĠĠĠĠĠĠĠ Ġval Ġcell For Row Ġ= Ġlayout Inflater . inflate ( R . layout . directories _ row , Ġparent , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn ĠDirect ories ViewHolder ( cell For Row ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠDirect ories ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdirectory Ġ= ĠgetItem ( holder . adapter Position ) ĊĠĠĠĠĠĠĠ Ġholder . directory . text Ġ= Ġdirectory . title ĊĊĠĠĠĠĠĠĠ Ġ// ĠSet Ġdelete Ġbutton Ġto Ġinvisible Ġif Ġdefault Ġdirectory ĊĠĠĠĠĠĠĠ Ġholder . directory Delete . visibility Ġ= Ġif Ġ( holder . directory . text Ġ== ĠDEFAULT _ DIRECTORY _ NAME ) ĠIN VISIBLE Ġelse ĠVIS IBLE ĊĊĠĠĠĠĠĠĠ Ġholder . directory View . setOnClickListener Ġ{ Ġclick Listener . directory Clicked ( directory . id ) Ġ} ĊĠĠĠĠĠĠĠ Ġholder . directory Delete . setOnClickListener Ġ{ Ġclick Listener . item Deleted ( directory . id ) Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠDirect ories ViewHolder ( view : ĠView ) Ġ: ĠRecyclerView . ViewHolder ( view ) Ġ{ ĊĠĠĠ Ġval Ġdirectory : ĠTextView Ġ= Ġview . findViewById ( R . id . textView Directories Row ) ĊĠĠĠ Ġval Ġdirectory View : ĠConstraint Layout Ġ= Ġview . findViewById ( R . id . directories Row ) ĊĠĠĠ Ġval Ġdirectory Delete : ĠView Ġ= Ġview . findViewById ( R . id . delete Button Directories Row ) Ċ } Ċ Ċ interface ĠDirect ories Listener Ġ{ ĊĠĠĠ Ġfun Ġitem Deleted ( id : ĠInt ) ĊĠĠĠ Ġfun Ġdirectory Clicked ( id : ĠInt ) Ċ } Ċ Ċ class ĠDirect ories Diff Util Ġ: ĠDiff Util . Item Callback < Directory >() Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġare Items The Same ( old Item : ĠDirectory , Ġnew Item : ĠDirectory ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġold Item . id Ġ== Ġnew Item . id ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġare Contents The Same ( old Item : ĠDirectory , Ġnew Item : ĠDirectory ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġold Item . id Ġ== Ġnew Item . id ĊĠĠĠ Ġ} Ċ } Ċ