package Ġcomp osable architecture . example . search Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . net . Uri Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . core . widget . do After TextChanged Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . lifecycle . lifecycle Scope Ċ import Ġandroidx . recyclerview . widget . Divider Item Decoration Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcomp osable architecture . example . search . databinding . Search Activity Binding Ċ import Ġkotlinx . coroutines . flow . collect Ċ Ċ class ĠSearch Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġstore Ġ= ĠSearch App . store ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠData Binding Util ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set ContentView < Search Activity Binding >( this , ĠR . layout . search _ activity ) ĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= Ġthis ĊĊĠĠĠĠĠĠĠ Ġbinding . search Input . do After TextChanged Ġ{ Ġtext Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstore . send ( Search Action . Search Query Changed ( text . toString ())) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġsearch Adapter Ġ= ĠSearch Adapter ( on Location Tap Ġ= Ġ{ Ġstore . send ( Search Action . Location T apped ( it )) Ġ}) ĊĠĠĠĠĠĠĠ Ġbinding . search Results . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġsearch Adapter ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadd Item Decoration ( Divider Item Decoration ( context , ĠDiv ider Item Decoration . VERTICAL )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . search Credit Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartActivity ( Intent ( Intent . ACTION _ VIEW , ĠUri . parse (" https :// www . met aw e ather . com / "))) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġlifecycle Scope . launch When Created Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstore . states . collect Ġ{ Ġstate Ġ-> Ġsearch Adapter . update ( state ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ