diff --git a/dpadrecyclerview-compose/api/dpadrecyclerview-compose.api b/dpadrecyclerview-compose/api/dpadrecyclerview-compose.api index 0dbdc1b5..be534b34 100644 --- a/dpadrecyclerview-compose/api/dpadrecyclerview-compose.api +++ b/dpadrecyclerview-compose/api/dpadrecyclerview-compose.api @@ -1,7 +1,7 @@ public abstract class com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder : androidx/recyclerview/widget/RecyclerView$ViewHolder, com/rubensousa/dpadrecyclerview/DpadViewHolder { public static final field $stable I - public fun (Landroid/view/ViewGroup;Z)V - public synthetic fun (Landroid/view/ViewGroup;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Landroid/view/ViewGroup;ZLandroidx/compose/ui/platform/ViewCompositionStrategy;)V + public synthetic fun (Landroid/view/ViewGroup;ZLandroidx/compose/ui/platform/ViewCompositionStrategy;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public abstract fun Content (Ljava/lang/Object;ZZLandroidx/compose/runtime/Composer;I)V public final fun getItem ()Ljava/lang/Object; public fun getSubPositionAlignments ()Ljava/util/List; @@ -14,8 +14,8 @@ public abstract class com/rubensousa/dpadrecyclerview/compose/DpadAbstractCompos public class com/rubensousa/dpadrecyclerview/compose/DpadComposeViewHolder : com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder { public static final field $stable I - public fun (Landroid/view/ViewGroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function5;)V - public synthetic fun (Landroid/view/ViewGroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLkotlin/jvm/functions/Function5;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Landroid/view/ViewGroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLandroidx/compose/ui/platform/ViewCompositionStrategy;Lkotlin/jvm/functions/Function5;)V + public synthetic fun (Landroid/view/ViewGroup;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ZLandroidx/compose/ui/platform/ViewCompositionStrategy;Lkotlin/jvm/functions/Function5;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public fun Content (Ljava/lang/Object;ZZLandroidx/compose/runtime/Composer;I)V } diff --git a/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder.kt b/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder.kt index b6df0e5a..9173ee9b 100644 --- a/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder.kt +++ b/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadAbstractComposeViewHolder.kt @@ -20,6 +20,7 @@ import android.view.ViewGroup import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.platform.ComposeView +import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.recyclerview.widget.RecyclerView import com.rubensousa.dpadrecyclerview.DpadViewHolder @@ -41,7 +42,8 @@ import com.rubensousa.dpadrecyclerview.DpadViewHolder */ abstract class DpadAbstractComposeViewHolder( parent: ViewGroup, - isFocusable: Boolean = true + isFocusable: Boolean = true, + compositionStrategy: ViewCompositionStrategy = RecyclerViewCompositionStrategy.DisposeOnRecycled ) : RecyclerView.ViewHolder(ComposeView(parent.context)), DpadViewHolder { private val itemState = mutableStateOf(null) @@ -50,7 +52,7 @@ abstract class DpadAbstractComposeViewHolder( init { val composeView = itemView as ComposeView - composeView.setViewCompositionStrategy(RecyclerViewCompositionStrategy.DisposeOnRecycled) + composeView.setViewCompositionStrategy(compositionStrategy) composeView.isFocusable = isFocusable composeView.isFocusableInTouchMode = isFocusable composeView.descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS diff --git a/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadComposeViewHolder.kt b/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadComposeViewHolder.kt index aeefe18b..0fb88789 100644 --- a/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadComposeViewHolder.kt +++ b/dpadrecyclerview-compose/src/main/java/com/rubensousa/dpadrecyclerview/compose/DpadComposeViewHolder.kt @@ -17,6 +17,7 @@ package com.rubensousa.dpadrecyclerview.compose import android.view.ViewGroup import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.ViewCompositionStrategy /** * A basic implementation of [DpadAbstractComposeViewHolder] @@ -44,8 +45,9 @@ open class DpadComposeViewHolder( onClick: ((item: T) -> Unit)? = null, onLongClick: ((item: T) -> Boolean)? = null, isFocusable: Boolean = true, + compositionStrategy: ViewCompositionStrategy = RecyclerViewCompositionStrategy.DisposeOnRecycled, private val composable: DpadComposable, -) : DpadAbstractComposeViewHolder(parent, isFocusable) { +) : DpadAbstractComposeViewHolder(parent, isFocusable, compositionStrategy) { init { if (onClick != null) {