package Ġnet . sky scanner . back pack . demo . data Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . text . TextUtils . get Layout Direction From Locale Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġandroidx . core . view . View Compat . LAYOUT _ DIRECTION _ RTL Ċ import Ġnet . sky scanner . back pack . calendar . model . Calendar Color ing Ċ import Ġnet . sky scanner . back pack . calendar . model . Calendar Day Ċ import Ġnet . sky scanner . back pack . calendar . model . Calendar Range Ċ import Ġnet . sky scanner . back pack . calendar . model . Colo red Bucket Ċ import Ġnet . sky scanner . back pack . calendar . presenter . B pk Calendar Controller Ċ import Ġnet . sky scanner . back pack . demo . R Ċ import Ġjava . util . Calendar Ċ import Ġjava . util . Locale Ċ import Ġjava . util . TimeZone Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ class ĠExample B pk Calendar Controller ( private Ġval Ġcontext : ĠContext ) Ġ: ĠB pk Calendar Controller () Ġ{ ĊĠ Ġoverride Ġfun Ġon Range Selected ( range : ĠCalendar Range ) Ġ{ ĊĠĠĠ ĠToast . makeText ( context , ĠString . format ("% s Ġ- Ġ% s ", Ġrange . start . toString (), Ġrange . end . toString ()), ĠToast . LENGTH _ SHORT ) ĊĠĠĠĠĠ Ġ. show () ĊĠ Ġ} ĊĊĠ Ġvar Ġis Colo red Calendar : ĠBoolean Ġ= Ġfalse ĊĠ Ġvar Ġcolor Generation Offset : ĠLong Ġ= Ġ 0 L ĊĊĠ Ġoverride Ġval Ġis R tl : ĠBoolean Ġ= Ġget Layout Direction From Locale ( Locale . getDefault ()) Ġ== ĠLAY OUT _ DIRECTION _ RTL ĊĠ Ġoverride Ġval Ġlocale : ĠLocale Ġ= ĠLocale . getDefault () ĊĠ Ġoverride Ġval Ġcalendar Color ing : ĠCalendar Color ing ? ĊĠĠĠ Ġget () Ġ= Ġif Ġ( is Colo red Calendar ) Ġ{ ĊĠĠĠĠĠ Ġmulti Colo red Example Calendar Color ing () ĊĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠ Ġnull ĊĠĠĠ Ġ} ĊĊĠ Ġfun Ġnew Colors () Ġ{ ĊĠĠĠ Ġcolor Generation Offset Ġ+= Ġ 1 ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmulti Colo red Example Calendar Color ing (): ĠCalendar Color ing Ġ{ ĊĠĠĠ Ġval Ġdays Between Start And End Ġ= ĠTimeUnit . DAYS . convert ( endDate . date . time Ġ- ĠstartDate . date . time , ĠTimeUnit . MILLISECONDS ) ĊĠĠĠ Ġval Ġcalendar Ġ= ĠCalendar . getInstance ( TimeZone . getTime Zone (" UTC ")) ĊĠĠĠ Ġval Ġred Set Ġ= Ġmutable Set Of < Calendar Day >() ĊĠĠĠ Ġval Ġyellow Set Ġ= Ġmutable Set Of < Calendar Day >() ĊĠĠĠ Ġval Ġgreen Set Ġ= Ġmutable Set Of < Calendar Day >() ĊĠĠĠ Ġval Ġgrey Set Ġ= Ġmutable Set Of < Calendar Day >() ĊĠĠĠ Ġfor Ġ( i Ġin Ġ 0 Ġuntil Ġdays Between Start And End ) Ġ{ ĊĠĠĠĠĠ Ġval Ġshifted Iterator Ġ= Ġi Ġ+ Ġcolor Generation Offset ĊĠĠĠĠĠ Ġwhen Ġ{ ĊĠĠĠĠĠĠĠ Ġshifted Iterator Ġ% Ġ 4 Ġ== Ġ 0 L Ġ-> Ġred Set ĊĠĠĠĠĠĠĠ Ġshifted Iterator Ġ% Ġ 4 Ġ== Ġ 1 L Ġ-> Ġyellow Set ĊĠĠĠĠĠĠĠ Ġshifted Iterator Ġ% Ġ 4 Ġ== Ġ 2 L Ġ-> Ġgreen Set ĊĠĠĠĠĠĠĠ Ġshifted Iterator Ġ% Ġ 4 Ġ== Ġ 3 L Ġ-> Ġgrey Set ĊĠĠĠĠĠĠĠ Ġelse Ġ-> Ġmutable Set Of () ĊĠĠĠĠĠ Ġ}. add ( Calendar Day ( calendar . get ( Calendar . YEAR ), Ġcalendar . get ( Calendar . MONTH ), Ġcalendar . get ( Calendar . DAY _ OF _ MONTH ))) ĊĠĠĠĠĠ Ġcalendar . add ( Calendar . DATE , Ġ 1 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn ĠCalendar Color ing ( ĊĠĠĠĠĠ Ġset Of ( ĊĠĠĠĠĠĠĠ ĠCo lo red Bucket ( Context Compat . getColor ( context , ĠR . color . b pk Red 5 0 0 ), Ġred Set ), ĊĠĠĠĠĠĠĠ ĠCo lo red Bucket ( Context Compat . getColor ( context , ĠR . color . b pk Yellow 5 0 0 ), Ġyellow Set ), ĊĠĠĠĠĠĠĠ ĠCo lo red Bucket ( Context Compat . getColor ( context , ĠR . color . b pk Green 5 0 0 ), Ġgreen Set ), ĊĠĠĠĠĠĠĠ ĠCo lo red Bucket ( Context Compat . getColor ( context , ĠR . color . b pk Gray 1 0 0 ), Ġgrey Set ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ