package Ġcom . y zh . sun ny weather . ui . place Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . y zh . sun ny weather . R Ċ import Ġcom . y zh . sun ny weather . logic . model . Place Ċ import Ġcom . y zh . sun ny weather . ui . weather . Weather Activity Ċ Ċ class ĠPlace Adapter ( private Ġval Ġfragment : ĠPlace Fragment , Ġprivate Ġval Ġplace List : ĠList < Place >) Ġ: RecyclerView . Adapter < Place Adapter . View H od ler > (){ ĊĊĠĠĠ Ġinner Ġclass ĠView H od ler ( view Ġ: View ): RecyclerView . ViewHolder ( view ){ ĊĠĠĠĠĠĠĠ Ġval Ġplace Name : TextView = view . findViewById ( R . id . place Name ) ĊĠĠĠĠĠĠĠ Ġval Ġplace Address : TextView = view . findViewById ( R . id . place Address ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠView H od ler Ġ{ ĊĠ Ġval Ġview = ĠLayoutInflater . from ( parent . context ). inflate ( R . layout . place _ item , parent , false ) ĊĊĠĠĠĠĠĠĠ Ġval Ġhod ler Ġ= ĠView H od ler ( view ) ĊĠĠĠĠĠĠĠ Ġhod ler . item View . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlocation = place List [ hod ler . adapter Position ] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . viewModel . save Place ( location ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . startActivity ( Intent ( parent . context , Weather Activity :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Extra (" location _ lng ", location . location . lng ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Extra (" location _ lat ", location . location . lat ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Extra (" place _ name ", location . name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . activity ?. finish () ĊĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġhod ler ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠView H od ler , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġplace = place List [ position ] ĊĠĠĠĠĠĠĠ Ġholder . place Name . text = place . name ĊĠĠĠĠĠĠĠ Ġholder . place Address . text = place . address ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠ Ġreturn Ġplace List . size ĊĠĠĠ Ġ} Ċ }