-
Notifications
You must be signed in to change notification settings - Fork 11
/
SimpleGalleryCameraActivity.kt
28 lines (23 loc) · 1.04 KB
/
SimpleGalleryCameraActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.gallery.sample.camera
import android.app.Activity
import android.content.Intent
import android.net.Uri
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.os.bundleOf
import develop.file.gallery.compat.extensions.ActivityCompat.requireGalleryFragment
import develop.file.gallery.ui.material.activity.MaterialGalleryActivity
class SimpleGalleryCameraActivity : MaterialGalleryActivity() {
private val cameraLauncher =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { intent ->
when (intent.resultCode) {
Activity.RESULT_CANCELED -> requireGalleryFragment.onCameraResultCanceled()
Activity.RESULT_OK -> requireGalleryFragment.onCameraResultOk()
}
}
override fun onCustomCamera(uri: Uri): Boolean {
cameraLauncher.launch(Intent(this, SimpleCameraActivity::class.java).apply {
putExtras(bundleOf(SimpleCameraActivity.CUSTOM_CAMERA_OUT_PUT_URI to uri))
})
return true
}
}