package Ġcom . hol lab rowser . me force . network Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroid . net . Connectivity Manager Ċ import Ġcom . hol lab rowser . me force . rx . Broadcast Receiver Observable Ċ import Ġdagger . Re usable Ċ import Ġio . reactivex . Observable Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠA Ġmodel Ġthat Ġsupp lies Ġnetwork Ġconnectivity Ġstatus Ġupdates . Ċ Ġ*/ Ċ @ Re usable Ċ class ĠNetwork Connectivity Model Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġconnectivity Manager : ĠConnect ivity Manager , ĊĠĠĠ Ġprivate Ġval Ġapplication : ĠApplication Ċ ) Ġ{ ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠAn Ġinfinite Ġobservable Ġthat Ġemits Ġa Ġboolean Ġvalue Ġwhenever Ġthe Ġnetwork Ġcondition Ġchanges . ĊĠĠĠĠ Ġ* ĠE mitted Ġvalue Ġis Ġtrue Ġwhen Ġthe Ġnetwork Ġis Ġin Ġthe Ġconnected Ġstate , Ġand Ġit Ġis Ġfalse Ġotherwise . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġ@ Suppress (" DE PREC ATION ") ĊĠĠĠ Ġfun Ġconnectivity (): ĠObservable < Boolean > Ġ= ĠBroadcast Receiver Observable ( ĊĠĠĠĠĠĠĠ ĠNET WORK _ BRO ADCAST _ ACTION , ĊĠĠĠĠĠĠĠ Ġapplication ĊĠĠĠ Ġ). map Ġ{ Ġconnectivity Manager . active Network Info ?. isConnected Ġ== Ġtrue Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠNET WORK _ BRO ADCAST _ ACTION Ġ= Ġ" android . net . conn . CONNECT IVITY _ CHANGE " ĊĠĠĠ Ġ} Ċ Ċ } Ċ