0
PermissionUtils.permission(PermissionConstants.CALENDAR, PermissionConstants.MICROPHONE)
.rationale { activity, shouldRequest -> DialogHelper.showRationaleDialog(activity, shouldRequest) }
.callback(object : PermissionUtils.FullCallback {
override fun onGranted(permissionsGranted: List<String>) {
LogUtils.d(permissionsGranted)
if (permissionsGranted.size == 2) {
showSnackbar(true, "Calendar or Microphone is granted")
}
itemsView.updateItems(bindItems())
}
override fun onDenied(permissionsDeniedForever: List<String>,
permissionsDenied: List<String>) {
LogUtils.d(permissionsDeniedForever, permissionsDenied)
if (permissionsDeniedForever.isNotEmpty()) {
showSnackbar(false, "Calendar or Microphone is denied forever")
} else {
showSnackbar(false, "Calendar or Microphone is denied")
}
itemsView.updateItems(bindItems())
}
})
.request()
这个可以多个权限请求,有的同意,有的拒绝的情况下,不用总去判断permissionsGranted.size是否和自己传进来的一样大!,有时候会再加入有个权限,但是忘记吧permissionsGranted.size == 2改成permissionsGranted.size == 3,导致错误