Skip to content

Commit f5269e4

Browse files
author
Rob Orgiu
committed
Update DragAndDropSnippets to match the new documentation
1 parent 36d1904 commit f5269e4

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/draganddrop/DragAndDropSnippets.kt

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import androidx.annotation.RequiresApi
2424
import androidx.compose.foundation.ExperimentalFoundationApi
2525
import androidx.compose.foundation.draganddrop.dragAndDropSource
2626
import androidx.compose.foundation.draganddrop.dragAndDropTarget
27-
import androidx.compose.foundation.gestures.detectTapGestures
2827
import androidx.compose.runtime.Composable
2928
import androidx.compose.runtime.remember
3029
import androidx.compose.ui.Modifier
@@ -41,39 +40,30 @@ private fun DragAndDropSnippet() {
4140
val url = ""
4241

4342
// [START android_compose_drag_and_drop_1]
44-
Modifier.dragAndDropSource {
45-
detectTapGestures(onLongPress = {
46-
// Transfer data here.
47-
})
43+
Modifier.dragAndDropSource { _ ->
44+
// Transfer data here.
45+
null
4846
}
4947
// [END android_compose_drag_and_drop_1]
5048

5149
// [START android_compose_drag_and_drop_2]
52-
Modifier.dragAndDropSource {
53-
detectTapGestures(onLongPress = {
54-
startTransfer(
55-
DragAndDropTransferData(
56-
ClipData.newPlainText(
57-
"image Url", url
58-
)
59-
)
50+
Modifier.dragAndDropSource { _ ->
51+
DragAndDropTransferData(
52+
ClipData.newPlainText(
53+
"image Url", url
6054
)
61-
})
55+
)
6256
}
6357
// [END android_compose_drag_and_drop_2]
6458

6559
// [START android_compose_drag_and_drop_3]
66-
Modifier.dragAndDropSource {
67-
detectTapGestures(onLongPress = {
68-
startTransfer(
69-
DragAndDropTransferData(
70-
ClipData.newPlainText(
71-
"image Url", url
72-
),
73-
flags = View.DRAG_FLAG_GLOBAL
74-
)
75-
)
76-
})
60+
Modifier.dragAndDropSource { _ ->
61+
DragAndDropTransferData(
62+
ClipData.newPlainText(
63+
"image Url", url
64+
),
65+
flags = View.DRAG_FLAG_GLOBAL
66+
)
7767
}
7868
// [END android_compose_drag_and_drop_3]
7969

0 commit comments

Comments
 (0)