From fa03e597492b705e8c73ecbc4a82b7d2ec92d8d3 Mon Sep 17 00:00:00 2001 From: cp-megh Date: Tue, 28 May 2024 11:19:35 +0530 Subject: [PATCH] Update AGP Dependency --- build.gradle.kts | 4 ++-- compose-recyclerview/build.gradle.kts | 6 +++--- .../compose_recyclerview/ComposeRecyclerView.kt | 1 + .../utils/ItemTouchHelperConfig.kt | 3 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- sample-app/build.gradle.kts | 10 +++++----- .../com/example/composerecyclerview/MainActivity.kt | 4 +++- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 49aa71c..3ab5fc8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id("com.android.application") version "8.1.2" apply false + id("com.android.application") version "8.4.1" apply false id("org.jetbrains.kotlin.android") version "1.9.10" apply false - id("com.android.library") version "8.1.2" apply false + id("com.android.library") version "8.4.1" apply false id ("io.github.gradle-nexus.publish-plugin") version "1.1.0" } diff --git a/compose-recyclerview/build.gradle.kts b/compose-recyclerview/build.gradle.kts index 13f2360..31562b8 100644 --- a/compose-recyclerview/build.gradle.kts +++ b/compose-recyclerview/build.gradle.kts @@ -61,10 +61,10 @@ android { dependencies { - implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.core:core-ktx:1.13.1") implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.activity:activity-compose:1.8.2") - implementation("com.google.android.material:material:1.11.0") + implementation("androidx.activity:activity-compose:1.9.0") + implementation("com.google.android.material:material:1.12.0") testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") diff --git a/compose-recyclerview/src/main/java/com/example/compose_recyclerview/ComposeRecyclerView.kt b/compose-recyclerview/src/main/java/com/example/compose_recyclerview/ComposeRecyclerView.kt index e6a262a..1c8f074 100644 --- a/compose-recyclerview/src/main/java/com/example/compose_recyclerview/ComposeRecyclerView.kt +++ b/compose-recyclerview/src/main/java/com/example/compose_recyclerview/ComposeRecyclerView.kt @@ -36,6 +36,7 @@ import com.example.compose_recyclerview.utils.ItemTouchHelperConfig * @param itemTypeBuilder The optional lambda function to determine the type of each item. * * Required for effective drag and drop. Provide a non-null [ComposeRecyclerViewAdapter.ItemTypeBuilder] when enabling drag and drop functionality. * * Useful when dealing with multiple item types, ensuring proper handling and layout customization for each type. + * * If not provided, the builder will be considered as null and drag-and-drop functionality will be disabled. * @param onDragCompleted Callback triggered when an item drag operation is completed. * @param itemTouchHelperConfig Configuration block for customizing the behavior of ItemTouchHelper. * * Specify non-draggable item types, handle drag-and-drop and swipe actions, customize the appearance during drag, and more. diff --git a/compose-recyclerview/src/main/java/com/example/compose_recyclerview/utils/ItemTouchHelperConfig.kt b/compose-recyclerview/src/main/java/com/example/compose_recyclerview/utils/ItemTouchHelperConfig.kt index 7084e0b..31adfec 100644 --- a/compose-recyclerview/src/main/java/com/example/compose_recyclerview/utils/ItemTouchHelperConfig.kt +++ b/compose-recyclerview/src/main/java/com/example/compose_recyclerview/utils/ItemTouchHelperConfig.kt @@ -12,6 +12,8 @@ import androidx.recyclerview.widget.RecyclerView * @property getMovementFlags Callback for providing movement flags for drag and swipe behavior. * @property onSelectedChanged Callback for handling changes in the selection state of an item. * @property isLongPressDragEnabled Flag to enable or disable long press drag behavior. + * @property swipeDirs Swipe directions for items. If not provided, all directions are enabled by default. + * @property dragDirs Drag directions for items. If not provided, left or right directions are enabled by default. */ class ItemTouchHelperConfig { var nonDraggableItemTypes: Set = emptySet() @@ -62,6 +64,7 @@ class ItemTouchHelperConfig { /** * Flag to enable or disable long press drag behavior. + * Default is true. */ var isLongPressDragEnabled: Boolean = true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 21b4167..568bbb5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Dec 18 17:15:12 IST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sample-app/build.gradle.kts b/sample-app/build.gradle.kts index 5c5f29c..e1b4ff3 100644 --- a/sample-app/build.gradle.kts +++ b/sample-app/build.gradle.kts @@ -51,10 +51,10 @@ android { dependencies { implementation(project(path = ":compose-recyclerview")) - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") - implementation("androidx.activity:activity-compose:1.8.1") - implementation(platform("androidx.compose:compose-bom:2023.03.00")) + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.0") + implementation("androidx.activity:activity-compose:1.9.0") + implementation(platform("androidx.compose:compose-bom:2024.05.00")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-tooling-preview") @@ -62,7 +62,7 @@ dependencies { testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) + androidTestImplementation(platform("androidx.compose:compose-bom:2024.05.00")) androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") diff --git a/sample-app/src/main/java/com/example/composerecyclerview/MainActivity.kt b/sample-app/src/main/java/com/example/composerecyclerview/MainActivity.kt index facff81..4c55ac4 100644 --- a/sample-app/src/main/java/com/example/composerecyclerview/MainActivity.kt +++ b/sample-app/src/main/java/com/example/composerecyclerview/MainActivity.kt @@ -63,7 +63,7 @@ class MainActivity : ComponentActivity() { ComposeRecyclerView( modifier = Modifier.fillMaxSize(), items = listOf(1) + userDataList + listOf(1) + otherUsersDataList, - itemBuilder = { item, index -> + itemBuilder = { _, index -> if (index == 0) { Box( modifier = Modifier.fillMaxWidth(), @@ -137,6 +137,8 @@ class MainActivity : ComponentActivity() { override fun getItemType(position: Int): Int { // Determine the item type based on the position // You can customize this logic based on your requirements + // Required for effective drag and drop. Provide a non-null [ComposeRecyclerViewAdapter.ItemTypeBuilder] + // when enabling drag and drop functionality. return when { position == 0 -> ITEM_TYPE_FIRST_HEADER // Header type position <= userDataList.size -> ITEM_TYPE_FIRST_LIST_ITEM // First list item type