package Ġbe . sci ens ano . cor on alert . ui . submission Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġbe . sci ens ano . cor on alert . Mobile TestId Ċ import Ġbe . sci ens ano . cor on alert . storage . k Ċ import Ġbe . sci ens ano . cor on alert . storage . r 0 Ċ import Ġbe . sci ens ano . cor on alert . storage . t 0 Ċ import Ġde . r ki . cor on aw arn app . storage . Local Data Ċ import Ġjava . util . Calendar Ċ import Ġjava . util . Date Ċ Ċ class ĠSubmission Test Request ViewModel Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠTAG : ĠString ? Ġ= ĠSubmission Test Request ViewModel :: class . simple Name ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠDAY S _ MINUS Ġ= Ġ 2 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġsubmission Date : ĠMutable LiveData < Date > Ġ= ĠMutable LiveData ( Date ()) ĊĊĠĠĠ Ġfun Ġset Submission Date ( date : ĠDate ) Ġ= Ġrun Ġ{ Ġsubmission Date . value Ġ= Ġdate Ġ} ĊĊĠĠĠ Ġfun Ġgenerate TestId (): ĠMobile TestId Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcal Ġ= ĠCalendar . getInstance () ĊĠĠĠĠĠĠĠ Ġcal . time Ġ= Ġsubmission Date . value !! ĊĠĠĠĠĠĠĠ Ġcal . add ( Calendar . DATE , Ġ- DAYS _ MINUS ) ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Date Minus 2 Ġ= Ġcal . time ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Id Ġ= ĠMobile TestId . generate ( submission Date Minus 2 ) ĊĠĠĠĠĠĠĠ Ġsave TestId ( test Id ) ĊĠĠĠĠĠĠĠ Ġreturn Ġtest Id ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġsave TestId ( mobile TestId : ĠMobile TestId ) Ġ{ ĊĠĠĠĠĠĠĠ ĠLocal Data . t 0 ( mobile TestId . t 0 ) ĊĠĠĠĠĠĠĠ ĠLocal Data . r 0 ( mobile TestId . r 0 ) ĊĠĠĠĠĠĠĠ ĠLocal Data . k ( mobile TestId . k ) ĊĠĠĠĠĠĠĠ ĠLocal Data . registration Token ( mobile TestId . registration Token ()) ĊĠĠĠĠĠĠĠ ĠLocal Data . initial Polling For TestResult TimeStamp ( System . currentTimeMillis ()) ĊĠĠĠ Ġ} Ċ } ĊĊ