package Ġcom . she ma 1 0 2 . spac ex tracker . data . network Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . Connectivity Manager Ċ import Ġandroid . net . Network Capabilities Ċ import Ġcom . she ma 1 0 2 . spac ex tracker . internal . No Connectivity Exception Ċ import Ġokhttp 3 . Interceptor Ċ import Ġokhttp 3 . Response Ċ Ċ class ĠConnect ivity Interceptor Impl Ġconstructor ( ĊĠĠĠ Ġcontext : ĠContext Ċ ) Ġ: ĠConnect ivity Interceptor Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġapp Context Ġ= Ġcontext . application Context ĊĊĠĠĠ Ġoverride Ġfun Ġintercept ( chain : ĠInter ceptor . Chain ): ĠResponse Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! is Network Available ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠNo Connectivity Exception () ĊĠĠĠĠĠĠĠ Ġreturn Ġchain . proceed ( chain . request ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Network Available (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconnectivity Manager : ĠConnect ivity Manager Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapp Context . getSystem Service ( Context . CONNECT IVITY _ SERVICE ) Ġas ĠConnect ivity Manager ĊĊĠĠĠĠĠĠĠ Ġval Ġactive Network Ġ= Ġconnectivity Manager . active Network ĊĠĠĠĠĠĠĠ Ġval Ġnetwork Capabilities Ġ= Ġconnectivity Manager ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. get Network Capabilities ( active Network ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġnetwork Capabilities Ġ!= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ&& Ġnetwork Capabilities . has Capability ( Network Capabilities . NET _ CAP ABILITY _ INTER NET ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ&& Ġnetwork Capabilities . has Capability ( Network Capabilities . NET _ CAP ABILITY _ VALID ATED ) ĊĠĠĠ Ġ} Ċ }