File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
compose-recyclerview/src/main/java/com/example/compose_recyclerview Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 11package com.example.compose_recyclerview
22
3+ import android.util.Log
34import androidx.compose.runtime.Composable
45import androidx.compose.runtime.DisposableEffect
6+ import androidx.compose.runtime.LaunchedEffect
57import androidx.compose.runtime.getValue
68import androidx.compose.runtime.mutableStateOf
79import androidx.compose.runtime.remember
@@ -98,6 +100,11 @@ fun <T> ComposeRecyclerView(
98100 ItemTouchHelperConfig ().apply { itemTouchHelperConfig?.invoke(this ) }
99101 }
100102
103+ // To disable drag and drop when itemTypeBuilder is null
104+ LaunchedEffect (itemTypeBuilder) {
105+ config.isLongPressDragEnabled = itemTypeBuilder != null
106+ }
107+
101108 val itemTouchHelper = remember {
102109 ItemTouchHelper (object : ItemTouchHelper .SimpleCallback (
103110 config.dragDirs ? : (UP or DOWN or START or END ), config.swipeDirs ? : (LEFT or RIGHT )
You can’t perform that action at this time.
0 commit comments