aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'sample/src/main/kotlin')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt4
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt26
2 files changed, 23 insertions, 7 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index 5d0bd36..09002d4 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -169,6 +169,10 @@ class MainActivity : KPrefActivity() {
onClick = { _, _, _ -> startActivityWithEdge(SWIPE_EDGE_LEFT); false }
}
+ plainText(R.string.image_showcase) {
+ onClick = { _, _, _ -> kauLaunchMediaPicker(ImagePickerActivity::class.java, REQUEST_MEDIA); false }
+ }
+
plainText(R.string.video_overlay_showcase) {
onClick = { _, _, _ -> kauLaunchMediaPicker(VideoPickerActivityOverlay::class.java, REQUEST_MEDIA); false }
}
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
index 7aac0ef..618ca07 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt
@@ -1,16 +1,28 @@
package ca.allanwang.kau.sample
-import ca.allanwang.kau.mediapicker.MediaPickerActivityBase
-import ca.allanwang.kau.mediapicker.MediaPickerActivityOverlayBase
-import ca.allanwang.kau.mediapicker.MediaType
+import android.content.Context
+import android.net.Uri
+import android.support.v4.content.FileProvider
+import ca.allanwang.kau.mediapicker.*
+import java.io.File
/**
* Created by Allan Wang on 2017-07-23.
*/
-class ImagePickerActivity : MediaPickerActivityBase(MediaType.IMAGE)
+private fun actions(multiple: Boolean) = listOf(object : MediaActionCamera() {
-class ImagePickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.IMAGE)
+ override fun createFile(context: Context): File
+ = createMediaFile("KAU", ".jpg")
-class VideoPickerActivity : MediaPickerActivityBase(MediaType.VIDEO)
+ override fun createUri(context: Context, file: File): Uri
+ = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file)
-class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO) \ No newline at end of file
+}, MediaActionGallery(multiple))
+
+class ImagePickerActivity : MediaPickerActivityBase(MediaType.IMAGE, actions(true))
+
+class ImagePickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.IMAGE, actions(false))
+
+class VideoPickerActivity : MediaPickerActivityBase(MediaType.VIDEO, actions(true))
+
+class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO, actions(false)) \ No newline at end of file