package Ġcom . radix d lt . android . apps . pos . ui . payment Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . Connectivity Manager Ċ import Ġandroid . net . Network Ċ import Ġandroid . net . Network Capabilities Ċ import Ġandroid . net . Network Request Ċ import Ġandroid . os . Handler Ċ import Ġandroid . os . Looper Ċ Ċ abstract Ġclass ĠConnection State Monitor Ġ: ĠConnect ivity Manager . Network Callback () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġnetwork Request : ĠNetwork Request Ġ= ĠNetwork Request . Builder () ĊĠĠĠĠĠĠĠ Ġ. add Transport Type ( Network Capabilities . TRANSPORT _ CELL ULAR ) ĊĠĠĠĠĠĠĠ Ġ. add Transport Type ( Network Capabilities . TRANSPORT _ WIFI ) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġfun Ġenable ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnectivity Manager Ġ= Ġcontext . getSystem Service ( Context . CONNECT IVITY _ SERVICE ) Ġas ĠConnect ivity Manager ĊĠĠĠĠĠĠĠ Ġconnectivity Manager . register Network Callback ( network Request , Ġthis ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdisable ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnectivity Manager Ġ= Ġcontext . getSystem Service ( Context . CONNECT IVITY _ SERVICE ) Ġas ĠConnect ivity Manager ĊĠĠĠĠĠĠĠ Ġconnectivity Manager . unregister Network Callback ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Available ( network : ĠNetwork ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Available ( network ) ĊĠĠĠĠĠĠĠ ĠHandler ( Looper . get Main Looper ()). post Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Connected ( true ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Lost ( network : ĠNetwork ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Lost ( network ) ĊĠĠĠĠĠĠĠ ĠHandler ( Looper . get Main Looper ()). post Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis Connected ( false ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġabstract Ġfun Ġis Connected ( connected : ĠBoolean ) Ċ } Ċ