From 35198f4a5be2dac05e52f981cbad3409dd3c7655 Mon Sep 17 00:00:00 2001 From: Sparsh1212 Date: Wed, 9 Dec 2020 15:34:02 +0530 Subject: [PATCH] refactor #198: convert null checks in Network.kt to kotlin style --- .../kotlin/org/mifos/mobile/cn/ui/utils/Network.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/org/mifos/mobile/cn/ui/utils/Network.kt b/app/src/main/kotlin/org/mifos/mobile/cn/ui/utils/Network.kt index 78675fc0..b92ac619 100644 --- a/app/src/main/kotlin/org/mifos/mobile/cn/ui/utils/Network.kt +++ b/app/src/main/kotlin/org/mifos/mobile/cn/ui/utils/Network.kt @@ -25,7 +25,7 @@ object Network { */ fun isConnected(context: Context): Boolean { val info = Network.getNetworkInfo(context) - return info != null && info.isConnected + return info ?. isConnected ?: false } /** @@ -37,8 +37,8 @@ object Network { */ fun isConnectedWifi(context: Context): Boolean { val info = Network.getNetworkInfo(context) - return info != null && info.isConnected && - info.type == ConnectivityManager.TYPE_WIFI + return info ?. isConnected ?: false && + info ?. type == ConnectivityManager.TYPE_WIFI } /** @@ -50,8 +50,8 @@ object Network { */ fun isConnectedMobile(context: Context): Boolean { val info = Network.getNetworkInfo(context) - return info != null && info.isConnected && - info.type == ConnectivityManager.TYPE_MOBILE + return info ?. isConnected ?: false && + info ?. type == ConnectivityManager.TYPE_MOBILE } /** @@ -62,8 +62,8 @@ object Network { */ fun isConnectedFast(context: Context): Boolean { val info = Network.getNetworkInfo(context) - return info != null && info.isConnected && - Network.isConnectionFast(info.type, info.subtype) + return info ?. isConnected ?: false && + Network.isConnectionFast(info !!. type, info.subtype) } /**