/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 2 ĠAd yen ĠN . V . Ċ Ġ* Ċ Ġ* ĠThis Ġfile Ġis Ġopen Ġsource Ġand Ġavailable Ġunder Ġthe ĠMIT Ġlicense . ĠSee Ġthe ĠLICENSE Ġfile Ġfor Ġmore Ġinfo . Ċ Ġ* Ċ Ġ* ĠCreated Ġby Ġj ose ph j Ġon Ġ 1 7 / 1 / 2 0 2 2 . Ċ Ġ*/ Ċ Ċ package Ġcom . ady en . checkout . drop in . ui . view model Ċ Ċ import Ġandroidx . lifecycle . Saved State Handle Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . ady en . checkout . core . log . Log Util Ċ import Ġcom . ady en . checkout . core . log . Logger Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . flow . receive As Flow Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠGoogle Pay ViewModel ( private Ġval Ġsaved State Handle : ĠSaved State Handle ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠTAG Ġ= ĠLog Util . getTag () ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠIS _ GOOGLE _ PAY _ STARTED Ġ= Ġ" IS _ GOOGLE _ PAY _ STARTED " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġevent Channel Ġ= ĠChannel < Google Pay Fragment Event >( Channel . BUFFER ED ) ĊĠĠĠ Ġinternal Ġval Ġevents Flow Ġ= Ġevent Channel . receive As Flow () ĊĊĠĠĠ Ġprivate Ġvar Ġis Google Pay Started : ĠBoolean ĊĠĠĠĠĠĠĠ Ġget () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġsaved State Handle [ IS _ GOOGLE _ PAY _ STARTED ] Ġ?: Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġset ( value ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsaved State Handle [ IS _ GOOGLE _ PAY _ STARTED ] Ġ= Ġvalue ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfragment Loaded () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( is Google Pay Started ) Ġreturn ĊĠĠĠĠĠĠĠ Ġis Google Pay Started Ġ= Ġtrue ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLogger . d ( TAG , Ġ" Sending Ġstart ĠGoogle Pay Ġevent ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevent Channel . send ( Google Pay Fragment Event . Start Google Pay ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ sealed Ġclass ĠGoogle Pay Fragment Event Ġ{ ĊĠĠĠ Ġobject ĠStart Google Pay Ġ: ĠGoogle Pay Fragment Event () Ċ } Ċ