Skip to content

Commit a9926b7

Browse files
committed
Use function to delete captured item
1 parent 7090f28 commit a9926b7

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

app/src/main/java/app/grapheneos/camera/ui/composable/screen/GalleryScreen.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package app.grapheneos.camera.ui.composable.screen
22

33
import android.content.ActivityNotFoundException
44
import android.content.Intent
5-
import android.provider.DocumentsContract
6-
import android.provider.MediaStore
75
import android.util.Log
86
import android.widget.Toast
97
import androidx.compose.animation.animateColorAsState
@@ -141,18 +139,7 @@ fun GalleryScreen(
141139
deletionItem = itemToBeDeleted,
142140
onDeleteAction = { item ->
143141
coroutineScope.launch {
144-
var result = false
145-
146-
val uri = item.uri
147-
try {
148-
result = if (uri.authority == MediaStore.AUTHORITY) {
149-
context.contentResolver.delete(uri, null, null) > 0
150-
} else {
151-
DocumentsContract.deleteDocument(context.contentResolver, uri)
152-
}
153-
} catch (e: Exception) {
154-
e.printStackTrace()
155-
}
142+
val result = item.delete(context)
156143

157144
if (result) {
158145
capturedItems.remove(item)

0 commit comments

Comments
 (0)