aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
Diffstat (limited to 'sample/src/main/kotlin/ca/allanwang')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt22
1 files changed, 16 insertions, 6 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
index b793f40..2ba7731 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
@@ -1,12 +1,10 @@
package ca.allanwang.kau.sample
import android.os.Bundle
+import android.provider.MediaStore
import android.support.v7.app.AppCompatActivity
import ca.allanwang.kau.logging.KL
-import ca.allanwang.kau.permissions.PERMISSION_ACCESS_COARSE_LOCATION
-import ca.allanwang.kau.permissions.PERMISSION_ACCESS_FINE_LOCATION
-import ca.allanwang.kau.permissions.kauOnRequestPermissionsResult
-import ca.allanwang.kau.permissions.kauRequestPermissions
+import ca.allanwang.kau.permissions.*
import ca.allanwang.kau.utils.fullLinearRecycler
import ca.allanwang.kau.utils.startActivitySlideOut
import ca.allanwang.kau.utils.toast
@@ -27,8 +25,8 @@ class AnimActivity : AppCompatActivity() {
adapter.add(listOf(
PERMISSION_ACCESS_COARSE_LOCATION,
PERMISSION_ACCESS_FINE_LOCATION
- ).map{ PermissionCheckbox(it) })
- adapter.withOnClickListener { _, _, item, _ ->
+ ).map { PermissionCheckbox(it) })
+ val withOnClickListener = adapter.withOnClickListener { _, _, item, _ ->
KL.d("Perm Click")
kauRequestPermissions(item.permission) {
granted, deniedPerm ->
@@ -37,6 +35,18 @@ class AnimActivity : AppCompatActivity() {
}
true
}
+ kauRequestPermissions(PERMISSION_READ_EXTERNAL_STORAGE) {
+ granted, deniedPerm ->
+ if (!granted) return@kauRequestPermissions
+ val cursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
+ arrayOf(MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_MODIFIED),
+ null, null, MediaStore.Images.Media.DEFAULT_SORT_ORDER, null)
+ while (!cursor.isLast) {
+ cursor.moveToNext()
+ KL.d(cursor.getString(1))
+ }
+ cursor.close()
+ }
}
override fun onBackPressed() {