Skip to content

Commit

Permalink
More refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
igsosa92 committed Oct 25, 2019
1 parent 1d04d12 commit f4a9cde
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ class PermissionManager @Inject constructor(
* the permissions to be requested. Returns **true** if every requested permission
* was already granted, **false** otherwise.
*/
fun requestPermission(fragment: Fragment, listener: PermissionListener?, vararg permissions: String): Boolean =
fun requestPermission(fragment: Fragment, listener: PermissionListener?, vararg permissions: String) =
with(filterUngranted(*permissions)) {
if (isNotEmpty()) {
fragment.requestPermissions(this, requestCount)
requestListeners.put(requestCount++, listener)
false
} else {
listener?.onPermissionsGranted()
true
}
return isEmpty()
}

/**
Expand All @@ -66,15 +67,16 @@ class PermissionManager @Inject constructor(
* the permissions to be requested. Returns **true** if every requested permission
* was already granted, **false** otherwise.
*/
fun requestPermission(activity: Activity, listener: PermissionListener?, vararg permissions: String): Boolean =
fun requestPermission(activity: Activity, listener: PermissionListener?, vararg permissions: String) =
with(filterUngranted(*permissions)) {
if (isNotEmpty()) {
ActivityCompat.requestPermissions(activity, this, requestCount)
requestListeners.put(requestCount++, listener)
false
} else {
listener?.onPermissionsGranted()
true
}
return isEmpty()
}

/**
Expand Down

0 comments on commit f4a9cde

Please sign in to comment.