Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor #198: convert null checks in Network.kt to kotlin style #201

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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