package Ġdev . ke ader . corre io str acker . view . adapters Ċ Ċ import Ġandroid . text . method . Link Movement Method Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . core . text . Html Compat Ċ import Ġandroidx . databinding . Binding Adapter Ċ import Ġdev . ke ader . corre io str acker . R Ċ import Ġdev . ke ader . corre io str acker . database . Item Ċ import Ġdev . ke ader . corre io str acker . database . Item With Tracks Ċ import Ġdev . ke ader . corre io str acker . database . Track Ċ import Ġjava . time . LocalDate Ċ import Ġjava . time . LocalDateTime Ċ import Ġjava . time . format . DateTime Formatter Ċ import Ġjava . time . temporal . Ch rono Unit Ċ import Ġjava . util .* Ċ Ċ @ Binding Adapter (" track Image ") Ċ fun ĠImageView . set Track Icon ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġset Image Resource ( when Ġ( item . item . is Deliver ed ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtrue Ġ-> ĠR . drawable . box 2 ĊĠĠĠĠĠĠĠ Ġfalse Ġ-> ĠR . drawable . tr uck 2 ĊĠĠĠ Ġ}) Ċ } Ċ Ċ @ Binding Adapter (" track Date Text ") Ċ fun ĠTextView . setDate Text ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġtext Ġ= Ġitem . tracks . first (). date Ċ } Ċ Ċ @ Binding Adapter (" track Time Text ") Ċ fun ĠTextView . setTime Text ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġtext Ġ= Ġitem . tracks . first (). time Ċ } Ċ Ċ @ Binding Adapter (" track Status ") Ċ fun ĠTextView . set Track Status ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġtext Ġ= Ġitem . tracks . first (). status Ċ } Ċ Ċ @ Binding Adapter (" track Observation ") Ċ fun ĠTextView . set Track Observation ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġval Ġobservation Ġ= Ġitem . tracks . first (). observation ĊĠĠĠ Ġif Ġ( observation . isNotEmpty ()) ĊĠĠĠĠĠĠĠ Ġtext Ġ= Ġobservation ĊĠĠĠ Ġelse ĊĠĠĠĠĠĠĠ Ġvisibility Ġ= ĠView . GONE Ċ } Ċ Ċ @ Binding Adapter (" track Locale ") Ċ fun ĠTextView . set Track Locale ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġtext Ġ= Ġitem . tracks . first (). locale Ċ } Ċ Ċ @ Binding Adapter (" days S pend ") Ċ fun ĠTextView . set Days S pend ( item : ĠItem With Tracks ) Ġ{ ĊĠĠĠ Ġval Ġformatter Ġ= ĠDateTime Formatter . of Pattern (" dd / MM / yyyy ") ĊĠĠĠ Ġval ĠstartDate Ġ= ĠLocalDate . parse ( item . tracks . last (). date , Ġformatter ) ĊĠĠĠ Ġval ĠendDate Ġ= ĠLocalDateTime . now () ĊĠĠĠ Ġvar Ġdifference Ġ= ĠstartDate . until ( endDate , ĠCh rono Unit . DAYS ) ĊĊĠĠĠ Ġif Ġ( item . item . is Deliver ed ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdelivery Date Ġ= ĠLocalDate . parse ( item . tracks . first (). date , Ġformatter ) ĊĠĠĠĠĠĠĠ Ġdifference Ġ= ĠstartDate . until ( delivery Date , ĠCh rono Unit . DAYS ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġtext Ġ= Ġcontext . resources . get Quantity String ( R . plurals . duration _ days , Ġdifference . toInt (), Ġdifference . toString ()) Ċ } Ċ Ċ @ Binding Adapter (" observation ") Ċ fun ĠTextView . set Observation ( track : ĠTrack ) Ġ{ ĊĠĠĠ Ġif Ġ( track . observation . isEmpty ()) ĊĠĠĠĠĠĠĠ Ġvisibility Ġ= ĠView . GONE ĊĠĠĠ Ġelse ĊĠĠĠĠĠĠĠ Ġtext Ġ= Ġtrack . observation Ċ } Ċ Ċ @ Binding Adapter (" set Link ") Ċ fun ĠTextView . set Link ( track : ĠTrack ) Ġ{ ĊĠĠĠ Ġif Ġ( track . link . isNotEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstring Ġ= Ġif Ġ( track . link . contains (" pr azo ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . getString ( R . string . imports ) ĊĠĠĠĠĠĠĠ Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . getString ( R . string . dead lines ) ĊĠĠĠĠĠĠĠ Ġval Ġlink Ġ= Ġ"< a Ġhref =\" ${ track . link }\ ">${ string }</ a >" ĊĠĠĠĠĠĠĠ Ġval Ġsp ann able Ġ= ĠHtml Compat . from Html ( link , 0 ) ĊĠĠĠĠĠĠĠ Ġmovement Method Ġ= ĠLink Movement Method . getInstance () ĊĠĠĠĠĠĠĠ Ġtext Ġ= Ġsp ann able ĊĠĠĠĠĠĠĠ Ġvisibility Ġ= ĠView . VISIBLE ĊĠĠĠ Ġ} Ċ } Ċ Ċ @ Binding Adapter (" setType ") Ċ fun ĠTextView . setType ( item : ĠItem ) Ġ{ ĊĠĠĠ Ġval Ġlocale Ġ= ĠLocale . getDefault () ĊĠĠĠ Ġtext Ġ= Ġitem . type . toLowerCase ( locale ). capitalize ( locale ) Ċ } Ċ