package Ġml . ars en iy 8 9 9 . bank account test . view Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġkotlinx . android . synt hetic . main . activity _ card _ select .* Ċ import Ġkotlinx . android . synt hetic . main . item _ card _ select . view .* Ċ import Ġml . ars en iy 8 9 9 . bank account test . R Ċ import Ġml . ars en iy 8 9 9 . bank account test . data . User Ċ Ċ class ĠCard Select Activity Ġ: ĠAppCompatActivity () Ċ { Ċ ĉ var Ġc urent Card Ġ: ĠUser ? Ġ= Ġnull Ċ ĉ var Ġc urent Card List Ġ: ĠArrayList < User >? Ġ= Ġnull Ċ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ċ ĉ { Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ card _ select ) Ċĉ ĉ c urent Card Ġ= Ġintent . extras ?. get (" current - card ") Ġas ? ĠUser Ċĉ ĉ c urent Card List Ġ= Ġintent . extras ?. get (" list - card ") Ġas ? ĠArrayList < User > ĊĉĉĊĉ ĉ if ( c urent Card List Ġ== Ġnull ) Ċĉ ĉ { Ċĉĉ ĉ Toast . makeText ( this ," ÐĶ Ð°Ð½ Ð½ÑĭÐµ ĠÐµ Ñī Ðµ ĠÐ½Ðµ ĠÐ¿Ð¾Ð»ÑĥÑĩ ÐµÐ½ Ñĭ . ĠÐŁ Ð¾Ð¿ ÑĢ Ð¾Ð± Ñĥ Ð¹ ÑĤÐµ ĠÐ¿Ð¾Ð· Ð¶Ðµ ", Ċĉĉĉ ĉ Toast . LENGTH _ LONG ). show () Ċĉĉ ĉ finish () Ċĉ ĉ } ĊĉĉĊĉ ĉ setup View () Ċ ĉ } Ċ ĉ fun Ġsetup View () Ċ ĉ { ĊĉĉĊĉ ĉ val Ġactivity Ġ= Ġthis ; Ċĉ ĉ finish . setOnClickListener Ġ{ Ġfinish ()} Ċĉ ĉ card Select List . apply Ġ{ Ċĉĉ ĉ layout Manager Ġ= ĠLinearLayoutManager ( activity ) Ċĉĉ ĉ if ( c urent Card Ġ!= Ġnull Ġ&& Ġc urent Card List Ġ!= Ġnull ) Ċĉĉĉ ĉ adapter Ġ= Ċĉĉĉĉ ĉ Select Card ListAdapter ( Ċĉĉĉĉĉ ĉ c urent Card !! , Ċĉĉĉĉĉ ĉ c urent Card List !! , Ċĉĉĉĉĉ ĉ activity ) Ċĉ ĉ } ĊĉĉĊ ĉ } Ċ ĉ class ĠSelect Card ViewHolder ( var Ġc urent Card Ġ: ĠUser , Ġinflater : ĠLayoutInflater , Ġparent : ĠViewGroup , Ċĉĉĉĉĉĉĉ ĠĠ Ġvar Ġactivity : ĠActivity ) Ġ: Ċĉ ĉ RecyclerView . ViewHolder ( in flater . inflate ( R . layout . item _ card _ select , Ġparent , Ġfalse )) Ċ ĉ { Ċĉ ĉ private Ġvar Ġcard Select IV : ĠImageView ? Ġ= Ġnull Ċĉ ĉ private Ġvar Ġcard Select TV : ĠTextView ? Ġ= Ġnull Ċĉ ĉ private Ġvar Ġcard Select Is Sel IV : ĠView ? Ġ= Ġnull ĊĉĉĊĉĉĊĉ ĉ init Ġ{ Ċĉĉ ĉ card Select IV Ġ= ĠitemView . card Select IV Ċĉĉ ĉ card Select TV Ġ= ĠitemView . card Select TV Ċĉĉ ĉ card Select Is Sel IV Ġ= ĠitemView . card Select Is Sel IV Ċĉ ĉ } ĊĉĉĊĉ ĉ fun Ġbind ( card Ġ: ĠUser ) Ġ{ Ċĉĉ ĉ card Select TV ?. text Ġ= Ġcard . card Number Ċĉĉ ĉ card Select IV ?. setImage Resource ( card . icon ) Ċĉĉ ĉ if ( c urent Card . card Number Ġ== Ġcard . card Number ) Ċĉĉĉ ĉ card Select Is Sel IV ?. visibility Ġ= ĠView . VISIBLE Ċĉĉ ĉ else Ċĉĉĉ ĉ card Select Is Sel IV ?. visibility Ġ= ĠView . GONE Ċĉĉ ĉ item View . setOnClickListener Ġ{ Ċĉĉĉ ĉ var Ġres Intent Ġ= ĠIntent (); Ċĉĉĉ ĉ res Intent . putExtra (" card ", Ġcard ) Ċĉĉĉ ĉ activity . set Result ( Activity . RESULT _ OK , res Intent ) Ċĉĉĉ ĉ activity . finish () Ċĉĉ ĉ } Ċĉ ĉ } ĊĉĉĊ ĉ } Ċ ĉ class ĠSelect Card ListAdapter ( var Ġc urent Card Ġ: ĠUser , Ġvar Ġlist Ġ: ĠArrayList < User >, var Ġactivity : ĠActivity ) Ċĉ ĉ : ĠRecyclerView . Adapter < Select Card ViewHolder >() Ġ{ Ċĉ ĉ override Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠSelect Card ViewHolder Ċĉ ĉ { Ċĉĉ ĉ val Ġinflater Ġ= ĠLayoutInflater . from ( parent . context ) Ċĉĉ ĉ return ĠSelect Card ViewHolder ( Ċĉĉĉ ĉ c urent Card , Ċĉĉĉ ĉ in flater , Ċĉĉĉ ĉ parent , Ċĉĉĉ ĉ activity ) Ċĉ ĉ } ĊĉĉĊĉ ĉ override Ġfun Ġon Bind ViewHolder ( holder : ĠSelect Card ViewHolder , Ġposition : ĠInt ) Ġ{ Ċĉĉ ĉ val Ġcard Ġ= Ġlist . get ( position ) Ċĉĉ ĉ holder . bind ( card ) Ċĉ ĉ } ĊĉĉĊĉ ĉ override Ġfun ĠgetItem Count (): ĠInt { Ċĉĉ ĉ return Ġlist . size Ċĉ ĉ } ĊĉĉĊ ĉ } Ċ } Ċ