package Ġcom . tak w olf . android . demo . h fre cycler view . holder Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroidx . lifecycle . Lifecycle Owner Ċ import Ġandroidx . view pager 2 . widget . ViewPager 2 Ċ import Ġcom . tak w olf . android . demo . h fre cycler view . adapter . Banner Page Adapter Ċ import Ġcom . tak w olf . android . demo . h fre cycler view . data . Photo Ċ import Ġcom . tak w olf . android . demo . h fre cycler view . databinding . Header ViewPager Binding Ċ import Ġcom . tak w olf . android . demo . h fre cycler view . vm . Banner Page ViewModel Ċ import Ġcom . tak w olf . android . demo . h fre cycler view . vm . Photo List ViewModel Ċ import Ġcom . tak w olf . android . h fre cycler view . Header And Footer RecyclerView Ċ Ċ class ĠBanner Page Header ( re cyclerView : ĠHeader And Footer RecyclerView ) Ġ{ ĊĠĠĠ Ġval Ġbinding Ġ= ĠHeader ViewPager Binding . inflate ( LayoutInflater . from ( re cyclerView . context ), Ġre cyclerView . header View Container , Ġfalse ) ĊĠĠĠ Ġval Ġadapter Ġ= ĠBanner Page Adapter () ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . view Pager . adapter Ġ= Ġadapter ĊĠĠĠĠĠĠĠ Ġre cyclerView . add Header View ( binding . root ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġlisten ( owner : ĠLifecycle Owner , Ġbanner Page ViewModel : ĠBanner Page ViewModel , Ġphoto List ViewModel : ĠPhoto List ViewModel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbanner Page ViewModel . entities Data . observe ( owner ) Ġ{ Ġcolor Infos Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . submit List ( color Infos ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbinding . view Pager . register On Page Change Callback ( object Ġ: ĠView Pager 2 . On Page Change Callback () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Page Selected ( position : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġphoto List ViewModel . entities Data . value Ġ= ĠPhoto . getList () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ } Ċ