diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotSelector.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotSelector.kt index 7b1c823c..deec0392 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotSelector.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/PivotSelector.kt @@ -213,6 +213,11 @@ internal class PivotSelector( } fun onLayoutCompleted() { + if (isSelectionUpdatePending) { + isSelectionUpdatePending = false + dispatchViewHolderSelected() + dispatchViewHolderSelectedAndAligned() + } /** * Always update the selected ViewHolder on every layout update */ @@ -223,11 +228,6 @@ internal class PivotSelector( } } } - if (isSelectionUpdatePending) { - isSelectionUpdatePending = false - dispatchViewHolderSelected() - dispatchViewHolderSelectedAndAligned() - } } fun getCurrentSubPositions(): Int { @@ -350,15 +350,13 @@ internal class PivotSelector( listener.onViewHolderDeselected(recyclerView, viewHolder) } } - if (viewHolder is DpadViewHolder) { - selectedViewHolder = viewHolder viewHolder.onViewHolderSelected() - } else { - selectedViewHolder = null } } + selectedViewHolder = viewHolder + if (viewHolder != null) { selectionListeners.forEach { listener -> listener.onViewHolderSelected(