package Ġnl . r ws link man . sim device ble . ui . data Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . text . Editable Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Relative Layout Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġnl . r ws link man . sim device ble . App Model Ċ import Ġnl . r ws link man . sim device ble . R Ċ import Ġnl . r ws link man . sim device ble . device . model . Characteristic Ċ import Ġnl . r ws link man . sim device ble . device . model . Device Ċ import Ġjava . util .* Ċ Ċ class ĠService Data Fragment Ġ: ĠFragment () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġmanipulation Listener Ġ= Ġobject Ġ: ĠService Data Adapter . Characteristic Manip ulation Listener Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġset Characteristic Value ( character istic : ĠCharacter istic , ĠsetValue : ĠAny ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" set Characteristic Value : Ġset Ġvalue Ġto Ġ$ setValue ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Model . update Characteristic Value ( character istic , ĠsetValue . toString ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġnotify Characteristic ( character istic : ĠCharacter istic ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . d ( TAG , Ġ" notify Characteristic : Ġsend Ġnotification ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Model . send Characteristic Notification ( character istic ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġapp Model : ĠApp Model Ġby Ġactivity ViewModels () ĊĠĠĠ Ġprivate Ġval Ġservices Adapter Ġ= ĠService Data Adapter ( manip ulation Listener ) ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġroot Ġ= Ġinflater . inflate ( R . layout . fragment _ serv iced ata , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġval Ġnot Ad vertising View : ĠTextView Ġ= Ġroot . findViewById ( R . id . block _ not _ ad vertising ) ĊĠĠĠĠĠĠĠ Ġval Ġservices View : ĠRelative Layout Ġ= Ġroot . findViewById ( R . id . block _ services ) ĊĊĠĠĠĠĠĠĠ Ġ// ĠList Ġwith Ġsubscription Ġto Ġauto Ġupdate Ġitself ĊĠĠĠĠĠĠĠ Ġroot . findViewById < RecyclerView >( R . id . serv iced ata _ list ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġservices Adapter ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġapp Model . active Device . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Device Services () ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġapp Model . present able Data Container . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Device Services () ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġ// ĠToggle Ġview Ġvisibility ĊĠĠĠĠĠĠĠ Ġapp Model . is Ad vertising . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnot Ad vertising View . visibility Ġ= Ġif Ġ( it ) ĠView . GONE Ġelse ĠView . VISIBLE ĊĠĠĠĠĠĠĠĠĠĠĠ Ġservices View . visibility Ġ= Ġif Ġ( it ) ĠView . VISIBLE Ġelse ĠView . GONE ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġreturn Ġroot ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Device Services () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Ad vertising : ĠBoolean Ġ= Ġapp Model . is Ad vertising . value Ġ?: Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ(! is Ad vertising ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġactive Device : ĠDevice Ġ= Ġapp Model . active Device . value !! ĊĠĠĠĠĠĠĠ Ġval Ġcurrent Data : ĠMap < UUID , ĠString > Ġ= Ġapp Model . present able Data Container . value !! ĊĊĠĠĠĠĠĠĠ Ġservices Adapter . update DataSet ( active Device . services , Ġcurrent Data ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠTAG Ġ= Ġ" Service Data Fragment " ĊĠĠĠ Ġ} Ċ }