Skip to content

Commit

Permalink
refactor openMF#198: convert null checks in Network.kt to kotlin style
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparsh1212 committed Dec 9, 2020
1 parent 1766684 commit 35198f4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/src/main/kotlin/org/mifos/mobile/cn/ui/utils/Network.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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)
}

/**
Expand Down

0 comments on commit 35198f4

Please sign in to comment.