package Ġo sp . le ob ert . android . pager tracker demo . index . ui . notifications Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġkotlinx . android . synt hetic . main . fragment _ demo _ notify .* Ċ import Ġo sp . le ob ert . android . pager tracker demo . Base Fragment Ċ import Ġo sp . le ob ert . android . pager tracker demo . R Ċ import Ġo sp . le ob ert . android . pager tracker demo . bio . Bio Activity Ċ import Ġo sp . le ob ert . android . tracker . pager . IT rack ed Pager Ċ import Ġo sp . le ob ert . android . tracker . pager . Tracked Pager ĊĊ Ċ @ Tracked Pager ( pager Point Ġ= Ġ" P _ NOTIFY _ FG ", Ġwhen Fragment Ġ= ĠTrack ed Pager . Fragment Strategy . REPLACE _ ACTIVITY ) Ċ class ĠNotifications Fragment Ġ: ĠBase Fragment (), ĠI Tracked Pager . Fragment In ViewPager Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnotifications ViewModel : ĠNotifications ViewModel ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġnotifications ViewModel Ġ= ĠViewModel Providers . of ( this ). get ( Notifications ViewModel :: class . java ) ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . fragment _ demo _ notify , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġnotification _ rv . layout Manager Ġ= ĠLinearLayoutManager ( notification _ rv . context ) ĊĠĠĠĠĠĠĠ Ġnotifications ViewModel . notifications . observe ( view Lifecycle Owner , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnotification _ rv . adapter Ġ= ĠNotifications Adapter ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠNotification VH ( parent : ĠViewGroup ) Ġ: ĠRecyclerView . ViewHolder ( LayoutInflater . from ( parent . context ). inflate ( R . layout . vh _ notification , Ġparent , Ġfalse )) Ġ{ ĊĊĠĠĠ Ġval Ġtv Name Ġ= ĠitemView . findViewById < TextView >( R . id . tv _ user ) ĊĠĠĠ Ġval Ġtv Msg Ġ= ĠitemView . findViewById < TextView >( R . id . tv _ msg ) ĊĠĠĠ Ġvar Ġnotification : ĠNotification ? Ġ= Ġnull ĊĊĠĠĠ Ġinit Ġ{ ĊĊĠĠĠĠĠĠĠ ĠitemView . setOnClickListener Ġ{ Ġv Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnotification ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBio Activity . launch ( v . context , Ġit . userId ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġbind ( notification : ĠNotification ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . notification Ġ= Ġnotification ĊĠĠĠĠĠĠĠ Ġtv Name . text Ġ= Ġnotification . userName ĊĠĠĠĠĠĠĠ Ġtv Msg . text Ġ= Ġnotification . message ĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ class ĠNotifications Adapter ( val Ġlist : ĠList < Notification >) Ġ: ĠRecyclerView . Adapter < Notification VH >() Ġ{ ĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠNotification VH Ġ= ĠNotification VH ( parent ) ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ= Ġlist . size ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠNotification VH , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġholder . bind ( list [ position ]) ĊĠĠĠ Ġ} Ċ Ċ }