Created
January 22, 2019 21:21
-
-
Save ahmed3elshaer/43bd680c0f6484bf92f22fde4e1f8935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun queryCalenderProvider( | |
uri: Uri = CalendarContract.Calendars.CONTENT_URI, | |
eventProjection: Array<String>, | |
selection: String? = null, | |
selectionArgs: Array<String>? = null, | |
callback: (Cursor?) -> Unit | |
) { | |
if (ContextCompat.checkSelfPermission( | |
context, | |
Manifest.permission.READ_CALENDAR | |
) == PackageManager.PERMISSION_GRANTED | |
) { | |
doAsync { | |
val cursor = contentResolver.query(uri, eventProjection, selection, selectionArgs, null) | |
uiThread { callback(cursor) } | |
} | |
} else { | |
callback(null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment