Skip to content

Commit

Permalink
Merge pull request #11 from lriccardo/dev
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
lriccardo authored Jan 24, 2022
2 parents 6b3dcb7 + 32467f7 commit 6805770
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ allprojects {

```gradle
dependencies {
implementation 'com.github.lriccardo:TimelineView:1.1.0'
implementation 'com.github.lriccardo:TimelineView:1.1.1'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ class TimelineDecorator(
}

override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
c.save()
c.clipRect(parent.paddingLeft, parent.paddingTop, parent.width, parent.height-parent.paddingBottom)

parent.children.forEach {
val itemPosition = parent.getChildAdapterPosition(it)

if (itemPosition == RecyclerView.NO_POSITION)
return

val timelineView = TimelineView(context = parent.context)
(parent.adapter as? TimelineAdapter)?.run {

(parent.adapter as? TimelineAdapter ?: object : TimelineAdapter {}).run {
getTimelineViewType(itemPosition)?.let {
timelineView.viewType = it
} ?: timelineView.setType(itemPosition, parent.adapter?.itemCount ?: -1)
Expand Down Expand Up @@ -95,6 +99,7 @@ class TimelineDecorator(
timelineView.linePadding = it
}
}

timelineView.indicatorSize = indicatorSize

timelineView.indicatorYPosition = indicatorYPosition
Expand Down Expand Up @@ -127,16 +132,17 @@ class TimelineDecorator(
c.save()
when (position) {
Position.Left -> {
c.translate(padding, it.top.toFloat())
c.translate(padding+parent.paddingLeft, it.top.toFloat())
timelineView.layout(0, 0, timelineView.measuredWidth, it.measuredHeight)
}
Position.Right -> {
c.translate(it.measuredWidth + padding, it.top.toFloat())
c.translate(it.measuredWidth + padding + parent.paddingLeft, it.top.toFloat())
timelineView.layout(0, 0, timelineView.measuredWidth, it.measuredHeight)
}
}
timelineView.draw(c)
c.restore()
}
c.restore()
}
}

0 comments on commit 6805770

Please sign in to comment.