Skip to content

Commit

Permalink
Use "use" to be more safe in case of failures + Nice syntax (#92)
Browse files Browse the repository at this point in the history
* Use use to be more safe

* Even more idiomatic Kotlin

---------

Co-authored-by: filip-misztal <filip.misztal@schibsted.com>
  • Loading branch information
xserxses and filip-misztal committed Sep 22, 2023
1 parent 8df3e43 commit 0528cf8
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ internal class SessionInfoManager(context: Context) {
}

private fun isSessionPresent(authority: String): Boolean {
val cursor =
contentResolver.query(
Uri.parse("content://${authority}/sessions"),
null,
null,
null,
null
)
val isSessionPresent = cursor?.count != null && cursor.count > 0
cursor?.close()
return isSessionPresent
return contentResolver.query(
Uri.parse("content://${authority}/sessions"),
null,
null,
null,
null
)?.use {
it.count > 0
} ?: false
}

suspend fun isUserLoggedInOnTheDevice(): Boolean {
Expand Down

0 comments on commit 0528cf8

Please sign in to comment.