Skip to content

Commit

Permalink
Fix selected position arrow issue
Browse files Browse the repository at this point in the history
  • Loading branch information
worker8 committed Aug 15, 2018
1 parent 176f0b5 commit dc91368
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AccordianView @JvmOverloads constructor(context: Context, attrs: Attribute
if (value < _adapter.getItemCount() && value >= 0 && field != value) {
field = value
applyConstraint()
onBindAllViewHolders()
}
}
}
Expand Down Expand Up @@ -57,11 +58,7 @@ class AccordianView @JvmOverloads constructor(context: Context, attrs: Attribute
contentViewHolder?.let { _contentViewHolder ->
_contentViewHolder.itemView.visibility = View.INVISIBLE
selectedPosition = index
titleViewHolderArray.forEachIndexed { innerIndex, innerViewHolder ->
_adapter.onBindViewForTitle(innerViewHolder, innerIndex, arrowDirection(innerIndex))
}

_adapter.onBindViewForContent(_contentViewHolder, index)
onBindAllViewHolders()
_contentViewHolder.itemView.visibility = View.VISIBLE
}
}
Expand All @@ -72,6 +69,18 @@ class AccordianView @JvmOverloads constructor(context: Context, attrs: Attribute
}
}

private fun onBindAllViewHolders() {
adapter?.let { _adapter ->
contentViewHolder?.let { _contentViewHolder ->
titleViewHolderArray.forEachIndexed { innerIndex, innerViewHolder ->
_adapter.onBindViewForTitle(innerViewHolder, innerIndex, arrowDirection(innerIndex))
}

_adapter.onBindViewForContent(_contentViewHolder, selectedPosition)
}
}
}

private fun createContent() {
adapter?.let { _adapter ->
if (contentViewHolder == null) {
Expand Down

0 comments on commit dc91368

Please sign in to comment.